babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237
  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 _tempQuaternion;
  52084. private _tempVector;
  52085. private _tempVector2;
  52086. /**
  52087. * Creates a gizmo
  52088. * @param gizmoLayer The utility layer the gizmo will be added to
  52089. */
  52090. constructor(
  52091. /** The utility layer the gizmo will be added to */
  52092. gizmoLayer?: UtilityLayerRenderer);
  52093. /**
  52094. * Updates the gizmo to match the attached mesh's position/rotation
  52095. */
  52096. protected _update(): void;
  52097. /**
  52098. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52099. * @param value Node, TransformNode or mesh
  52100. */
  52101. protected _matrixChanged(): void;
  52102. /**
  52103. * Disposes of the gizmo
  52104. */
  52105. dispose(): void;
  52106. }
  52107. }
  52108. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52109. import { Observable } from "babylonjs/Misc/observable";
  52110. import { Nullable } from "babylonjs/types";
  52111. import { Vector3 } from "babylonjs/Maths/math.vector";
  52112. import { Color3 } from "babylonjs/Maths/math.color";
  52113. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52114. import { Node } from "babylonjs/node";
  52115. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52116. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52117. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52118. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52119. import { Scene } from "babylonjs/scene";
  52120. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52121. /**
  52122. * Single plane drag gizmo
  52123. */
  52124. export class PlaneDragGizmo extends Gizmo {
  52125. /**
  52126. * Drag behavior responsible for the gizmos dragging interactions
  52127. */
  52128. dragBehavior: PointerDragBehavior;
  52129. private _pointerObserver;
  52130. /**
  52131. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52132. */
  52133. snapDistance: number;
  52134. /**
  52135. * Event that fires each time the gizmo snaps to a new location.
  52136. * * snapDistance is the the change in distance
  52137. */
  52138. onSnapObservable: Observable<{
  52139. snapDistance: number;
  52140. }>;
  52141. private _plane;
  52142. private _coloredMaterial;
  52143. private _hoverMaterial;
  52144. private _isEnabled;
  52145. private _parent;
  52146. /** @hidden */
  52147. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52148. /** @hidden */
  52149. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52150. /**
  52151. * Creates a PlaneDragGizmo
  52152. * @param gizmoLayer The utility layer the gizmo will be added to
  52153. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52154. * @param color The color of the gizmo
  52155. */
  52156. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52157. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52158. /**
  52159. * If the gizmo is enabled
  52160. */
  52161. set isEnabled(value: boolean);
  52162. get isEnabled(): boolean;
  52163. /**
  52164. * Disposes of the gizmo
  52165. */
  52166. dispose(): void;
  52167. }
  52168. }
  52169. declare module "babylonjs/Gizmos/positionGizmo" {
  52170. import { Observable } from "babylonjs/Misc/observable";
  52171. import { Nullable } from "babylonjs/types";
  52172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52173. import { Node } from "babylonjs/node";
  52174. import { Mesh } from "babylonjs/Meshes/mesh";
  52175. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52176. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52177. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52178. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52179. /**
  52180. * Gizmo that enables dragging a mesh along 3 axis
  52181. */
  52182. export class PositionGizmo extends Gizmo {
  52183. /**
  52184. * Internal gizmo used for interactions on the x axis
  52185. */
  52186. xGizmo: AxisDragGizmo;
  52187. /**
  52188. * Internal gizmo used for interactions on the y axis
  52189. */
  52190. yGizmo: AxisDragGizmo;
  52191. /**
  52192. * Internal gizmo used for interactions on the z axis
  52193. */
  52194. zGizmo: AxisDragGizmo;
  52195. /**
  52196. * Internal gizmo used for interactions on the yz plane
  52197. */
  52198. xPlaneGizmo: PlaneDragGizmo;
  52199. /**
  52200. * Internal gizmo used for interactions on the xz plane
  52201. */
  52202. yPlaneGizmo: PlaneDragGizmo;
  52203. /**
  52204. * Internal gizmo used for interactions on the xy plane
  52205. */
  52206. zPlaneGizmo: PlaneDragGizmo;
  52207. /**
  52208. * private variables
  52209. */
  52210. private _meshAttached;
  52211. private _nodeAttached;
  52212. private _updateGizmoRotationToMatchAttachedMesh;
  52213. private _snapDistance;
  52214. private _scaleRatio;
  52215. /** Fires an event when any of it's sub gizmos are dragged */
  52216. onDragStartObservable: Observable<unknown>;
  52217. /** Fires an event when any of it's sub gizmos are released from dragging */
  52218. onDragEndObservable: Observable<unknown>;
  52219. /**
  52220. * If set to true, planar drag is enabled
  52221. */
  52222. private _planarGizmoEnabled;
  52223. get attachedMesh(): Nullable<AbstractMesh>;
  52224. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52225. get attachedNode(): Nullable<Node>;
  52226. set attachedNode(node: Nullable<Node>);
  52227. /**
  52228. * Creates a PositionGizmo
  52229. * @param gizmoLayer The utility layer the gizmo will be added to
  52230. @param thickness display gizmo axis thickness
  52231. */
  52232. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52233. /**
  52234. * If the planar drag gizmo is enabled
  52235. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52236. */
  52237. set planarGizmoEnabled(value: boolean);
  52238. get planarGizmoEnabled(): boolean;
  52239. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52240. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52241. /**
  52242. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52243. */
  52244. set snapDistance(value: number);
  52245. get snapDistance(): number;
  52246. /**
  52247. * Ratio for the scale of the gizmo (Default: 1)
  52248. */
  52249. set scaleRatio(value: number);
  52250. get scaleRatio(): number;
  52251. /**
  52252. * Disposes of the gizmo
  52253. */
  52254. dispose(): void;
  52255. /**
  52256. * CustomMeshes are not supported by this gizmo
  52257. * @param mesh The mesh to replace the default mesh of the gizmo
  52258. */
  52259. setCustomMesh(mesh: Mesh): void;
  52260. }
  52261. }
  52262. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52263. import { Observable } from "babylonjs/Misc/observable";
  52264. import { Nullable } from "babylonjs/types";
  52265. import { Vector3 } from "babylonjs/Maths/math.vector";
  52266. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52267. import { Node } from "babylonjs/node";
  52268. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52269. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52270. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52271. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52272. import { Scene } from "babylonjs/scene";
  52273. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52274. import { Color3 } from "babylonjs/Maths/math.color";
  52275. /**
  52276. * Single axis drag gizmo
  52277. */
  52278. export class AxisDragGizmo extends Gizmo {
  52279. /**
  52280. * Drag behavior responsible for the gizmos dragging interactions
  52281. */
  52282. dragBehavior: PointerDragBehavior;
  52283. private _pointerObserver;
  52284. /**
  52285. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52286. */
  52287. snapDistance: number;
  52288. /**
  52289. * Event that fires each time the gizmo snaps to a new location.
  52290. * * snapDistance is the the change in distance
  52291. */
  52292. onSnapObservable: Observable<{
  52293. snapDistance: number;
  52294. }>;
  52295. private _isEnabled;
  52296. private _parent;
  52297. private _arrow;
  52298. private _coloredMaterial;
  52299. private _hoverMaterial;
  52300. /** @hidden */
  52301. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52302. /** @hidden */
  52303. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52304. /**
  52305. * Creates an AxisDragGizmo
  52306. * @param gizmoLayer The utility layer the gizmo will be added to
  52307. * @param dragAxis The axis which the gizmo will be able to drag on
  52308. * @param color The color of the gizmo
  52309. * @param thickness display gizmo axis thickness
  52310. */
  52311. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52312. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52313. /**
  52314. * If the gizmo is enabled
  52315. */
  52316. set isEnabled(value: boolean);
  52317. get isEnabled(): boolean;
  52318. /**
  52319. * Disposes of the gizmo
  52320. */
  52321. dispose(): void;
  52322. }
  52323. }
  52324. declare module "babylonjs/Debug/axesViewer" {
  52325. import { Vector3 } from "babylonjs/Maths/math.vector";
  52326. import { Nullable } from "babylonjs/types";
  52327. import { Scene } from "babylonjs/scene";
  52328. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52329. /**
  52330. * The Axes viewer will show 3 axes in a specific point in space
  52331. */
  52332. export class AxesViewer {
  52333. private _xAxis;
  52334. private _yAxis;
  52335. private _zAxis;
  52336. private _scaleLinesFactor;
  52337. private _instanced;
  52338. /**
  52339. * Gets the hosting scene
  52340. */
  52341. scene: Scene;
  52342. /**
  52343. * Gets or sets a number used to scale line length
  52344. */
  52345. scaleLines: number;
  52346. /** Gets the node hierarchy used to render x-axis */
  52347. get xAxis(): TransformNode;
  52348. /** Gets the node hierarchy used to render y-axis */
  52349. get yAxis(): TransformNode;
  52350. /** Gets the node hierarchy used to render z-axis */
  52351. get zAxis(): TransformNode;
  52352. /**
  52353. * Creates a new AxesViewer
  52354. * @param scene defines the hosting scene
  52355. * @param scaleLines defines a number used to scale line length (1 by default)
  52356. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52357. * @param xAxis defines the node hierarchy used to render the x-axis
  52358. * @param yAxis defines the node hierarchy used to render the y-axis
  52359. * @param zAxis defines the node hierarchy used to render the z-axis
  52360. */
  52361. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52362. /**
  52363. * Force the viewer to update
  52364. * @param position defines the position of the viewer
  52365. * @param xaxis defines the x axis of the viewer
  52366. * @param yaxis defines the y axis of the viewer
  52367. * @param zaxis defines the z axis of the viewer
  52368. */
  52369. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52370. /**
  52371. * Creates an instance of this axes viewer.
  52372. * @returns a new axes viewer with instanced meshes
  52373. */
  52374. createInstance(): AxesViewer;
  52375. /** Releases resources */
  52376. dispose(): void;
  52377. private static _SetRenderingGroupId;
  52378. }
  52379. }
  52380. declare module "babylonjs/Debug/boneAxesViewer" {
  52381. import { Nullable } from "babylonjs/types";
  52382. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52383. import { Vector3 } from "babylonjs/Maths/math.vector";
  52384. import { Mesh } from "babylonjs/Meshes/mesh";
  52385. import { Bone } from "babylonjs/Bones/bone";
  52386. import { Scene } from "babylonjs/scene";
  52387. /**
  52388. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52389. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52390. */
  52391. export class BoneAxesViewer extends AxesViewer {
  52392. /**
  52393. * Gets or sets the target mesh where to display the axes viewer
  52394. */
  52395. mesh: Nullable<Mesh>;
  52396. /**
  52397. * Gets or sets the target bone where to display the axes viewer
  52398. */
  52399. bone: Nullable<Bone>;
  52400. /** Gets current position */
  52401. pos: Vector3;
  52402. /** Gets direction of X axis */
  52403. xaxis: Vector3;
  52404. /** Gets direction of Y axis */
  52405. yaxis: Vector3;
  52406. /** Gets direction of Z axis */
  52407. zaxis: Vector3;
  52408. /**
  52409. * Creates a new BoneAxesViewer
  52410. * @param scene defines the hosting scene
  52411. * @param bone defines the target bone
  52412. * @param mesh defines the target mesh
  52413. * @param scaleLines defines a scaling factor for line length (1 by default)
  52414. */
  52415. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52416. /**
  52417. * Force the viewer to update
  52418. */
  52419. update(): void;
  52420. /** Releases resources */
  52421. dispose(): void;
  52422. }
  52423. }
  52424. declare module "babylonjs/Debug/debugLayer" {
  52425. import { Scene } from "babylonjs/scene";
  52426. /**
  52427. * Interface used to define scene explorer extensibility option
  52428. */
  52429. export interface IExplorerExtensibilityOption {
  52430. /**
  52431. * Define the option label
  52432. */
  52433. label: string;
  52434. /**
  52435. * Defines the action to execute on click
  52436. */
  52437. action: (entity: any) => void;
  52438. }
  52439. /**
  52440. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52441. */
  52442. export interface IExplorerExtensibilityGroup {
  52443. /**
  52444. * Defines a predicate to test if a given type mut be extended
  52445. */
  52446. predicate: (entity: any) => boolean;
  52447. /**
  52448. * Gets the list of options added to a type
  52449. */
  52450. entries: IExplorerExtensibilityOption[];
  52451. }
  52452. /**
  52453. * Interface used to define the options to use to create the Inspector
  52454. */
  52455. export interface IInspectorOptions {
  52456. /**
  52457. * Display in overlay mode (default: false)
  52458. */
  52459. overlay?: boolean;
  52460. /**
  52461. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52462. */
  52463. globalRoot?: HTMLElement;
  52464. /**
  52465. * Display the Scene explorer
  52466. */
  52467. showExplorer?: boolean;
  52468. /**
  52469. * Display the property inspector
  52470. */
  52471. showInspector?: boolean;
  52472. /**
  52473. * Display in embed mode (both panes on the right)
  52474. */
  52475. embedMode?: boolean;
  52476. /**
  52477. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52478. */
  52479. handleResize?: boolean;
  52480. /**
  52481. * Allow the panes to popup (default: true)
  52482. */
  52483. enablePopup?: boolean;
  52484. /**
  52485. * Allow the panes to be closed by users (default: true)
  52486. */
  52487. enableClose?: boolean;
  52488. /**
  52489. * Optional list of extensibility entries
  52490. */
  52491. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52492. /**
  52493. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52494. */
  52495. inspectorURL?: string;
  52496. /**
  52497. * Optional initial tab (default to DebugLayerTab.Properties)
  52498. */
  52499. initialTab?: DebugLayerTab;
  52500. }
  52501. module "babylonjs/scene" {
  52502. interface Scene {
  52503. /**
  52504. * @hidden
  52505. * Backing field
  52506. */
  52507. _debugLayer: DebugLayer;
  52508. /**
  52509. * Gets the debug layer (aka Inspector) associated with the scene
  52510. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52511. */
  52512. debugLayer: DebugLayer;
  52513. }
  52514. }
  52515. /**
  52516. * Enum of inspector action tab
  52517. */
  52518. export enum DebugLayerTab {
  52519. /**
  52520. * Properties tag (default)
  52521. */
  52522. Properties = 0,
  52523. /**
  52524. * Debug tab
  52525. */
  52526. Debug = 1,
  52527. /**
  52528. * Statistics tab
  52529. */
  52530. Statistics = 2,
  52531. /**
  52532. * Tools tab
  52533. */
  52534. Tools = 3,
  52535. /**
  52536. * Settings tab
  52537. */
  52538. Settings = 4
  52539. }
  52540. /**
  52541. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52542. * what is happening in your scene
  52543. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52544. */
  52545. export class DebugLayer {
  52546. /**
  52547. * Define the url to get the inspector script from.
  52548. * By default it uses the babylonjs CDN.
  52549. * @ignoreNaming
  52550. */
  52551. static InspectorURL: string;
  52552. private _scene;
  52553. private BJSINSPECTOR;
  52554. private _onPropertyChangedObservable?;
  52555. /**
  52556. * Observable triggered when a property is changed through the inspector.
  52557. */
  52558. get onPropertyChangedObservable(): any;
  52559. /**
  52560. * Instantiates a new debug layer.
  52561. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52562. * what is happening in your scene
  52563. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52564. * @param scene Defines the scene to inspect
  52565. */
  52566. constructor(scene: Scene);
  52567. /** Creates the inspector window. */
  52568. private _createInspector;
  52569. /**
  52570. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52571. * @param entity defines the entity to select
  52572. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52573. */
  52574. select(entity: any, lineContainerTitles?: string | string[]): void;
  52575. /** Get the inspector from bundle or global */
  52576. private _getGlobalInspector;
  52577. /**
  52578. * Get if the inspector is visible or not.
  52579. * @returns true if visible otherwise, false
  52580. */
  52581. isVisible(): boolean;
  52582. /**
  52583. * Hide the inspector and close its window.
  52584. */
  52585. hide(): void;
  52586. /**
  52587. * Update the scene in the inspector
  52588. */
  52589. setAsActiveScene(): void;
  52590. /**
  52591. * Launch the debugLayer.
  52592. * @param config Define the configuration of the inspector
  52593. * @return a promise fulfilled when the debug layer is visible
  52594. */
  52595. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52596. }
  52597. }
  52598. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52599. import { Nullable } from "babylonjs/types";
  52600. import { Scene } from "babylonjs/scene";
  52601. import { Vector4 } from "babylonjs/Maths/math.vector";
  52602. import { Color4 } from "babylonjs/Maths/math.color";
  52603. import { Mesh } from "babylonjs/Meshes/mesh";
  52604. /**
  52605. * Class containing static functions to help procedurally build meshes
  52606. */
  52607. export class BoxBuilder {
  52608. /**
  52609. * Creates a box mesh
  52610. * * The parameter `size` sets the size (float) of each box side (default 1)
  52611. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52612. * * 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)
  52613. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52617. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52618. * @param name defines the name of the mesh
  52619. * @param options defines the options used to create the mesh
  52620. * @param scene defines the hosting scene
  52621. * @returns the box mesh
  52622. */
  52623. static CreateBox(name: string, options: {
  52624. size?: number;
  52625. width?: number;
  52626. height?: number;
  52627. depth?: number;
  52628. faceUV?: Vector4[];
  52629. faceColors?: Color4[];
  52630. sideOrientation?: number;
  52631. frontUVs?: Vector4;
  52632. backUVs?: Vector4;
  52633. wrap?: boolean;
  52634. topBaseAt?: number;
  52635. bottomBaseAt?: number;
  52636. updatable?: boolean;
  52637. }, scene?: Nullable<Scene>): Mesh;
  52638. }
  52639. }
  52640. declare module "babylonjs/Debug/physicsViewer" {
  52641. import { Nullable } from "babylonjs/types";
  52642. import { Scene } from "babylonjs/scene";
  52643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52644. import { Mesh } from "babylonjs/Meshes/mesh";
  52645. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52646. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52647. /**
  52648. * Used to show the physics impostor around the specific mesh
  52649. */
  52650. export class PhysicsViewer {
  52651. /** @hidden */
  52652. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52653. /** @hidden */
  52654. protected _meshes: Array<Nullable<AbstractMesh>>;
  52655. /** @hidden */
  52656. protected _scene: Nullable<Scene>;
  52657. /** @hidden */
  52658. protected _numMeshes: number;
  52659. /** @hidden */
  52660. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52661. private _renderFunction;
  52662. private _utilityLayer;
  52663. private _debugBoxMesh;
  52664. private _debugSphereMesh;
  52665. private _debugCylinderMesh;
  52666. private _debugMaterial;
  52667. private _debugMeshMeshes;
  52668. /**
  52669. * Creates a new PhysicsViewer
  52670. * @param scene defines the hosting scene
  52671. */
  52672. constructor(scene: Scene);
  52673. /** @hidden */
  52674. protected _updateDebugMeshes(): void;
  52675. /**
  52676. * Renders a specified physic impostor
  52677. * @param impostor defines the impostor to render
  52678. * @param targetMesh defines the mesh represented by the impostor
  52679. * @returns the new debug mesh used to render the impostor
  52680. */
  52681. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52682. /**
  52683. * Hides a specified physic impostor
  52684. * @param impostor defines the impostor to hide
  52685. */
  52686. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52687. private _getDebugMaterial;
  52688. private _getDebugBoxMesh;
  52689. private _getDebugSphereMesh;
  52690. private _getDebugCylinderMesh;
  52691. private _getDebugMeshMesh;
  52692. private _getDebugMesh;
  52693. /** Releases all resources */
  52694. dispose(): void;
  52695. }
  52696. }
  52697. declare module "babylonjs/Debug/rayHelper" {
  52698. import { Nullable } from "babylonjs/types";
  52699. import { Ray } from "babylonjs/Culling/ray";
  52700. import { Vector3 } from "babylonjs/Maths/math.vector";
  52701. import { Color3 } from "babylonjs/Maths/math.color";
  52702. import { Scene } from "babylonjs/scene";
  52703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52704. import "babylonjs/Meshes/Builders/linesBuilder";
  52705. /**
  52706. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52707. * in order to better appreciate the issue one might have.
  52708. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52709. */
  52710. export class RayHelper {
  52711. /**
  52712. * Defines the ray we are currently tryin to visualize.
  52713. */
  52714. ray: Nullable<Ray>;
  52715. private _renderPoints;
  52716. private _renderLine;
  52717. private _renderFunction;
  52718. private _scene;
  52719. private _updateToMeshFunction;
  52720. private _attachedToMesh;
  52721. private _meshSpaceDirection;
  52722. private _meshSpaceOrigin;
  52723. /**
  52724. * Helper function to create a colored helper in a scene in one line.
  52725. * @param ray Defines the ray we are currently tryin to visualize
  52726. * @param scene Defines the scene the ray is used in
  52727. * @param color Defines the color we want to see the ray in
  52728. * @returns The newly created ray helper.
  52729. */
  52730. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52731. /**
  52732. * Instantiate a new ray helper.
  52733. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52734. * in order to better appreciate the issue one might have.
  52735. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52736. * @param ray Defines the ray we are currently tryin to visualize
  52737. */
  52738. constructor(ray: Ray);
  52739. /**
  52740. * Shows the ray we are willing to debug.
  52741. * @param scene Defines the scene the ray needs to be rendered in
  52742. * @param color Defines the color the ray needs to be rendered in
  52743. */
  52744. show(scene: Scene, color?: Color3): void;
  52745. /**
  52746. * Hides the ray we are debugging.
  52747. */
  52748. hide(): void;
  52749. private _render;
  52750. /**
  52751. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52752. * @param mesh Defines the mesh we want the helper attached to
  52753. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52754. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52755. * @param length Defines the length of the ray
  52756. */
  52757. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52758. /**
  52759. * Detach the ray helper from the mesh it has previously been attached to.
  52760. */
  52761. detachFromMesh(): void;
  52762. private _updateToMesh;
  52763. /**
  52764. * Dispose the helper and release its associated resources.
  52765. */
  52766. dispose(): void;
  52767. }
  52768. }
  52769. declare module "babylonjs/Debug/ISkeletonViewer" {
  52770. /**
  52771. * Defines the options associated with the creation of a SkeletonViewer.
  52772. */
  52773. export interface ISkeletonViewerOptions {
  52774. /** Should the system pause animations before building the Viewer? */
  52775. pauseAnimations: boolean;
  52776. /** Should the system return the skeleton to rest before building? */
  52777. returnToRest: boolean;
  52778. /** public Display Mode of the Viewer */
  52779. displayMode: number;
  52780. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52781. displayOptions: ISkeletonViewerDisplayOptions;
  52782. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52783. computeBonesUsingShaders: boolean;
  52784. }
  52785. /**
  52786. * Defines how to display the various bone meshes for the viewer.
  52787. */
  52788. export interface ISkeletonViewerDisplayOptions {
  52789. /** How far down to start tapering the bone spurs */
  52790. midStep?: number;
  52791. /** How big is the midStep? */
  52792. midStepFactor?: number;
  52793. /** Base for the Sphere Size */
  52794. sphereBaseSize?: number;
  52795. /** The ratio of the sphere to the longest bone in units */
  52796. sphereScaleUnit?: number;
  52797. /** Ratio for the Sphere Size */
  52798. sphereFactor?: number;
  52799. }
  52800. }
  52801. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52802. import { Nullable } from "babylonjs/types";
  52803. import { Scene } from "babylonjs/scene";
  52804. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52805. import { Color4 } from "babylonjs/Maths/math.color";
  52806. import { Mesh } from "babylonjs/Meshes/mesh";
  52807. /**
  52808. * Class containing static functions to help procedurally build meshes
  52809. */
  52810. export class RibbonBuilder {
  52811. /**
  52812. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52813. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52814. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52815. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52816. * * 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
  52817. * * 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
  52818. * * 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
  52819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52822. * * 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
  52823. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52824. * * 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
  52825. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52827. * @param name defines the name of the mesh
  52828. * @param options defines the options used to create the mesh
  52829. * @param scene defines the hosting scene
  52830. * @returns the ribbon mesh
  52831. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52833. */
  52834. static CreateRibbon(name: string, options: {
  52835. pathArray: Vector3[][];
  52836. closeArray?: boolean;
  52837. closePath?: boolean;
  52838. offset?: number;
  52839. updatable?: boolean;
  52840. sideOrientation?: number;
  52841. frontUVs?: Vector4;
  52842. backUVs?: Vector4;
  52843. instance?: Mesh;
  52844. invertUV?: boolean;
  52845. uvs?: Vector2[];
  52846. colors?: Color4[];
  52847. }, scene?: Nullable<Scene>): Mesh;
  52848. }
  52849. }
  52850. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52851. import { Nullable } from "babylonjs/types";
  52852. import { Scene } from "babylonjs/scene";
  52853. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52854. import { Mesh } from "babylonjs/Meshes/mesh";
  52855. /**
  52856. * Class containing static functions to help procedurally build meshes
  52857. */
  52858. export class ShapeBuilder {
  52859. /**
  52860. * 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.
  52861. * * 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.
  52862. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52863. * * 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.
  52864. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52865. * * 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
  52866. * * 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
  52867. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52872. * @param name defines the name of the mesh
  52873. * @param options defines the options used to create the mesh
  52874. * @param scene defines the hosting scene
  52875. * @returns the extruded shape mesh
  52876. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52878. */
  52879. static ExtrudeShape(name: string, options: {
  52880. shape: Vector3[];
  52881. path: Vector3[];
  52882. scale?: number;
  52883. rotation?: number;
  52884. cap?: number;
  52885. updatable?: boolean;
  52886. sideOrientation?: number;
  52887. frontUVs?: Vector4;
  52888. backUVs?: Vector4;
  52889. instance?: Mesh;
  52890. invertUV?: boolean;
  52891. }, scene?: Nullable<Scene>): Mesh;
  52892. /**
  52893. * Creates an custom extruded shape mesh.
  52894. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52895. * * 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.
  52896. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52897. * * 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
  52898. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52899. * * 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
  52900. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52901. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52902. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52903. * * 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
  52904. * * 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
  52905. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52908. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52910. * @param name defines the name of the mesh
  52911. * @param options defines the options used to create the mesh
  52912. * @param scene defines the hosting scene
  52913. * @returns the custom extruded shape mesh
  52914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52917. */
  52918. static ExtrudeShapeCustom(name: string, options: {
  52919. shape: Vector3[];
  52920. path: Vector3[];
  52921. scaleFunction?: any;
  52922. rotationFunction?: any;
  52923. ribbonCloseArray?: boolean;
  52924. ribbonClosePath?: boolean;
  52925. cap?: number;
  52926. updatable?: boolean;
  52927. sideOrientation?: number;
  52928. frontUVs?: Vector4;
  52929. backUVs?: Vector4;
  52930. instance?: Mesh;
  52931. invertUV?: boolean;
  52932. }, scene?: Nullable<Scene>): Mesh;
  52933. private static _ExtrudeShapeGeneric;
  52934. }
  52935. }
  52936. declare module "babylonjs/Debug/skeletonViewer" {
  52937. import { Color3 } from "babylonjs/Maths/math.color";
  52938. import { Scene } from "babylonjs/scene";
  52939. import { Nullable } from "babylonjs/types";
  52940. import { Skeleton } from "babylonjs/Bones/skeleton";
  52941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52942. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52943. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52944. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52945. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  52946. /**
  52947. * Class used to render a debug view of a given skeleton
  52948. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52949. */
  52950. export class SkeletonViewer {
  52951. /** defines the skeleton to render */
  52952. skeleton: Skeleton;
  52953. /** defines the mesh attached to the skeleton */
  52954. mesh: AbstractMesh;
  52955. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52956. autoUpdateBonesMatrices: boolean;
  52957. /** defines the rendering group id to use with the viewer */
  52958. renderingGroupId: number;
  52959. /** is the options for the viewer */
  52960. options: Partial<ISkeletonViewerOptions>;
  52961. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  52962. static readonly DISPLAY_LINES: number;
  52963. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  52964. static readonly DISPLAY_SPHERES: number;
  52965. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  52966. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  52967. /** If SkeletonViewer scene scope. */
  52968. private _scene;
  52969. /** Gets or sets the color used to render the skeleton */
  52970. color: Color3;
  52971. /** Array of the points of the skeleton fo the line view. */
  52972. private _debugLines;
  52973. /** The SkeletonViewers Mesh. */
  52974. private _debugMesh;
  52975. /** If SkeletonViewer is enabled. */
  52976. private _isEnabled;
  52977. /** If SkeletonViewer is ready. */
  52978. private _ready;
  52979. /** SkeletonViewer render observable. */
  52980. private _obs;
  52981. /** The Utility Layer to render the gizmos in. */
  52982. private _utilityLayer;
  52983. /** Gets the Scene. */
  52984. get scene(): Scene;
  52985. /** Gets the utilityLayer. */
  52986. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  52987. /** Checks Ready Status. */
  52988. get isReady(): Boolean;
  52989. /** Sets Ready Status. */
  52990. set ready(value: boolean);
  52991. /** Gets the debugMesh */
  52992. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  52993. /** Sets the debugMesh */
  52994. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  52995. /** Gets the material */
  52996. get material(): StandardMaterial;
  52997. /** Sets the material */
  52998. set material(value: StandardMaterial);
  52999. /**
  53000. * Creates a new SkeletonViewer
  53001. * @param skeleton defines the skeleton to render
  53002. * @param mesh defines the mesh attached to the skeleton
  53003. * @param scene defines the hosting scene
  53004. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53005. * @param renderingGroupId defines the rendering group id to use with the viewer
  53006. * @param options All of the extra constructor options for the SkeletonViewer
  53007. */
  53008. constructor(
  53009. /** defines the skeleton to render */
  53010. skeleton: Skeleton,
  53011. /** defines the mesh attached to the skeleton */
  53012. mesh: AbstractMesh,
  53013. /** The Scene scope*/
  53014. scene: Scene,
  53015. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53016. autoUpdateBonesMatrices?: boolean,
  53017. /** defines the rendering group id to use with the viewer */
  53018. renderingGroupId?: number,
  53019. /** is the options for the viewer */
  53020. options?: Partial<ISkeletonViewerOptions>);
  53021. /** The Dynamic bindings for the update functions */
  53022. private _bindObs;
  53023. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53024. update(): void;
  53025. /** Gets or sets a boolean indicating if the viewer is enabled */
  53026. set isEnabled(value: boolean);
  53027. get isEnabled(): boolean;
  53028. private _getBonePosition;
  53029. private _getLinesForBonesWithLength;
  53030. private _getLinesForBonesNoLength;
  53031. /** function to revert the mesh and scene back to the initial state. */
  53032. private _revert;
  53033. /** function to build and bind sphere joint points and spur bone representations. */
  53034. private _buildSpheresAndSpurs;
  53035. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53036. private _displayLinesUpdate;
  53037. /** Release associated resources */
  53038. dispose(): void;
  53039. }
  53040. }
  53041. declare module "babylonjs/Debug/index" {
  53042. export * from "babylonjs/Debug/axesViewer";
  53043. export * from "babylonjs/Debug/boneAxesViewer";
  53044. export * from "babylonjs/Debug/debugLayer";
  53045. export * from "babylonjs/Debug/physicsViewer";
  53046. export * from "babylonjs/Debug/rayHelper";
  53047. export * from "babylonjs/Debug/skeletonViewer";
  53048. export * from "babylonjs/Debug/ISkeletonViewer";
  53049. }
  53050. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53051. /**
  53052. * Enum for Device Types
  53053. */
  53054. export enum DeviceType {
  53055. /** Generic */
  53056. Generic = 0,
  53057. /** Keyboard */
  53058. Keyboard = 1,
  53059. /** Mouse */
  53060. Mouse = 2,
  53061. /** Touch Pointers */
  53062. Touch = 3,
  53063. /** PS4 Dual Shock */
  53064. DualShock = 4,
  53065. /** Xbox */
  53066. Xbox = 5,
  53067. /** Switch Controller */
  53068. Switch = 6
  53069. }
  53070. /**
  53071. * Enum for All Pointers (Touch/Mouse)
  53072. */
  53073. export enum PointerInput {
  53074. /** Horizontal Axis */
  53075. Horizontal = 0,
  53076. /** Vertical Axis */
  53077. Vertical = 1,
  53078. /** Left Click or Touch */
  53079. LeftClick = 2,
  53080. /** Middle Click */
  53081. MiddleClick = 3,
  53082. /** Right Click */
  53083. RightClick = 4,
  53084. /** Browser Back */
  53085. BrowserBack = 5,
  53086. /** Browser Forward */
  53087. BrowserForward = 6
  53088. }
  53089. /**
  53090. * Enum for Dual Shock Gamepad
  53091. */
  53092. export enum DualShockInput {
  53093. /** Cross */
  53094. Cross = 0,
  53095. /** Circle */
  53096. Circle = 1,
  53097. /** Square */
  53098. Square = 2,
  53099. /** Triangle */
  53100. Triangle = 3,
  53101. /** L1 */
  53102. L1 = 4,
  53103. /** R1 */
  53104. R1 = 5,
  53105. /** L2 */
  53106. L2 = 6,
  53107. /** R2 */
  53108. R2 = 7,
  53109. /** Share */
  53110. Share = 8,
  53111. /** Options */
  53112. Options = 9,
  53113. /** L3 */
  53114. L3 = 10,
  53115. /** R3 */
  53116. R3 = 11,
  53117. /** DPadUp */
  53118. DPadUp = 12,
  53119. /** DPadDown */
  53120. DPadDown = 13,
  53121. /** DPadLeft */
  53122. DPadLeft = 14,
  53123. /** DRight */
  53124. DPadRight = 15,
  53125. /** Home */
  53126. Home = 16,
  53127. /** TouchPad */
  53128. TouchPad = 17,
  53129. /** LStickXAxis */
  53130. LStickXAxis = 18,
  53131. /** LStickYAxis */
  53132. LStickYAxis = 19,
  53133. /** RStickXAxis */
  53134. RStickXAxis = 20,
  53135. /** RStickYAxis */
  53136. RStickYAxis = 21
  53137. }
  53138. /**
  53139. * Enum for Xbox Gamepad
  53140. */
  53141. export enum XboxInput {
  53142. /** A */
  53143. A = 0,
  53144. /** B */
  53145. B = 1,
  53146. /** X */
  53147. X = 2,
  53148. /** Y */
  53149. Y = 3,
  53150. /** LB */
  53151. LB = 4,
  53152. /** RB */
  53153. RB = 5,
  53154. /** LT */
  53155. LT = 6,
  53156. /** RT */
  53157. RT = 7,
  53158. /** Back */
  53159. Back = 8,
  53160. /** Start */
  53161. Start = 9,
  53162. /** LS */
  53163. LS = 10,
  53164. /** RS */
  53165. RS = 11,
  53166. /** DPadUp */
  53167. DPadUp = 12,
  53168. /** DPadDown */
  53169. DPadDown = 13,
  53170. /** DPadLeft */
  53171. DPadLeft = 14,
  53172. /** DRight */
  53173. DPadRight = 15,
  53174. /** Home */
  53175. Home = 16,
  53176. /** LStickXAxis */
  53177. LStickXAxis = 17,
  53178. /** LStickYAxis */
  53179. LStickYAxis = 18,
  53180. /** RStickXAxis */
  53181. RStickXAxis = 19,
  53182. /** RStickYAxis */
  53183. RStickYAxis = 20
  53184. }
  53185. /**
  53186. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53187. */
  53188. export enum SwitchInput {
  53189. /** B */
  53190. B = 0,
  53191. /** A */
  53192. A = 1,
  53193. /** Y */
  53194. Y = 2,
  53195. /** X */
  53196. X = 3,
  53197. /** L */
  53198. L = 4,
  53199. /** R */
  53200. R = 5,
  53201. /** ZL */
  53202. ZL = 6,
  53203. /** ZR */
  53204. ZR = 7,
  53205. /** Minus */
  53206. Minus = 8,
  53207. /** Plus */
  53208. Plus = 9,
  53209. /** LS */
  53210. LS = 10,
  53211. /** RS */
  53212. RS = 11,
  53213. /** DPadUp */
  53214. DPadUp = 12,
  53215. /** DPadDown */
  53216. DPadDown = 13,
  53217. /** DPadLeft */
  53218. DPadLeft = 14,
  53219. /** DRight */
  53220. DPadRight = 15,
  53221. /** Home */
  53222. Home = 16,
  53223. /** Capture */
  53224. Capture = 17,
  53225. /** LStickXAxis */
  53226. LStickXAxis = 18,
  53227. /** LStickYAxis */
  53228. LStickYAxis = 19,
  53229. /** RStickXAxis */
  53230. RStickXAxis = 20,
  53231. /** RStickYAxis */
  53232. RStickYAxis = 21
  53233. }
  53234. }
  53235. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53236. import { Engine } from "babylonjs/Engines/engine";
  53237. import { IDisposable } from "babylonjs/scene";
  53238. import { Nullable } from "babylonjs/types";
  53239. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53240. /**
  53241. * This class will take all inputs from Keyboard, Pointer, and
  53242. * any Gamepads and provide a polling system that all devices
  53243. * will use. This class assumes that there will only be one
  53244. * pointer device and one keyboard.
  53245. */
  53246. export class DeviceInputSystem implements IDisposable {
  53247. /**
  53248. * Callback to be triggered when a device is connected
  53249. */
  53250. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53251. /**
  53252. * Callback to be triggered when a device is disconnected
  53253. */
  53254. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53255. /**
  53256. * Callback to be triggered when event driven input is updated
  53257. */
  53258. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53259. private _inputs;
  53260. private _gamepads;
  53261. private _keyboardActive;
  53262. private _pointerActive;
  53263. private _elementToAttachTo;
  53264. private _keyboardDownEvent;
  53265. private _keyboardUpEvent;
  53266. private _pointerMoveEvent;
  53267. private _pointerDownEvent;
  53268. private _pointerUpEvent;
  53269. private _gamepadConnectedEvent;
  53270. private _gamepadDisconnectedEvent;
  53271. private static _MAX_KEYCODES;
  53272. private static _MAX_POINTER_INPUTS;
  53273. private constructor();
  53274. /**
  53275. * Creates a new DeviceInputSystem instance
  53276. * @param engine Engine to pull input element from
  53277. * @returns The new instance
  53278. */
  53279. static Create(engine: Engine): DeviceInputSystem;
  53280. /**
  53281. * Checks for current device input value, given an id and input index
  53282. * @param deviceName Id of connected device
  53283. * @param inputIndex Index of device input
  53284. * @returns Current value of input
  53285. */
  53286. /**
  53287. * Checks for current device input value, given an id and input index
  53288. * @param deviceType Enum specifiying device type
  53289. * @param deviceSlot "Slot" or index that device is referenced in
  53290. * @param inputIndex Id of input to be checked
  53291. * @returns Current value of input
  53292. */
  53293. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  53294. /**
  53295. * Dispose of all the eventlisteners
  53296. */
  53297. dispose(): void;
  53298. /**
  53299. * Add device and inputs to device array
  53300. * @param deviceType Enum specifiying device type
  53301. * @param deviceSlot "Slot" or index that device is referenced in
  53302. * @param numberOfInputs Number of input entries to create for given device
  53303. */
  53304. private _registerDevice;
  53305. /**
  53306. * Given a specific device name, remove that device from the device map
  53307. * @param deviceType Enum specifiying device type
  53308. * @param deviceSlot "Slot" or index that device is referenced in
  53309. */
  53310. private _unregisterDevice;
  53311. /**
  53312. * Handle all actions that come from keyboard interaction
  53313. */
  53314. private _handleKeyActions;
  53315. /**
  53316. * Handle all actions that come from pointer interaction
  53317. */
  53318. private _handlePointerActions;
  53319. /**
  53320. * Handle all actions that come from gamepad interaction
  53321. */
  53322. private _handleGamepadActions;
  53323. /**
  53324. * Update all non-event based devices with each frame
  53325. * @param deviceType Enum specifiying device type
  53326. * @param deviceSlot "Slot" or index that device is referenced in
  53327. * @param inputIndex Id of input to be checked
  53328. */
  53329. private _updateDevice;
  53330. /**
  53331. * Gets DeviceType from the device name
  53332. * @param deviceName Name of Device from DeviceInputSystem
  53333. * @returns DeviceType enum value
  53334. */
  53335. private _getGamepadDeviceType;
  53336. }
  53337. }
  53338. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53339. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53340. /**
  53341. * Type to handle enforcement of inputs
  53342. */
  53343. 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;
  53344. }
  53345. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53346. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53347. import { Engine } from "babylonjs/Engines/engine";
  53348. import { IDisposable } from "babylonjs/scene";
  53349. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53350. import { Nullable } from "babylonjs/types";
  53351. import { Observable } from "babylonjs/Misc/observable";
  53352. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53353. /**
  53354. * Class that handles all input for a specific device
  53355. */
  53356. export class DeviceSource<T extends DeviceType> {
  53357. /** Type of device */
  53358. readonly deviceType: DeviceType;
  53359. /** "Slot" or index that device is referenced in */
  53360. readonly deviceSlot: number;
  53361. /**
  53362. * Observable to handle device input changes per device
  53363. */
  53364. readonly onInputChangedObservable: Observable<{
  53365. inputIndex: DeviceInput<T>;
  53366. previousState: Nullable<number>;
  53367. currentState: Nullable<number>;
  53368. }>;
  53369. private readonly _deviceInputSystem;
  53370. /**
  53371. * Default Constructor
  53372. * @param deviceInputSystem Reference to DeviceInputSystem
  53373. * @param deviceType Type of device
  53374. * @param deviceSlot "Slot" or index that device is referenced in
  53375. */
  53376. constructor(deviceInputSystem: DeviceInputSystem,
  53377. /** Type of device */
  53378. deviceType: DeviceType,
  53379. /** "Slot" or index that device is referenced in */
  53380. deviceSlot?: number);
  53381. /**
  53382. * Get input for specific input
  53383. * @param inputIndex index of specific input on device
  53384. * @returns Input value from DeviceInputSystem
  53385. */
  53386. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53387. }
  53388. /**
  53389. * Class to keep track of devices
  53390. */
  53391. export class DeviceSourceManager implements IDisposable {
  53392. /**
  53393. * Observable to be triggered when before a device is connected
  53394. */
  53395. readonly onBeforeDeviceConnectedObservable: Observable<{
  53396. deviceType: DeviceType;
  53397. deviceSlot: number;
  53398. }>;
  53399. /**
  53400. * Observable to be triggered when before a device is disconnected
  53401. */
  53402. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53403. deviceType: DeviceType;
  53404. deviceSlot: number;
  53405. }>;
  53406. /**
  53407. * Observable to be triggered when after a device is connected
  53408. */
  53409. readonly onAfterDeviceConnectedObservable: Observable<{
  53410. deviceType: DeviceType;
  53411. deviceSlot: number;
  53412. }>;
  53413. /**
  53414. * Observable to be triggered when after a device is disconnected
  53415. */
  53416. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53417. deviceType: DeviceType;
  53418. deviceSlot: number;
  53419. }>;
  53420. private readonly _devices;
  53421. private readonly _firstDevice;
  53422. private readonly _deviceInputSystem;
  53423. /**
  53424. * Default Constructor
  53425. * @param engine engine to pull input element from
  53426. */
  53427. constructor(engine: Engine);
  53428. /**
  53429. * Gets a DeviceSource, given a type and slot
  53430. * @param deviceType Enum specifying device type
  53431. * @param deviceSlot "Slot" or index that device is referenced in
  53432. * @returns DeviceSource object
  53433. */
  53434. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53435. /**
  53436. * Gets an array of DeviceSource objects for a given device type
  53437. * @param deviceType Enum specifying device type
  53438. * @returns Array of DeviceSource objects
  53439. */
  53440. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53441. /**
  53442. * Dispose of DeviceInputSystem and other parts
  53443. */
  53444. dispose(): void;
  53445. /**
  53446. * Function to add device name to device list
  53447. * @param deviceType Enum specifying device type
  53448. * @param deviceSlot "Slot" or index that device is referenced in
  53449. */
  53450. private _addDevice;
  53451. /**
  53452. * Function to remove device name to device list
  53453. * @param deviceType Enum specifying device type
  53454. * @param deviceSlot "Slot" or index that device is referenced in
  53455. */
  53456. private _removeDevice;
  53457. /**
  53458. * Updates array storing first connected device of each type
  53459. * @param type Type of Device
  53460. */
  53461. private _updateFirstDevices;
  53462. }
  53463. }
  53464. declare module "babylonjs/DeviceInput/index" {
  53465. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53466. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53467. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53468. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53469. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53470. }
  53471. declare module "babylonjs/Engines/nullEngine" {
  53472. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53473. import { Engine } from "babylonjs/Engines/engine";
  53474. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53475. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53477. import { Effect } from "babylonjs/Materials/effect";
  53478. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53479. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53480. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53481. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53482. /**
  53483. * Options to create the null engine
  53484. */
  53485. export class NullEngineOptions {
  53486. /**
  53487. * Render width (Default: 512)
  53488. */
  53489. renderWidth: number;
  53490. /**
  53491. * Render height (Default: 256)
  53492. */
  53493. renderHeight: number;
  53494. /**
  53495. * Texture size (Default: 512)
  53496. */
  53497. textureSize: number;
  53498. /**
  53499. * If delta time between frames should be constant
  53500. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53501. */
  53502. deterministicLockstep: boolean;
  53503. /**
  53504. * Maximum about of steps between frames (Default: 4)
  53505. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53506. */
  53507. lockstepMaxSteps: number;
  53508. /**
  53509. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53510. */
  53511. useHighPrecisionMatrix?: boolean;
  53512. }
  53513. /**
  53514. * The null engine class provides support for headless version of babylon.js.
  53515. * This can be used in server side scenario or for testing purposes
  53516. */
  53517. export class NullEngine extends Engine {
  53518. private _options;
  53519. /**
  53520. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53521. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53522. * @returns true if engine is in deterministic lock step mode
  53523. */
  53524. isDeterministicLockStep(): boolean;
  53525. /**
  53526. * Gets the max steps when engine is running in deterministic lock step
  53527. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53528. * @returns the max steps
  53529. */
  53530. getLockstepMaxSteps(): number;
  53531. /**
  53532. * Gets the current hardware scaling level.
  53533. * By default the hardware scaling level is computed from the window device ratio.
  53534. * 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.
  53535. * @returns a number indicating the current hardware scaling level
  53536. */
  53537. getHardwareScalingLevel(): number;
  53538. constructor(options?: NullEngineOptions);
  53539. /**
  53540. * Creates a vertex buffer
  53541. * @param vertices the data for the vertex buffer
  53542. * @returns the new WebGL static buffer
  53543. */
  53544. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53545. /**
  53546. * Creates a new index buffer
  53547. * @param indices defines the content of the index buffer
  53548. * @param updatable defines if the index buffer must be updatable
  53549. * @returns a new webGL buffer
  53550. */
  53551. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53552. /**
  53553. * Clear the current render buffer or the current render target (if any is set up)
  53554. * @param color defines the color to use
  53555. * @param backBuffer defines if the back buffer must be cleared
  53556. * @param depth defines if the depth buffer must be cleared
  53557. * @param stencil defines if the stencil buffer must be cleared
  53558. */
  53559. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53560. /**
  53561. * Gets the current render width
  53562. * @param useScreen defines if screen size must be used (or the current render target if any)
  53563. * @returns a number defining the current render width
  53564. */
  53565. getRenderWidth(useScreen?: boolean): number;
  53566. /**
  53567. * Gets the current render height
  53568. * @param useScreen defines if screen size must be used (or the current render target if any)
  53569. * @returns a number defining the current render height
  53570. */
  53571. getRenderHeight(useScreen?: boolean): number;
  53572. /**
  53573. * Set the WebGL's viewport
  53574. * @param viewport defines the viewport element to be used
  53575. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53576. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53577. */
  53578. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53579. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53580. /**
  53581. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53582. * @param pipelineContext defines the pipeline context to use
  53583. * @param uniformsNames defines the list of uniform names
  53584. * @returns an array of webGL uniform locations
  53585. */
  53586. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53587. /**
  53588. * Gets the lsit of active attributes for a given webGL program
  53589. * @param pipelineContext defines the pipeline context to use
  53590. * @param attributesNames defines the list of attribute names to get
  53591. * @returns an array of indices indicating the offset of each attribute
  53592. */
  53593. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53594. /**
  53595. * Binds an effect to the webGL context
  53596. * @param effect defines the effect to bind
  53597. */
  53598. bindSamplers(effect: Effect): void;
  53599. /**
  53600. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53601. * @param effect defines the effect to activate
  53602. */
  53603. enableEffect(effect: Effect): void;
  53604. /**
  53605. * Set various states to the webGL context
  53606. * @param culling defines backface culling state
  53607. * @param zOffset defines the value to apply to zOffset (0 by default)
  53608. * @param force defines if states must be applied even if cache is up to date
  53609. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53610. */
  53611. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53612. /**
  53613. * Set the value of an uniform to an array of int32
  53614. * @param uniform defines the webGL uniform location where to store the value
  53615. * @param array defines the array of int32 to store
  53616. */
  53617. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53618. /**
  53619. * Set the value of an uniform to an array of int32 (stored as vec2)
  53620. * @param uniform defines the webGL uniform location where to store the value
  53621. * @param array defines the array of int32 to store
  53622. */
  53623. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53624. /**
  53625. * Set the value of an uniform to an array of int32 (stored as vec3)
  53626. * @param uniform defines the webGL uniform location where to store the value
  53627. * @param array defines the array of int32 to store
  53628. */
  53629. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53630. /**
  53631. * Set the value of an uniform to an array of int32 (stored as vec4)
  53632. * @param uniform defines the webGL uniform location where to store the value
  53633. * @param array defines the array of int32 to store
  53634. */
  53635. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53636. /**
  53637. * Set the value of an uniform to an array of float32
  53638. * @param uniform defines the webGL uniform location where to store the value
  53639. * @param array defines the array of float32 to store
  53640. */
  53641. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53642. /**
  53643. * Set the value of an uniform to an array of float32 (stored as vec2)
  53644. * @param uniform defines the webGL uniform location where to store the value
  53645. * @param array defines the array of float32 to store
  53646. */
  53647. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53648. /**
  53649. * Set the value of an uniform to an array of float32 (stored as vec3)
  53650. * @param uniform defines the webGL uniform location where to store the value
  53651. * @param array defines the array of float32 to store
  53652. */
  53653. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53654. /**
  53655. * Set the value of an uniform to an array of float32 (stored as vec4)
  53656. * @param uniform defines the webGL uniform location where to store the value
  53657. * @param array defines the array of float32 to store
  53658. */
  53659. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53660. /**
  53661. * Set the value of an uniform to an array of number
  53662. * @param uniform defines the webGL uniform location where to store the value
  53663. * @param array defines the array of number to store
  53664. */
  53665. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53666. /**
  53667. * Set the value of an uniform to an array of number (stored as vec2)
  53668. * @param uniform defines the webGL uniform location where to store the value
  53669. * @param array defines the array of number to store
  53670. */
  53671. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53672. /**
  53673. * Set the value of an uniform to an array of number (stored as vec3)
  53674. * @param uniform defines the webGL uniform location where to store the value
  53675. * @param array defines the array of number to store
  53676. */
  53677. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53678. /**
  53679. * Set the value of an uniform to an array of number (stored as vec4)
  53680. * @param uniform defines the webGL uniform location where to store the value
  53681. * @param array defines the array of number to store
  53682. */
  53683. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53684. /**
  53685. * Set the value of an uniform to an array of float32 (stored as matrices)
  53686. * @param uniform defines the webGL uniform location where to store the value
  53687. * @param matrices defines the array of float32 to store
  53688. */
  53689. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53690. /**
  53691. * Set the value of an uniform to a matrix (3x3)
  53692. * @param uniform defines the webGL uniform location where to store the value
  53693. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53694. */
  53695. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53696. /**
  53697. * Set the value of an uniform to a matrix (2x2)
  53698. * @param uniform defines the webGL uniform location where to store the value
  53699. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53700. */
  53701. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53702. /**
  53703. * Set the value of an uniform to a number (float)
  53704. * @param uniform defines the webGL uniform location where to store the value
  53705. * @param value defines the float number to store
  53706. */
  53707. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53708. /**
  53709. * Set the value of an uniform to a vec2
  53710. * @param uniform defines the webGL uniform location where to store the value
  53711. * @param x defines the 1st component of the value
  53712. * @param y defines the 2nd component of the value
  53713. */
  53714. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53715. /**
  53716. * Set the value of an uniform to a vec3
  53717. * @param uniform defines the webGL uniform location where to store the value
  53718. * @param x defines the 1st component of the value
  53719. * @param y defines the 2nd component of the value
  53720. * @param z defines the 3rd component of the value
  53721. */
  53722. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53723. /**
  53724. * Set the value of an uniform to a boolean
  53725. * @param uniform defines the webGL uniform location where to store the value
  53726. * @param bool defines the boolean to store
  53727. */
  53728. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53729. /**
  53730. * Set the value of an uniform to a vec4
  53731. * @param uniform defines the webGL uniform location where to store the value
  53732. * @param x defines the 1st component of the value
  53733. * @param y defines the 2nd component of the value
  53734. * @param z defines the 3rd component of the value
  53735. * @param w defines the 4th component of the value
  53736. */
  53737. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53738. /**
  53739. * Sets the current alpha mode
  53740. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53741. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53742. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53743. */
  53744. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53745. /**
  53746. * Bind webGl buffers directly to the webGL context
  53747. * @param vertexBuffers defines the vertex buffer to bind
  53748. * @param indexBuffer defines the index buffer to bind
  53749. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53750. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53751. * @param effect defines the effect associated with the vertex buffer
  53752. */
  53753. bindBuffers(vertexBuffers: {
  53754. [key: string]: VertexBuffer;
  53755. }, indexBuffer: DataBuffer, effect: Effect): void;
  53756. /**
  53757. * Force the entire cache to be cleared
  53758. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53759. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53760. */
  53761. wipeCaches(bruteForce?: boolean): void;
  53762. /**
  53763. * Send a draw order
  53764. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53765. * @param indexStart defines the starting index
  53766. * @param indexCount defines the number of index to draw
  53767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53768. */
  53769. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53770. /**
  53771. * Draw a list of indexed primitives
  53772. * @param fillMode defines the primitive to use
  53773. * @param indexStart defines the starting index
  53774. * @param indexCount defines the number of index to draw
  53775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53776. */
  53777. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53778. /**
  53779. * Draw a list of unindexed primitives
  53780. * @param fillMode defines the primitive to use
  53781. * @param verticesStart defines the index of first vertex to draw
  53782. * @param verticesCount defines the count of vertices to draw
  53783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53784. */
  53785. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53786. /** @hidden */
  53787. _createTexture(): WebGLTexture;
  53788. /** @hidden */
  53789. _releaseTexture(texture: InternalTexture): void;
  53790. /**
  53791. * Usually called from Texture.ts.
  53792. * Passed information to create a WebGLTexture
  53793. * @param urlArg defines a value which contains one of the following:
  53794. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53795. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53796. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53797. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53798. * @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)
  53799. * @param scene needed for loading to the correct scene
  53800. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53801. * @param onLoad optional callback to be called upon successful completion
  53802. * @param onError optional callback to be called upon failure
  53803. * @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
  53804. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53805. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53806. * @param forcedExtension defines the extension to use to pick the right loader
  53807. * @param mimeType defines an optional mime type
  53808. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53809. */
  53810. 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;
  53811. /**
  53812. * Creates a new render target texture
  53813. * @param size defines the size of the texture
  53814. * @param options defines the options used to create the texture
  53815. * @returns a new render target texture stored in an InternalTexture
  53816. */
  53817. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53818. /**
  53819. * Update the sampling mode of a given texture
  53820. * @param samplingMode defines the required sampling mode
  53821. * @param texture defines the texture to update
  53822. */
  53823. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53824. /**
  53825. * Binds the frame buffer to the specified texture.
  53826. * @param texture The texture to render to or null for the default canvas
  53827. * @param faceIndex The face of the texture to render to in case of cube texture
  53828. * @param requiredWidth The width of the target to render to
  53829. * @param requiredHeight The height of the target to render to
  53830. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  53831. * @param lodLevel defines le lod level to bind to the frame buffer
  53832. */
  53833. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53834. /**
  53835. * Unbind the current render target texture from the webGL context
  53836. * @param texture defines the render target texture to unbind
  53837. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53838. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53839. */
  53840. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53841. /**
  53842. * Creates a dynamic vertex buffer
  53843. * @param vertices the data for the dynamic vertex buffer
  53844. * @returns the new WebGL dynamic buffer
  53845. */
  53846. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  53847. /**
  53848. * Update the content of a dynamic texture
  53849. * @param texture defines the texture to update
  53850. * @param canvas defines the canvas containing the source
  53851. * @param invertY defines if data must be stored with Y axis inverted
  53852. * @param premulAlpha defines if alpha is stored as premultiplied
  53853. * @param format defines the format of the data
  53854. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53855. */
  53856. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53857. /**
  53858. * Gets a boolean indicating if all created effects are ready
  53859. * @returns true if all effects are ready
  53860. */
  53861. areAllEffectsReady(): boolean;
  53862. /**
  53863. * @hidden
  53864. * Get the current error code of the webGL context
  53865. * @returns the error code
  53866. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53867. */
  53868. getError(): number;
  53869. /** @hidden */
  53870. _getUnpackAlignement(): number;
  53871. /** @hidden */
  53872. _unpackFlipY(value: boolean): void;
  53873. /**
  53874. * Update a dynamic index buffer
  53875. * @param indexBuffer defines the target index buffer
  53876. * @param indices defines the data to update
  53877. * @param offset defines the offset in the target index buffer where update should start
  53878. */
  53879. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53880. /**
  53881. * Updates a dynamic vertex buffer.
  53882. * @param vertexBuffer the vertex buffer to update
  53883. * @param vertices the data used to update the vertex buffer
  53884. * @param byteOffset the byte offset of the data (optional)
  53885. * @param byteLength the byte length of the data (optional)
  53886. */
  53887. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  53888. /** @hidden */
  53889. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  53890. /** @hidden */
  53891. _bindTexture(channel: number, texture: InternalTexture): void;
  53892. protected _deleteBuffer(buffer: WebGLBuffer): void;
  53893. /**
  53894. * 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
  53895. */
  53896. releaseEffects(): void;
  53897. displayLoadingUI(): void;
  53898. hideLoadingUI(): void;
  53899. /** @hidden */
  53900. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53901. /** @hidden */
  53902. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53903. /** @hidden */
  53904. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53905. /** @hidden */
  53906. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53907. }
  53908. }
  53909. declare module "babylonjs/Instrumentation/timeToken" {
  53910. import { Nullable } from "babylonjs/types";
  53911. /**
  53912. * @hidden
  53913. **/
  53914. export class _TimeToken {
  53915. _startTimeQuery: Nullable<WebGLQuery>;
  53916. _endTimeQuery: Nullable<WebGLQuery>;
  53917. _timeElapsedQuery: Nullable<WebGLQuery>;
  53918. _timeElapsedQueryEnded: boolean;
  53919. }
  53920. }
  53921. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  53922. import { Nullable, int } from "babylonjs/types";
  53923. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  53924. /** @hidden */
  53925. export class _OcclusionDataStorage {
  53926. /** @hidden */
  53927. occlusionInternalRetryCounter: number;
  53928. /** @hidden */
  53929. isOcclusionQueryInProgress: boolean;
  53930. /** @hidden */
  53931. isOccluded: boolean;
  53932. /** @hidden */
  53933. occlusionRetryCount: number;
  53934. /** @hidden */
  53935. occlusionType: number;
  53936. /** @hidden */
  53937. occlusionQueryAlgorithmType: number;
  53938. }
  53939. module "babylonjs/Engines/engine" {
  53940. interface Engine {
  53941. /**
  53942. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53943. * @return the new query
  53944. */
  53945. createQuery(): WebGLQuery;
  53946. /**
  53947. * Delete and release a webGL query
  53948. * @param query defines the query to delete
  53949. * @return the current engine
  53950. */
  53951. deleteQuery(query: WebGLQuery): Engine;
  53952. /**
  53953. * Check if a given query has resolved and got its value
  53954. * @param query defines the query to check
  53955. * @returns true if the query got its value
  53956. */
  53957. isQueryResultAvailable(query: WebGLQuery): boolean;
  53958. /**
  53959. * Gets the value of a given query
  53960. * @param query defines the query to check
  53961. * @returns the value of the query
  53962. */
  53963. getQueryResult(query: WebGLQuery): number;
  53964. /**
  53965. * Initiates an occlusion query
  53966. * @param algorithmType defines the algorithm to use
  53967. * @param query defines the query to use
  53968. * @returns the current engine
  53969. * @see https://doc.babylonjs.com/features/occlusionquery
  53970. */
  53971. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53972. /**
  53973. * Ends an occlusion query
  53974. * @see https://doc.babylonjs.com/features/occlusionquery
  53975. * @param algorithmType defines the algorithm to use
  53976. * @returns the current engine
  53977. */
  53978. endOcclusionQuery(algorithmType: number): Engine;
  53979. /**
  53980. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53981. * Please note that only one query can be issued at a time
  53982. * @returns a time token used to track the time span
  53983. */
  53984. startTimeQuery(): Nullable<_TimeToken>;
  53985. /**
  53986. * Ends a time query
  53987. * @param token defines the token used to measure the time span
  53988. * @returns the time spent (in ns)
  53989. */
  53990. endTimeQuery(token: _TimeToken): int;
  53991. /** @hidden */
  53992. _currentNonTimestampToken: Nullable<_TimeToken>;
  53993. /** @hidden */
  53994. _createTimeQuery(): WebGLQuery;
  53995. /** @hidden */
  53996. _deleteTimeQuery(query: WebGLQuery): void;
  53997. /** @hidden */
  53998. _getGlAlgorithmType(algorithmType: number): number;
  53999. /** @hidden */
  54000. _getTimeQueryResult(query: WebGLQuery): any;
  54001. /** @hidden */
  54002. _getTimeQueryAvailability(query: WebGLQuery): any;
  54003. }
  54004. }
  54005. module "babylonjs/Meshes/abstractMesh" {
  54006. interface AbstractMesh {
  54007. /**
  54008. * Backing filed
  54009. * @hidden
  54010. */
  54011. __occlusionDataStorage: _OcclusionDataStorage;
  54012. /**
  54013. * Access property
  54014. * @hidden
  54015. */
  54016. _occlusionDataStorage: _OcclusionDataStorage;
  54017. /**
  54018. * 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.
  54019. * The default value is -1 which means don't break the query and wait till the result
  54020. * @see https://doc.babylonjs.com/features/occlusionquery
  54021. */
  54022. occlusionRetryCount: number;
  54023. /**
  54024. * 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:
  54025. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54026. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54027. * * 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.
  54028. * @see https://doc.babylonjs.com/features/occlusionquery
  54029. */
  54030. occlusionType: number;
  54031. /**
  54032. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54033. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54034. * * 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.
  54035. * @see https://doc.babylonjs.com/features/occlusionquery
  54036. */
  54037. occlusionQueryAlgorithmType: number;
  54038. /**
  54039. * 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
  54040. * @see https://doc.babylonjs.com/features/occlusionquery
  54041. */
  54042. isOccluded: boolean;
  54043. /**
  54044. * Flag to check the progress status of the query
  54045. * @see https://doc.babylonjs.com/features/occlusionquery
  54046. */
  54047. isOcclusionQueryInProgress: boolean;
  54048. }
  54049. }
  54050. }
  54051. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54052. import { Nullable } from "babylonjs/types";
  54053. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54054. /** @hidden */
  54055. export var _forceTransformFeedbackToBundle: boolean;
  54056. module "babylonjs/Engines/engine" {
  54057. interface Engine {
  54058. /**
  54059. * Creates a webGL transform feedback object
  54060. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54061. * @returns the webGL transform feedback object
  54062. */
  54063. createTransformFeedback(): WebGLTransformFeedback;
  54064. /**
  54065. * Delete a webGL transform feedback object
  54066. * @param value defines the webGL transform feedback object to delete
  54067. */
  54068. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54069. /**
  54070. * Bind a webGL transform feedback object to the webgl context
  54071. * @param value defines the webGL transform feedback object to bind
  54072. */
  54073. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54074. /**
  54075. * Begins a transform feedback operation
  54076. * @param usePoints defines if points or triangles must be used
  54077. */
  54078. beginTransformFeedback(usePoints: boolean): void;
  54079. /**
  54080. * Ends a transform feedback operation
  54081. */
  54082. endTransformFeedback(): void;
  54083. /**
  54084. * Specify the varyings to use with transform feedback
  54085. * @param program defines the associated webGL program
  54086. * @param value defines the list of strings representing the varying names
  54087. */
  54088. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54089. /**
  54090. * Bind a webGL buffer for a transform feedback operation
  54091. * @param value defines the webGL buffer to bind
  54092. */
  54093. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54094. }
  54095. }
  54096. }
  54097. declare module "babylonjs/Engines/Extensions/engine.views" {
  54098. import { Camera } from "babylonjs/Cameras/camera";
  54099. import { Nullable } from "babylonjs/types";
  54100. /**
  54101. * Class used to define an additional view for the engine
  54102. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54103. */
  54104. export class EngineView {
  54105. /** Defines the canvas where to render the view */
  54106. target: HTMLCanvasElement;
  54107. /** Defines an optional camera used to render the view (will use active camera else) */
  54108. camera?: Camera;
  54109. }
  54110. module "babylonjs/Engines/engine" {
  54111. interface Engine {
  54112. /**
  54113. * Gets or sets the HTML element to use for attaching events
  54114. */
  54115. inputElement: Nullable<HTMLElement>;
  54116. /**
  54117. * Gets the current engine view
  54118. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54119. */
  54120. activeView: Nullable<EngineView>;
  54121. /** Gets or sets the list of views */
  54122. views: EngineView[];
  54123. /**
  54124. * Register a new child canvas
  54125. * @param canvas defines the canvas to register
  54126. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54127. * @returns the associated view
  54128. */
  54129. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54130. /**
  54131. * Remove a registered child canvas
  54132. * @param canvas defines the canvas to remove
  54133. * @returns the current engine
  54134. */
  54135. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54136. }
  54137. }
  54138. }
  54139. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54140. import { Nullable } from "babylonjs/types";
  54141. module "babylonjs/Engines/engine" {
  54142. interface Engine {
  54143. /** @hidden */
  54144. _excludedCompressedTextures: string[];
  54145. /** @hidden */
  54146. _textureFormatInUse: string;
  54147. /**
  54148. * Gets the list of texture formats supported
  54149. */
  54150. readonly texturesSupported: Array<string>;
  54151. /**
  54152. * Gets the texture format in use
  54153. */
  54154. readonly textureFormatInUse: Nullable<string>;
  54155. /**
  54156. * Set the compressed texture extensions or file names to skip.
  54157. *
  54158. * @param skippedFiles defines the list of those texture files you want to skip
  54159. * Example: [".dds", ".env", "myfile.png"]
  54160. */
  54161. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54162. /**
  54163. * Set the compressed texture format to use, based on the formats you have, and the formats
  54164. * supported by the hardware / browser.
  54165. *
  54166. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54167. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54168. * to API arguments needed to compressed textures. This puts the burden on the container
  54169. * generator to house the arcane code for determining these for current & future formats.
  54170. *
  54171. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54172. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54173. *
  54174. * Note: The result of this call is not taken into account when a texture is base64.
  54175. *
  54176. * @param formatsAvailable defines the list of those format families you have created
  54177. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54178. *
  54179. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54180. * @returns The extension selected.
  54181. */
  54182. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54183. }
  54184. }
  54185. }
  54186. declare module "babylonjs/Engines/Extensions/index" {
  54187. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54188. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54189. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54190. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54191. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54192. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54193. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54194. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54195. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54196. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54197. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54198. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54199. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54200. export * from "babylonjs/Engines/Extensions/engine.views";
  54201. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54202. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54203. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54204. }
  54205. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54206. import { Nullable } from "babylonjs/types";
  54207. /**
  54208. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54209. */
  54210. export interface CubeMapInfo {
  54211. /**
  54212. * The pixel array for the front face.
  54213. * This is stored in format, left to right, up to down format.
  54214. */
  54215. front: Nullable<ArrayBufferView>;
  54216. /**
  54217. * The pixel array for the back face.
  54218. * This is stored in format, left to right, up to down format.
  54219. */
  54220. back: Nullable<ArrayBufferView>;
  54221. /**
  54222. * The pixel array for the left face.
  54223. * This is stored in format, left to right, up to down format.
  54224. */
  54225. left: Nullable<ArrayBufferView>;
  54226. /**
  54227. * The pixel array for the right face.
  54228. * This is stored in format, left to right, up to down format.
  54229. */
  54230. right: Nullable<ArrayBufferView>;
  54231. /**
  54232. * The pixel array for the up face.
  54233. * This is stored in format, left to right, up to down format.
  54234. */
  54235. up: Nullable<ArrayBufferView>;
  54236. /**
  54237. * The pixel array for the down face.
  54238. * This is stored in format, left to right, up to down format.
  54239. */
  54240. down: Nullable<ArrayBufferView>;
  54241. /**
  54242. * The size of the cubemap stored.
  54243. *
  54244. * Each faces will be size * size pixels.
  54245. */
  54246. size: number;
  54247. /**
  54248. * The format of the texture.
  54249. *
  54250. * RGBA, RGB.
  54251. */
  54252. format: number;
  54253. /**
  54254. * The type of the texture data.
  54255. *
  54256. * UNSIGNED_INT, FLOAT.
  54257. */
  54258. type: number;
  54259. /**
  54260. * Specifies whether the texture is in gamma space.
  54261. */
  54262. gammaSpace: boolean;
  54263. }
  54264. /**
  54265. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54266. */
  54267. export class PanoramaToCubeMapTools {
  54268. private static FACE_LEFT;
  54269. private static FACE_RIGHT;
  54270. private static FACE_FRONT;
  54271. private static FACE_BACK;
  54272. private static FACE_DOWN;
  54273. private static FACE_UP;
  54274. /**
  54275. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54276. *
  54277. * @param float32Array The source data.
  54278. * @param inputWidth The width of the input panorama.
  54279. * @param inputHeight The height of the input panorama.
  54280. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54281. * @return The cubemap data
  54282. */
  54283. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54284. private static CreateCubemapTexture;
  54285. private static CalcProjectionSpherical;
  54286. }
  54287. }
  54288. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54289. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54291. import { Nullable } from "babylonjs/types";
  54292. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54293. /**
  54294. * Helper class dealing with the extraction of spherical polynomial dataArray
  54295. * from a cube map.
  54296. */
  54297. export class CubeMapToSphericalPolynomialTools {
  54298. private static FileFaces;
  54299. /**
  54300. * Converts a texture to the according Spherical Polynomial data.
  54301. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54302. *
  54303. * @param texture The texture to extract the information from.
  54304. * @return The Spherical Polynomial data.
  54305. */
  54306. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54307. /**
  54308. * Converts a cubemap to the according Spherical Polynomial data.
  54309. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54310. *
  54311. * @param cubeInfo The Cube map to extract the information from.
  54312. * @return The Spherical Polynomial data.
  54313. */
  54314. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54315. }
  54316. }
  54317. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54318. import { Nullable } from "babylonjs/types";
  54319. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54320. module "babylonjs/Materials/Textures/baseTexture" {
  54321. interface BaseTexture {
  54322. /**
  54323. * Get the polynomial representation of the texture data.
  54324. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54325. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54326. */
  54327. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54328. }
  54329. }
  54330. }
  54331. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54333. /** @hidden */
  54334. export var rgbdEncodePixelShader: {
  54335. name: string;
  54336. shader: string;
  54337. };
  54338. }
  54339. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54340. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54341. /** @hidden */
  54342. export var rgbdDecodePixelShader: {
  54343. name: string;
  54344. shader: string;
  54345. };
  54346. }
  54347. declare module "babylonjs/Misc/environmentTextureTools" {
  54348. import { Nullable } from "babylonjs/types";
  54349. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54351. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54352. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54353. import "babylonjs/Engines/Extensions/engine.readTexture";
  54354. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54355. import "babylonjs/Shaders/rgbdEncode.fragment";
  54356. import "babylonjs/Shaders/rgbdDecode.fragment";
  54357. /**
  54358. * Raw texture data and descriptor sufficient for WebGL texture upload
  54359. */
  54360. export interface EnvironmentTextureInfo {
  54361. /**
  54362. * Version of the environment map
  54363. */
  54364. version: number;
  54365. /**
  54366. * Width of image
  54367. */
  54368. width: number;
  54369. /**
  54370. * Irradiance information stored in the file.
  54371. */
  54372. irradiance: any;
  54373. /**
  54374. * Specular information stored in the file.
  54375. */
  54376. specular: any;
  54377. }
  54378. /**
  54379. * Defines One Image in the file. It requires only the position in the file
  54380. * as well as the length.
  54381. */
  54382. interface BufferImageData {
  54383. /**
  54384. * Length of the image data.
  54385. */
  54386. length: number;
  54387. /**
  54388. * Position of the data from the null terminator delimiting the end of the JSON.
  54389. */
  54390. position: number;
  54391. }
  54392. /**
  54393. * Defines the specular data enclosed in the file.
  54394. * This corresponds to the version 1 of the data.
  54395. */
  54396. export interface EnvironmentTextureSpecularInfoV1 {
  54397. /**
  54398. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54399. */
  54400. specularDataPosition?: number;
  54401. /**
  54402. * This contains all the images data needed to reconstruct the cubemap.
  54403. */
  54404. mipmaps: Array<BufferImageData>;
  54405. /**
  54406. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54407. */
  54408. lodGenerationScale: number;
  54409. }
  54410. /**
  54411. * Sets of helpers addressing the serialization and deserialization of environment texture
  54412. * stored in a BabylonJS env file.
  54413. * Those files are usually stored as .env files.
  54414. */
  54415. export class EnvironmentTextureTools {
  54416. /**
  54417. * Magic number identifying the env file.
  54418. */
  54419. private static _MagicBytes;
  54420. /**
  54421. * Gets the environment info from an env file.
  54422. * @param data The array buffer containing the .env bytes.
  54423. * @returns the environment file info (the json header) if successfully parsed.
  54424. */
  54425. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54426. /**
  54427. * Creates an environment texture from a loaded cube texture.
  54428. * @param texture defines the cube texture to convert in env file
  54429. * @return a promise containing the environment data if succesfull.
  54430. */
  54431. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54432. /**
  54433. * Creates a JSON representation of the spherical data.
  54434. * @param texture defines the texture containing the polynomials
  54435. * @return the JSON representation of the spherical info
  54436. */
  54437. private static _CreateEnvTextureIrradiance;
  54438. /**
  54439. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54440. * @param data the image data
  54441. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54442. * @return the views described by info providing access to the underlying buffer
  54443. */
  54444. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54445. /**
  54446. * Uploads the texture info contained in the env file to the GPU.
  54447. * @param texture defines the internal texture to upload to
  54448. * @param data defines the data to load
  54449. * @param info defines the texture info retrieved through the GetEnvInfo method
  54450. * @returns a promise
  54451. */
  54452. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54453. private static _OnImageReadyAsync;
  54454. /**
  54455. * Uploads the levels of image data to the GPU.
  54456. * @param texture defines the internal texture to upload to
  54457. * @param imageData defines the array buffer views of image data [mipmap][face]
  54458. * @returns a promise
  54459. */
  54460. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54461. /**
  54462. * Uploads spherical polynomials information to the texture.
  54463. * @param texture defines the texture we are trying to upload the information to
  54464. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54465. */
  54466. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54467. /** @hidden */
  54468. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54469. }
  54470. }
  54471. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54472. /**
  54473. * Class used to inline functions in shader code
  54474. */
  54475. export class ShaderCodeInliner {
  54476. private static readonly _RegexpFindFunctionNameAndType;
  54477. private _sourceCode;
  54478. private _functionDescr;
  54479. private _numMaxIterations;
  54480. /** Gets or sets the token used to mark the functions to inline */
  54481. inlineToken: string;
  54482. /** Gets or sets the debug mode */
  54483. debug: boolean;
  54484. /** Gets the code after the inlining process */
  54485. get code(): string;
  54486. /**
  54487. * Initializes the inliner
  54488. * @param sourceCode shader code source to inline
  54489. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54490. */
  54491. constructor(sourceCode: string, numMaxIterations?: number);
  54492. /**
  54493. * Start the processing of the shader code
  54494. */
  54495. processCode(): void;
  54496. private _collectFunctions;
  54497. private _processInlining;
  54498. private _extractBetweenMarkers;
  54499. private _skipWhitespaces;
  54500. private _removeComments;
  54501. private _replaceFunctionCallsByCode;
  54502. private _findBackward;
  54503. private _escapeRegExp;
  54504. private _replaceNames;
  54505. }
  54506. }
  54507. declare module "babylonjs/Engines/nativeEngine" {
  54508. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54509. import { Engine } from "babylonjs/Engines/engine";
  54510. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54511. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54512. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54513. import { Effect } from "babylonjs/Materials/effect";
  54514. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54515. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54516. import { IColor4Like } from "babylonjs/Maths/math.like";
  54517. import { Scene } from "babylonjs/scene";
  54518. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54519. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54520. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54521. /**
  54522. * Container for accessors for natively-stored mesh data buffers.
  54523. */
  54524. class NativeDataBuffer extends DataBuffer {
  54525. /**
  54526. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54527. */
  54528. nativeIndexBuffer?: any;
  54529. /**
  54530. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54531. */
  54532. nativeVertexBuffer?: any;
  54533. }
  54534. /** @hidden */
  54535. class NativeTexture extends InternalTexture {
  54536. getInternalTexture(): InternalTexture;
  54537. getViewCount(): number;
  54538. }
  54539. /** @hidden */
  54540. export class NativeEngine extends Engine {
  54541. private readonly _native;
  54542. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54543. private readonly INVALID_HANDLE;
  54544. getHardwareScalingLevel(): number;
  54545. constructor();
  54546. dispose(): void;
  54547. /**
  54548. * Can be used to override the current requestAnimationFrame requester.
  54549. * @hidden
  54550. */
  54551. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54552. /**
  54553. * Override default engine behavior.
  54554. * @param color
  54555. * @param backBuffer
  54556. * @param depth
  54557. * @param stencil
  54558. */
  54559. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54560. /**
  54561. * Gets host document
  54562. * @returns the host document object
  54563. */
  54564. getHostDocument(): Nullable<Document>;
  54565. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54566. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54567. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54568. bindBuffers(vertexBuffers: {
  54569. [key: string]: VertexBuffer;
  54570. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54571. recordVertexArrayObject(vertexBuffers: {
  54572. [key: string]: VertexBuffer;
  54573. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54574. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54575. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54576. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54577. /**
  54578. * Draw a list of indexed primitives
  54579. * @param fillMode defines the primitive to use
  54580. * @param indexStart defines the starting index
  54581. * @param indexCount defines the number of index to draw
  54582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54583. */
  54584. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54585. /**
  54586. * Draw a list of unindexed primitives
  54587. * @param fillMode defines the primitive to use
  54588. * @param verticesStart defines the index of first vertex to draw
  54589. * @param verticesCount defines the count of vertices to draw
  54590. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54591. */
  54592. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54593. createPipelineContext(): IPipelineContext;
  54594. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54595. /** @hidden */
  54596. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54597. /** @hidden */
  54598. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54599. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54600. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54601. protected _setProgram(program: WebGLProgram): void;
  54602. _releaseEffect(effect: Effect): void;
  54603. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54604. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54605. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54606. bindSamplers(effect: Effect): void;
  54607. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54608. getRenderWidth(useScreen?: boolean): number;
  54609. getRenderHeight(useScreen?: boolean): number;
  54610. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54611. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54612. /**
  54613. * Set the z offset to apply to current rendering
  54614. * @param value defines the offset to apply
  54615. */
  54616. setZOffset(value: number): void;
  54617. /**
  54618. * Gets the current value of the zOffset
  54619. * @returns the current zOffset state
  54620. */
  54621. getZOffset(): number;
  54622. /**
  54623. * Enable or disable depth buffering
  54624. * @param enable defines the state to set
  54625. */
  54626. setDepthBuffer(enable: boolean): void;
  54627. /**
  54628. * Gets a boolean indicating if depth writing is enabled
  54629. * @returns the current depth writing state
  54630. */
  54631. getDepthWrite(): boolean;
  54632. /**
  54633. * Enable or disable depth writing
  54634. * @param enable defines the state to set
  54635. */
  54636. setDepthWrite(enable: boolean): void;
  54637. /**
  54638. * Enable or disable color writing
  54639. * @param enable defines the state to set
  54640. */
  54641. setColorWrite(enable: boolean): void;
  54642. /**
  54643. * Gets a boolean indicating if color writing is enabled
  54644. * @returns the current color writing state
  54645. */
  54646. getColorWrite(): boolean;
  54647. /**
  54648. * Sets alpha constants used by some alpha blending modes
  54649. * @param r defines the red component
  54650. * @param g defines the green component
  54651. * @param b defines the blue component
  54652. * @param a defines the alpha component
  54653. */
  54654. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54655. /**
  54656. * Sets the current alpha mode
  54657. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54658. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54659. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54660. */
  54661. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54662. /**
  54663. * Gets the current alpha mode
  54664. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54665. * @returns the current alpha mode
  54666. */
  54667. getAlphaMode(): number;
  54668. setInt(uniform: WebGLUniformLocation, int: number): void;
  54669. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54670. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54671. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54672. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54673. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54674. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54675. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54676. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54677. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54678. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54679. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54680. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54681. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54682. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54683. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54684. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54685. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54686. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54687. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54688. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54689. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54690. wipeCaches(bruteForce?: boolean): void;
  54691. _createTexture(): WebGLTexture;
  54692. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54693. /**
  54694. * Usually called from Texture.ts.
  54695. * Passed information to create a WebGLTexture
  54696. * @param url defines a value which contains one of the following:
  54697. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54698. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54699. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54701. * @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)
  54702. * @param scene needed for loading to the correct scene
  54703. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54704. * @param onLoad optional callback to be called upon successful completion
  54705. * @param onError optional callback to be called upon failure
  54706. * @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
  54707. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54708. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54709. * @param forcedExtension defines the extension to use to pick the right loader
  54710. * @param mimeType defines an optional mime type
  54711. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54712. */
  54713. 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;
  54714. /**
  54715. * Creates a cube texture
  54716. * @param rootUrl defines the url where the files to load is located
  54717. * @param scene defines the current scene
  54718. * @param files defines the list of files to load (1 per face)
  54719. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54720. * @param onLoad defines an optional callback raised when the texture is loaded
  54721. * @param onError defines an optional callback raised if there is an issue to load the texture
  54722. * @param format defines the format of the data
  54723. * @param forcedExtension defines the extension to use to pick the right loader
  54724. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54725. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54726. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54727. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54728. * @returns the cube texture as an InternalTexture
  54729. */
  54730. 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;
  54731. private _getSamplingFilter;
  54732. private static _GetNativeTextureFormat;
  54733. createRenderTargetTexture(size: number | {
  54734. width: number;
  54735. height: number;
  54736. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54737. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54738. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54739. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54740. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54741. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54742. /**
  54743. * Updates a dynamic vertex buffer.
  54744. * @param vertexBuffer the vertex buffer to update
  54745. * @param data the data used to update the vertex buffer
  54746. * @param byteOffset the byte offset of the data (optional)
  54747. * @param byteLength the byte length of the data (optional)
  54748. */
  54749. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54750. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54751. private _updateAnisotropicLevel;
  54752. private _getAddressMode;
  54753. /** @hidden */
  54754. _bindTexture(channel: number, texture: InternalTexture): void;
  54755. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54756. releaseEffects(): void;
  54757. /** @hidden */
  54758. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54759. /** @hidden */
  54760. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54761. /** @hidden */
  54762. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54763. /** @hidden */
  54764. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54765. }
  54766. }
  54767. declare module "babylonjs/Engines/index" {
  54768. export * from "babylonjs/Engines/constants";
  54769. export * from "babylonjs/Engines/engineCapabilities";
  54770. export * from "babylonjs/Engines/instancingAttributeInfo";
  54771. export * from "babylonjs/Engines/thinEngine";
  54772. export * from "babylonjs/Engines/engine";
  54773. export * from "babylonjs/Engines/engineStore";
  54774. export * from "babylonjs/Engines/nullEngine";
  54775. export * from "babylonjs/Engines/Extensions/index";
  54776. export * from "babylonjs/Engines/IPipelineContext";
  54777. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54778. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54779. export * from "babylonjs/Engines/nativeEngine";
  54780. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54781. export * from "babylonjs/Engines/performanceConfigurator";
  54782. }
  54783. declare module "babylonjs/Events/clipboardEvents" {
  54784. /**
  54785. * Gather the list of clipboard event types as constants.
  54786. */
  54787. export class ClipboardEventTypes {
  54788. /**
  54789. * The clipboard event is fired when a copy command is active (pressed).
  54790. */
  54791. static readonly COPY: number;
  54792. /**
  54793. * The clipboard event is fired when a cut command is active (pressed).
  54794. */
  54795. static readonly CUT: number;
  54796. /**
  54797. * The clipboard event is fired when a paste command is active (pressed).
  54798. */
  54799. static readonly PASTE: number;
  54800. }
  54801. /**
  54802. * This class is used to store clipboard related info for the onClipboardObservable event.
  54803. */
  54804. export class ClipboardInfo {
  54805. /**
  54806. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54807. */
  54808. type: number;
  54809. /**
  54810. * Defines the related dom event
  54811. */
  54812. event: ClipboardEvent;
  54813. /**
  54814. *Creates an instance of ClipboardInfo.
  54815. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54816. * @param event Defines the related dom event
  54817. */
  54818. constructor(
  54819. /**
  54820. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54821. */
  54822. type: number,
  54823. /**
  54824. * Defines the related dom event
  54825. */
  54826. event: ClipboardEvent);
  54827. /**
  54828. * Get the clipboard event's type from the keycode.
  54829. * @param keyCode Defines the keyCode for the current keyboard event.
  54830. * @return {number}
  54831. */
  54832. static GetTypeFromCharacter(keyCode: number): number;
  54833. }
  54834. }
  54835. declare module "babylonjs/Events/index" {
  54836. export * from "babylonjs/Events/keyboardEvents";
  54837. export * from "babylonjs/Events/pointerEvents";
  54838. export * from "babylonjs/Events/clipboardEvents";
  54839. }
  54840. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54841. import { Scene } from "babylonjs/scene";
  54842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54843. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54844. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54845. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54846. /**
  54847. * Google Daydream controller
  54848. */
  54849. export class DaydreamController extends WebVRController {
  54850. /**
  54851. * Base Url for the controller model.
  54852. */
  54853. static MODEL_BASE_URL: string;
  54854. /**
  54855. * File name for the controller model.
  54856. */
  54857. static MODEL_FILENAME: string;
  54858. /**
  54859. * Gamepad Id prefix used to identify Daydream Controller.
  54860. */
  54861. static readonly GAMEPAD_ID_PREFIX: string;
  54862. /**
  54863. * Creates a new DaydreamController from a gamepad
  54864. * @param vrGamepad the gamepad that the controller should be created from
  54865. */
  54866. constructor(vrGamepad: any);
  54867. /**
  54868. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54869. * @param scene scene in which to add meshes
  54870. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54871. */
  54872. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54873. /**
  54874. * Called once for each button that changed state since the last frame
  54875. * @param buttonIdx Which button index changed
  54876. * @param state New state of the button
  54877. * @param changes Which properties on the state changed since last frame
  54878. */
  54879. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54880. }
  54881. }
  54882. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54883. import { Scene } from "babylonjs/scene";
  54884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54885. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54886. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54887. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54888. /**
  54889. * Gear VR Controller
  54890. */
  54891. export class GearVRController extends WebVRController {
  54892. /**
  54893. * Base Url for the controller model.
  54894. */
  54895. static MODEL_BASE_URL: string;
  54896. /**
  54897. * File name for the controller model.
  54898. */
  54899. static MODEL_FILENAME: string;
  54900. /**
  54901. * Gamepad Id prefix used to identify this controller.
  54902. */
  54903. static readonly GAMEPAD_ID_PREFIX: string;
  54904. private readonly _buttonIndexToObservableNameMap;
  54905. /**
  54906. * Creates a new GearVRController from a gamepad
  54907. * @param vrGamepad the gamepad that the controller should be created from
  54908. */
  54909. constructor(vrGamepad: any);
  54910. /**
  54911. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54912. * @param scene scene in which to add meshes
  54913. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54914. */
  54915. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54916. /**
  54917. * Called once for each button that changed state since the last frame
  54918. * @param buttonIdx Which button index changed
  54919. * @param state New state of the button
  54920. * @param changes Which properties on the state changed since last frame
  54921. */
  54922. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54923. }
  54924. }
  54925. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54926. import { Scene } from "babylonjs/scene";
  54927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54928. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54929. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54930. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54931. /**
  54932. * Generic Controller
  54933. */
  54934. export class GenericController extends WebVRController {
  54935. /**
  54936. * Base Url for the controller model.
  54937. */
  54938. static readonly MODEL_BASE_URL: string;
  54939. /**
  54940. * File name for the controller model.
  54941. */
  54942. static readonly MODEL_FILENAME: string;
  54943. /**
  54944. * Creates a new GenericController from a gamepad
  54945. * @param vrGamepad the gamepad that the controller should be created from
  54946. */
  54947. constructor(vrGamepad: any);
  54948. /**
  54949. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54950. * @param scene scene in which to add meshes
  54951. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54952. */
  54953. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54954. /**
  54955. * Called once for each button that changed state since the last frame
  54956. * @param buttonIdx Which button index changed
  54957. * @param state New state of the button
  54958. * @param changes Which properties on the state changed since last frame
  54959. */
  54960. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54961. }
  54962. }
  54963. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54964. import { Observable } from "babylonjs/Misc/observable";
  54965. import { Scene } from "babylonjs/scene";
  54966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54967. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54968. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54969. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54970. /**
  54971. * Oculus Touch Controller
  54972. */
  54973. export class OculusTouchController extends WebVRController {
  54974. /**
  54975. * Base Url for the controller model.
  54976. */
  54977. static MODEL_BASE_URL: string;
  54978. /**
  54979. * File name for the left controller model.
  54980. */
  54981. static MODEL_LEFT_FILENAME: string;
  54982. /**
  54983. * File name for the right controller model.
  54984. */
  54985. static MODEL_RIGHT_FILENAME: string;
  54986. /**
  54987. * Base Url for the Quest controller model.
  54988. */
  54989. static QUEST_MODEL_BASE_URL: string;
  54990. /**
  54991. * @hidden
  54992. * If the controllers are running on a device that needs the updated Quest controller models
  54993. */
  54994. static _IsQuest: boolean;
  54995. /**
  54996. * Fired when the secondary trigger on this controller is modified
  54997. */
  54998. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54999. /**
  55000. * Fired when the thumb rest on this controller is modified
  55001. */
  55002. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55003. /**
  55004. * Creates a new OculusTouchController from a gamepad
  55005. * @param vrGamepad the gamepad that the controller should be created from
  55006. */
  55007. constructor(vrGamepad: any);
  55008. /**
  55009. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55010. * @param scene scene in which to add meshes
  55011. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55012. */
  55013. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55014. /**
  55015. * Fired when the A button on this controller is modified
  55016. */
  55017. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55018. /**
  55019. * Fired when the B button on this controller is modified
  55020. */
  55021. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55022. /**
  55023. * Fired when the X button on this controller is modified
  55024. */
  55025. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55026. /**
  55027. * Fired when the Y button on this controller is modified
  55028. */
  55029. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55030. /**
  55031. * Called once for each button that changed state since the last frame
  55032. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55033. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55034. * 2) secondary trigger (same)
  55035. * 3) A (right) X (left), touch, pressed = value
  55036. * 4) B / Y
  55037. * 5) thumb rest
  55038. * @param buttonIdx Which button index changed
  55039. * @param state New state of the button
  55040. * @param changes Which properties on the state changed since last frame
  55041. */
  55042. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55043. }
  55044. }
  55045. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55046. import { Scene } from "babylonjs/scene";
  55047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55048. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55049. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55050. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55051. import { Observable } from "babylonjs/Misc/observable";
  55052. /**
  55053. * Vive Controller
  55054. */
  55055. export class ViveController extends WebVRController {
  55056. /**
  55057. * Base Url for the controller model.
  55058. */
  55059. static MODEL_BASE_URL: string;
  55060. /**
  55061. * File name for the controller model.
  55062. */
  55063. static MODEL_FILENAME: string;
  55064. /**
  55065. * Creates a new ViveController from a gamepad
  55066. * @param vrGamepad the gamepad that the controller should be created from
  55067. */
  55068. constructor(vrGamepad: any);
  55069. /**
  55070. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55071. * @param scene scene in which to add meshes
  55072. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55073. */
  55074. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55075. /**
  55076. * Fired when the left button on this controller is modified
  55077. */
  55078. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55079. /**
  55080. * Fired when the right button on this controller is modified
  55081. */
  55082. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55083. /**
  55084. * Fired when the menu button on this controller is modified
  55085. */
  55086. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55087. /**
  55088. * Called once for each button that changed state since the last frame
  55089. * Vive mapping:
  55090. * 0: touchpad
  55091. * 1: trigger
  55092. * 2: left AND right buttons
  55093. * 3: menu button
  55094. * @param buttonIdx Which button index changed
  55095. * @param state New state of the button
  55096. * @param changes Which properties on the state changed since last frame
  55097. */
  55098. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55099. }
  55100. }
  55101. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55102. import { Observable } from "babylonjs/Misc/observable";
  55103. import { Scene } from "babylonjs/scene";
  55104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55105. import { Ray } from "babylonjs/Culling/ray";
  55106. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55107. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55108. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55109. /**
  55110. * Defines the WindowsMotionController object that the state of the windows motion controller
  55111. */
  55112. export class WindowsMotionController extends WebVRController {
  55113. /**
  55114. * The base url used to load the left and right controller models
  55115. */
  55116. static MODEL_BASE_URL: string;
  55117. /**
  55118. * The name of the left controller model file
  55119. */
  55120. static MODEL_LEFT_FILENAME: string;
  55121. /**
  55122. * The name of the right controller model file
  55123. */
  55124. static MODEL_RIGHT_FILENAME: string;
  55125. /**
  55126. * The controller name prefix for this controller type
  55127. */
  55128. static readonly GAMEPAD_ID_PREFIX: string;
  55129. /**
  55130. * The controller id pattern for this controller type
  55131. */
  55132. private static readonly GAMEPAD_ID_PATTERN;
  55133. private _loadedMeshInfo;
  55134. protected readonly _mapping: {
  55135. buttons: string[];
  55136. buttonMeshNames: {
  55137. trigger: string;
  55138. menu: string;
  55139. grip: string;
  55140. thumbstick: string;
  55141. trackpad: string;
  55142. };
  55143. buttonObservableNames: {
  55144. trigger: string;
  55145. menu: string;
  55146. grip: string;
  55147. thumbstick: string;
  55148. trackpad: string;
  55149. };
  55150. axisMeshNames: string[];
  55151. pointingPoseMeshName: string;
  55152. };
  55153. /**
  55154. * Fired when the trackpad on this controller is clicked
  55155. */
  55156. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55157. /**
  55158. * Fired when the trackpad on this controller is modified
  55159. */
  55160. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55161. /**
  55162. * The current x and y values of this controller's trackpad
  55163. */
  55164. trackpad: StickValues;
  55165. /**
  55166. * Creates a new WindowsMotionController from a gamepad
  55167. * @param vrGamepad the gamepad that the controller should be created from
  55168. */
  55169. constructor(vrGamepad: any);
  55170. /**
  55171. * Fired when the trigger on this controller is modified
  55172. */
  55173. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55174. /**
  55175. * Fired when the menu button on this controller is modified
  55176. */
  55177. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55178. /**
  55179. * Fired when the grip button on this controller is modified
  55180. */
  55181. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55182. /**
  55183. * Fired when the thumbstick button on this controller is modified
  55184. */
  55185. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55186. /**
  55187. * Fired when the touchpad button on this controller is modified
  55188. */
  55189. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55190. /**
  55191. * Fired when the touchpad values on this controller are modified
  55192. */
  55193. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55194. protected _updateTrackpad(): void;
  55195. /**
  55196. * Called once per frame by the engine.
  55197. */
  55198. update(): void;
  55199. /**
  55200. * Called once for each button that changed state since the last frame
  55201. * @param buttonIdx Which button index changed
  55202. * @param state New state of the button
  55203. * @param changes Which properties on the state changed since last frame
  55204. */
  55205. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55206. /**
  55207. * Moves the buttons on the controller mesh based on their current state
  55208. * @param buttonName the name of the button to move
  55209. * @param buttonValue the value of the button which determines the buttons new position
  55210. */
  55211. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55212. /**
  55213. * Moves the axis on the controller mesh based on its current state
  55214. * @param axis the index of the axis
  55215. * @param axisValue the value of the axis which determines the meshes new position
  55216. * @hidden
  55217. */
  55218. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55219. /**
  55220. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55221. * @param scene scene in which to add meshes
  55222. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55223. */
  55224. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55225. /**
  55226. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55227. * can be transformed by button presses and axes values, based on this._mapping.
  55228. *
  55229. * @param scene scene in which the meshes exist
  55230. * @param meshes list of meshes that make up the controller model to process
  55231. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55232. */
  55233. private processModel;
  55234. private createMeshInfo;
  55235. /**
  55236. * Gets the ray of the controller in the direction the controller is pointing
  55237. * @param length the length the resulting ray should be
  55238. * @returns a ray in the direction the controller is pointing
  55239. */
  55240. getForwardRay(length?: number): Ray;
  55241. /**
  55242. * Disposes of the controller
  55243. */
  55244. dispose(): void;
  55245. }
  55246. /**
  55247. * This class represents a new windows motion controller in XR.
  55248. */
  55249. export class XRWindowsMotionController extends WindowsMotionController {
  55250. /**
  55251. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55252. */
  55253. protected readonly _mapping: {
  55254. buttons: string[];
  55255. buttonMeshNames: {
  55256. trigger: string;
  55257. menu: string;
  55258. grip: string;
  55259. thumbstick: string;
  55260. trackpad: string;
  55261. };
  55262. buttonObservableNames: {
  55263. trigger: string;
  55264. menu: string;
  55265. grip: string;
  55266. thumbstick: string;
  55267. trackpad: string;
  55268. };
  55269. axisMeshNames: string[];
  55270. pointingPoseMeshName: string;
  55271. };
  55272. /**
  55273. * Construct a new XR-Based windows motion controller
  55274. *
  55275. * @param gamepadInfo the gamepad object from the browser
  55276. */
  55277. constructor(gamepadInfo: any);
  55278. /**
  55279. * holds the thumbstick values (X,Y)
  55280. */
  55281. thumbstickValues: StickValues;
  55282. /**
  55283. * Fired when the thumbstick on this controller is clicked
  55284. */
  55285. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55286. /**
  55287. * Fired when the thumbstick on this controller is modified
  55288. */
  55289. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55290. /**
  55291. * Fired when the touchpad button on this controller is modified
  55292. */
  55293. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55294. /**
  55295. * Fired when the touchpad values on this controller are modified
  55296. */
  55297. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55298. /**
  55299. * Fired when the thumbstick button on this controller is modified
  55300. * here to prevent breaking changes
  55301. */
  55302. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55303. /**
  55304. * updating the thumbstick(!) and not the trackpad.
  55305. * This is named this way due to the difference between WebVR and XR and to avoid
  55306. * changing the parent class.
  55307. */
  55308. protected _updateTrackpad(): void;
  55309. /**
  55310. * Disposes the class with joy
  55311. */
  55312. dispose(): void;
  55313. }
  55314. }
  55315. declare module "babylonjs/Gamepads/Controllers/index" {
  55316. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55317. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55318. export * from "babylonjs/Gamepads/Controllers/genericController";
  55319. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55320. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55321. export * from "babylonjs/Gamepads/Controllers/viveController";
  55322. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55323. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55324. }
  55325. declare module "babylonjs/Gamepads/index" {
  55326. export * from "babylonjs/Gamepads/Controllers/index";
  55327. export * from "babylonjs/Gamepads/gamepad";
  55328. export * from "babylonjs/Gamepads/gamepadManager";
  55329. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55330. export * from "babylonjs/Gamepads/xboxGamepad";
  55331. export * from "babylonjs/Gamepads/dualShockGamepad";
  55332. }
  55333. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55334. import { Scene } from "babylonjs/scene";
  55335. import { Vector4 } from "babylonjs/Maths/math.vector";
  55336. import { Color4 } from "babylonjs/Maths/math.color";
  55337. import { Mesh } from "babylonjs/Meshes/mesh";
  55338. import { Nullable } from "babylonjs/types";
  55339. /**
  55340. * Class containing static functions to help procedurally build meshes
  55341. */
  55342. export class PolyhedronBuilder {
  55343. /**
  55344. * Creates a polyhedron mesh
  55345. * * 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
  55346. * * The parameter `size` (positive float, default 1) sets the polygon size
  55347. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55348. * * 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`
  55349. * * 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
  55350. * * 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)`)
  55351. * * 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
  55352. * * 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
  55353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55356. * @param name defines the name of the mesh
  55357. * @param options defines the options used to create the mesh
  55358. * @param scene defines the hosting scene
  55359. * @returns the polyhedron mesh
  55360. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55361. */
  55362. static CreatePolyhedron(name: string, options: {
  55363. type?: number;
  55364. size?: number;
  55365. sizeX?: number;
  55366. sizeY?: number;
  55367. sizeZ?: number;
  55368. custom?: any;
  55369. faceUV?: Vector4[];
  55370. faceColors?: Color4[];
  55371. flat?: boolean;
  55372. updatable?: boolean;
  55373. sideOrientation?: number;
  55374. frontUVs?: Vector4;
  55375. backUVs?: Vector4;
  55376. }, scene?: Nullable<Scene>): Mesh;
  55377. }
  55378. }
  55379. declare module "babylonjs/Gizmos/scaleGizmo" {
  55380. import { Observable } from "babylonjs/Misc/observable";
  55381. import { Nullable } from "babylonjs/types";
  55382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55383. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55384. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55385. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55386. import { Node } from "babylonjs/node";
  55387. /**
  55388. * Gizmo that enables scaling a mesh along 3 axis
  55389. */
  55390. export class ScaleGizmo extends Gizmo {
  55391. /**
  55392. * Internal gizmo used for interactions on the x axis
  55393. */
  55394. xGizmo: AxisScaleGizmo;
  55395. /**
  55396. * Internal gizmo used for interactions on the y axis
  55397. */
  55398. yGizmo: AxisScaleGizmo;
  55399. /**
  55400. * Internal gizmo used for interactions on the z axis
  55401. */
  55402. zGizmo: AxisScaleGizmo;
  55403. /**
  55404. * Internal gizmo used to scale all axis equally
  55405. */
  55406. uniformScaleGizmo: AxisScaleGizmo;
  55407. private _meshAttached;
  55408. private _nodeAttached;
  55409. private _updateGizmoRotationToMatchAttachedMesh;
  55410. private _snapDistance;
  55411. private _scaleRatio;
  55412. private _uniformScalingMesh;
  55413. private _octahedron;
  55414. private _sensitivity;
  55415. /** Fires an event when any of it's sub gizmos are dragged */
  55416. onDragStartObservable: Observable<unknown>;
  55417. /** Fires an event when any of it's sub gizmos are released from dragging */
  55418. onDragEndObservable: Observable<unknown>;
  55419. get attachedMesh(): Nullable<AbstractMesh>;
  55420. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55421. get attachedNode(): Nullable<Node>;
  55422. set attachedNode(node: Nullable<Node>);
  55423. /**
  55424. * Creates a ScaleGizmo
  55425. * @param gizmoLayer The utility layer the gizmo will be added to
  55426. * @param thickness display gizmo axis thickness
  55427. */
  55428. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55429. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55430. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55431. /**
  55432. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55433. */
  55434. set snapDistance(value: number);
  55435. get snapDistance(): number;
  55436. /**
  55437. * Ratio for the scale of the gizmo (Default: 1)
  55438. */
  55439. set scaleRatio(value: number);
  55440. get scaleRatio(): number;
  55441. /**
  55442. * Sensitivity factor for dragging (Default: 1)
  55443. */
  55444. set sensitivity(value: number);
  55445. get sensitivity(): number;
  55446. /**
  55447. * Disposes of the gizmo
  55448. */
  55449. dispose(): void;
  55450. }
  55451. }
  55452. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55453. import { Observable } from "babylonjs/Misc/observable";
  55454. import { Nullable } from "babylonjs/types";
  55455. import { Vector3 } from "babylonjs/Maths/math.vector";
  55456. import { Node } from "babylonjs/node";
  55457. import { Mesh } from "babylonjs/Meshes/mesh";
  55458. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55459. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55460. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55461. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55462. import { Color3 } from "babylonjs/Maths/math.color";
  55463. /**
  55464. * Single axis scale gizmo
  55465. */
  55466. export class AxisScaleGizmo extends Gizmo {
  55467. /**
  55468. * Drag behavior responsible for the gizmos dragging interactions
  55469. */
  55470. dragBehavior: PointerDragBehavior;
  55471. private _pointerObserver;
  55472. /**
  55473. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55474. */
  55475. snapDistance: number;
  55476. /**
  55477. * Event that fires each time the gizmo snaps to a new location.
  55478. * * snapDistance is the the change in distance
  55479. */
  55480. onSnapObservable: Observable<{
  55481. snapDistance: number;
  55482. }>;
  55483. /**
  55484. * If the scaling operation should be done on all axis (default: false)
  55485. */
  55486. uniformScaling: boolean;
  55487. /**
  55488. * Custom sensitivity value for the drag strength
  55489. */
  55490. sensitivity: number;
  55491. private _isEnabled;
  55492. private _parent;
  55493. private _arrow;
  55494. private _coloredMaterial;
  55495. private _hoverMaterial;
  55496. /**
  55497. * Creates an AxisScaleGizmo
  55498. * @param gizmoLayer The utility layer the gizmo will be added to
  55499. * @param dragAxis The axis which the gizmo will be able to scale on
  55500. * @param color The color of the gizmo
  55501. * @param thickness display gizmo axis thickness
  55502. */
  55503. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55504. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55505. /**
  55506. * If the gizmo is enabled
  55507. */
  55508. set isEnabled(value: boolean);
  55509. get isEnabled(): boolean;
  55510. /**
  55511. * Disposes of the gizmo
  55512. */
  55513. dispose(): void;
  55514. /**
  55515. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55516. * @param mesh The mesh to replace the default mesh of the gizmo
  55517. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55518. */
  55519. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55520. }
  55521. }
  55522. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55523. import { Observable } from "babylonjs/Misc/observable";
  55524. import { Nullable } from "babylonjs/types";
  55525. import { Vector3 } from "babylonjs/Maths/math.vector";
  55526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55527. import { Mesh } from "babylonjs/Meshes/mesh";
  55528. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55529. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55530. import { Color3 } from "babylonjs/Maths/math.color";
  55531. import "babylonjs/Meshes/Builders/boxBuilder";
  55532. /**
  55533. * Bounding box gizmo
  55534. */
  55535. export class BoundingBoxGizmo extends Gizmo {
  55536. private _lineBoundingBox;
  55537. private _rotateSpheresParent;
  55538. private _scaleBoxesParent;
  55539. private _boundingDimensions;
  55540. private _renderObserver;
  55541. private _pointerObserver;
  55542. private _scaleDragSpeed;
  55543. private _tmpQuaternion;
  55544. private _tmpVector;
  55545. private _tmpRotationMatrix;
  55546. /**
  55547. * 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)
  55548. */
  55549. ignoreChildren: boolean;
  55550. /**
  55551. * 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)
  55552. */
  55553. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55554. /**
  55555. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55556. */
  55557. rotationSphereSize: number;
  55558. /**
  55559. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55560. */
  55561. scaleBoxSize: number;
  55562. /**
  55563. * 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)
  55564. */
  55565. fixedDragMeshScreenSize: boolean;
  55566. /**
  55567. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55568. */
  55569. fixedDragMeshScreenSizeDistanceFactor: number;
  55570. /**
  55571. * Fired when a rotation sphere or scale box is dragged
  55572. */
  55573. onDragStartObservable: Observable<{}>;
  55574. /**
  55575. * Fired when a scale box is dragged
  55576. */
  55577. onScaleBoxDragObservable: Observable<{}>;
  55578. /**
  55579. * Fired when a scale box drag is ended
  55580. */
  55581. onScaleBoxDragEndObservable: Observable<{}>;
  55582. /**
  55583. * Fired when a rotation sphere is dragged
  55584. */
  55585. onRotationSphereDragObservable: Observable<{}>;
  55586. /**
  55587. * Fired when a rotation sphere drag is ended
  55588. */
  55589. onRotationSphereDragEndObservable: Observable<{}>;
  55590. /**
  55591. * 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)
  55592. */
  55593. scalePivot: Nullable<Vector3>;
  55594. /**
  55595. * Mesh used as a pivot to rotate the attached node
  55596. */
  55597. private _anchorMesh;
  55598. private _existingMeshScale;
  55599. private _dragMesh;
  55600. private pointerDragBehavior;
  55601. private coloredMaterial;
  55602. private hoverColoredMaterial;
  55603. /**
  55604. * Sets the color of the bounding box gizmo
  55605. * @param color the color to set
  55606. */
  55607. setColor(color: Color3): void;
  55608. /**
  55609. * Creates an BoundingBoxGizmo
  55610. * @param gizmoLayer The utility layer the gizmo will be added to
  55611. * @param color The color of the gizmo
  55612. */
  55613. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55614. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55615. private _selectNode;
  55616. /**
  55617. * Updates the bounding box information for the Gizmo
  55618. */
  55619. updateBoundingBox(): void;
  55620. private _updateRotationSpheres;
  55621. private _updateScaleBoxes;
  55622. /**
  55623. * Enables rotation on the specified axis and disables rotation on the others
  55624. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55625. */
  55626. setEnabledRotationAxis(axis: string): void;
  55627. /**
  55628. * Enables/disables scaling
  55629. * @param enable if scaling should be enabled
  55630. * @param homogeneousScaling defines if scaling should only be homogeneous
  55631. */
  55632. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55633. private _updateDummy;
  55634. /**
  55635. * Enables a pointer drag behavior on the bounding box of the gizmo
  55636. */
  55637. enableDragBehavior(): void;
  55638. /**
  55639. * Disposes of the gizmo
  55640. */
  55641. dispose(): void;
  55642. /**
  55643. * 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)
  55644. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55645. * @returns the bounding box mesh with the passed in mesh as a child
  55646. */
  55647. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55648. /**
  55649. * CustomMeshes are not supported by this gizmo
  55650. * @param mesh The mesh to replace the default mesh of the gizmo
  55651. */
  55652. setCustomMesh(mesh: Mesh): void;
  55653. }
  55654. }
  55655. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55656. import { Observable } from "babylonjs/Misc/observable";
  55657. import { Nullable } from "babylonjs/types";
  55658. import { Vector3 } from "babylonjs/Maths/math.vector";
  55659. import { Color3 } from "babylonjs/Maths/math.color";
  55660. import { Node } from "babylonjs/node";
  55661. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55662. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55663. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55664. import "babylonjs/Meshes/Builders/linesBuilder";
  55665. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55666. /**
  55667. * Single plane rotation gizmo
  55668. */
  55669. export class PlaneRotationGizmo extends Gizmo {
  55670. /**
  55671. * Drag behavior responsible for the gizmos dragging interactions
  55672. */
  55673. dragBehavior: PointerDragBehavior;
  55674. private _pointerObserver;
  55675. /**
  55676. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55677. */
  55678. snapDistance: number;
  55679. /**
  55680. * Event that fires each time the gizmo snaps to a new location.
  55681. * * snapDistance is the the change in distance
  55682. */
  55683. onSnapObservable: Observable<{
  55684. snapDistance: number;
  55685. }>;
  55686. private _isEnabled;
  55687. private _parent;
  55688. /**
  55689. * Creates a PlaneRotationGizmo
  55690. * @param gizmoLayer The utility layer the gizmo will be added to
  55691. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55692. * @param color The color of the gizmo
  55693. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55694. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55695. * @param thickness display gizmo axis thickness
  55696. */
  55697. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55698. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55699. /**
  55700. * If the gizmo is enabled
  55701. */
  55702. set isEnabled(value: boolean);
  55703. get isEnabled(): boolean;
  55704. /**
  55705. * Disposes of the gizmo
  55706. */
  55707. dispose(): void;
  55708. }
  55709. }
  55710. declare module "babylonjs/Gizmos/rotationGizmo" {
  55711. import { Observable } from "babylonjs/Misc/observable";
  55712. import { Nullable } from "babylonjs/types";
  55713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55714. import { Mesh } from "babylonjs/Meshes/mesh";
  55715. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55716. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55717. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55718. import { Node } from "babylonjs/node";
  55719. /**
  55720. * Gizmo that enables rotating a mesh along 3 axis
  55721. */
  55722. export class RotationGizmo extends Gizmo {
  55723. /**
  55724. * Internal gizmo used for interactions on the x axis
  55725. */
  55726. xGizmo: PlaneRotationGizmo;
  55727. /**
  55728. * Internal gizmo used for interactions on the y axis
  55729. */
  55730. yGizmo: PlaneRotationGizmo;
  55731. /**
  55732. * Internal gizmo used for interactions on the z axis
  55733. */
  55734. zGizmo: PlaneRotationGizmo;
  55735. /** Fires an event when any of it's sub gizmos are dragged */
  55736. onDragStartObservable: Observable<unknown>;
  55737. /** Fires an event when any of it's sub gizmos are released from dragging */
  55738. onDragEndObservable: Observable<unknown>;
  55739. private _meshAttached;
  55740. private _nodeAttached;
  55741. get attachedMesh(): Nullable<AbstractMesh>;
  55742. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55743. get attachedNode(): Nullable<Node>;
  55744. set attachedNode(node: Nullable<Node>);
  55745. /**
  55746. * Creates a RotationGizmo
  55747. * @param gizmoLayer The utility layer the gizmo will be added to
  55748. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55749. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55750. * @param thickness display gizmo axis thickness
  55751. */
  55752. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55753. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55754. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55755. /**
  55756. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55757. */
  55758. set snapDistance(value: number);
  55759. get snapDistance(): number;
  55760. /**
  55761. * Ratio for the scale of the gizmo (Default: 1)
  55762. */
  55763. set scaleRatio(value: number);
  55764. get scaleRatio(): number;
  55765. /**
  55766. * Disposes of the gizmo
  55767. */
  55768. dispose(): void;
  55769. /**
  55770. * CustomMeshes are not supported by this gizmo
  55771. * @param mesh The mesh to replace the default mesh of the gizmo
  55772. */
  55773. setCustomMesh(mesh: Mesh): void;
  55774. }
  55775. }
  55776. declare module "babylonjs/Gizmos/gizmoManager" {
  55777. import { Observable } from "babylonjs/Misc/observable";
  55778. import { Nullable } from "babylonjs/types";
  55779. import { Scene, IDisposable } from "babylonjs/scene";
  55780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55781. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55782. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55783. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55784. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55785. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55786. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55787. /**
  55788. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55789. */
  55790. export class GizmoManager implements IDisposable {
  55791. private scene;
  55792. /**
  55793. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55794. */
  55795. gizmos: {
  55796. positionGizmo: Nullable<PositionGizmo>;
  55797. rotationGizmo: Nullable<RotationGizmo>;
  55798. scaleGizmo: Nullable<ScaleGizmo>;
  55799. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55800. };
  55801. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55802. clearGizmoOnEmptyPointerEvent: boolean;
  55803. /** Fires an event when the manager is attached to a mesh */
  55804. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55805. private _gizmosEnabled;
  55806. private _pointerObserver;
  55807. private _attachedMesh;
  55808. private _boundingBoxColor;
  55809. private _defaultUtilityLayer;
  55810. private _defaultKeepDepthUtilityLayer;
  55811. private _thickness;
  55812. /**
  55813. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55814. */
  55815. boundingBoxDragBehavior: SixDofDragBehavior;
  55816. /**
  55817. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55818. */
  55819. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55820. /**
  55821. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55822. */
  55823. usePointerToAttachGizmos: boolean;
  55824. /**
  55825. * Utility layer that the bounding box gizmo belongs to
  55826. */
  55827. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55828. /**
  55829. * Utility layer that all gizmos besides bounding box belong to
  55830. */
  55831. get utilityLayer(): UtilityLayerRenderer;
  55832. /**
  55833. * Instatiates a gizmo manager
  55834. * @param scene the scene to overlay the gizmos on top of
  55835. * @param thickness display gizmo axis thickness
  55836. */
  55837. constructor(scene: Scene, thickness?: number);
  55838. /**
  55839. * Attaches a set of gizmos to the specified mesh
  55840. * @param mesh The mesh the gizmo's should be attached to
  55841. */
  55842. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55843. /**
  55844. * If the position gizmo is enabled
  55845. */
  55846. set positionGizmoEnabled(value: boolean);
  55847. get positionGizmoEnabled(): boolean;
  55848. /**
  55849. * If the rotation gizmo is enabled
  55850. */
  55851. set rotationGizmoEnabled(value: boolean);
  55852. get rotationGizmoEnabled(): boolean;
  55853. /**
  55854. * If the scale gizmo is enabled
  55855. */
  55856. set scaleGizmoEnabled(value: boolean);
  55857. get scaleGizmoEnabled(): boolean;
  55858. /**
  55859. * If the boundingBox gizmo is enabled
  55860. */
  55861. set boundingBoxGizmoEnabled(value: boolean);
  55862. get boundingBoxGizmoEnabled(): boolean;
  55863. /**
  55864. * Disposes of the gizmo manager
  55865. */
  55866. dispose(): void;
  55867. }
  55868. }
  55869. declare module "babylonjs/Lights/directionalLight" {
  55870. import { Camera } from "babylonjs/Cameras/camera";
  55871. import { Scene } from "babylonjs/scene";
  55872. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55874. import { Light } from "babylonjs/Lights/light";
  55875. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55876. import { Effect } from "babylonjs/Materials/effect";
  55877. /**
  55878. * A directional light is defined by a direction (what a surprise!).
  55879. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55880. * 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.
  55881. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55882. */
  55883. export class DirectionalLight extends ShadowLight {
  55884. private _shadowFrustumSize;
  55885. /**
  55886. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55887. */
  55888. get shadowFrustumSize(): number;
  55889. /**
  55890. * Specifies a fix frustum size for the shadow generation.
  55891. */
  55892. set shadowFrustumSize(value: number);
  55893. private _shadowOrthoScale;
  55894. /**
  55895. * Gets the shadow projection scale against the optimal computed one.
  55896. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55897. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55898. */
  55899. get shadowOrthoScale(): number;
  55900. /**
  55901. * Sets the shadow projection scale against the optimal computed one.
  55902. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55903. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55904. */
  55905. set shadowOrthoScale(value: number);
  55906. /**
  55907. * Automatically compute the projection matrix to best fit (including all the casters)
  55908. * on each frame.
  55909. */
  55910. autoUpdateExtends: boolean;
  55911. /**
  55912. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55913. * on each frame. autoUpdateExtends must be set to true for this to work
  55914. */
  55915. autoCalcShadowZBounds: boolean;
  55916. private _orthoLeft;
  55917. private _orthoRight;
  55918. private _orthoTop;
  55919. private _orthoBottom;
  55920. /**
  55921. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55922. * The directional light is emitted from everywhere in the given direction.
  55923. * It can cast shadows.
  55924. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55925. * @param name The friendly name of the light
  55926. * @param direction The direction of the light
  55927. * @param scene The scene the light belongs to
  55928. */
  55929. constructor(name: string, direction: Vector3, scene: Scene);
  55930. /**
  55931. * Returns the string "DirectionalLight".
  55932. * @return The class name
  55933. */
  55934. getClassName(): string;
  55935. /**
  55936. * Returns the integer 1.
  55937. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55938. */
  55939. getTypeID(): number;
  55940. /**
  55941. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55945. /**
  55946. * Sets the passed matrix "matrix" as fixed frustum 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 _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55950. /**
  55951. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55952. * Returns the DirectionalLight Shadow projection matrix.
  55953. */
  55954. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55955. protected _buildUniformLayout(): void;
  55956. /**
  55957. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55958. * @param effect The effect to update
  55959. * @param lightIndex The index of the light in the effect to update
  55960. * @returns The directional light
  55961. */
  55962. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55963. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55964. /**
  55965. * Gets the minZ used for shadow according to both the scene and the light.
  55966. *
  55967. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55968. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55969. * @param activeCamera The camera we are returning the min for
  55970. * @returns the depth min z
  55971. */
  55972. getDepthMinZ(activeCamera: Camera): number;
  55973. /**
  55974. * Gets the maxZ used for shadow according to both the scene and the light.
  55975. *
  55976. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55977. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55978. * @param activeCamera The camera we are returning the max for
  55979. * @returns the depth max z
  55980. */
  55981. getDepthMaxZ(activeCamera: Camera): number;
  55982. /**
  55983. * Prepares the list of defines specific to the light type.
  55984. * @param defines the list of defines
  55985. * @param lightIndex defines the index of the light for the effect
  55986. */
  55987. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55988. }
  55989. }
  55990. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55991. import { Mesh } from "babylonjs/Meshes/mesh";
  55992. /**
  55993. * Class containing static functions to help procedurally build meshes
  55994. */
  55995. export class HemisphereBuilder {
  55996. /**
  55997. * Creates a hemisphere mesh
  55998. * @param name defines the name of the mesh
  55999. * @param options defines the options used to create the mesh
  56000. * @param scene defines the hosting scene
  56001. * @returns the hemisphere mesh
  56002. */
  56003. static CreateHemisphere(name: string, options: {
  56004. segments?: number;
  56005. diameter?: number;
  56006. sideOrientation?: number;
  56007. }, scene: any): Mesh;
  56008. }
  56009. }
  56010. declare module "babylonjs/Lights/spotLight" {
  56011. import { Nullable } from "babylonjs/types";
  56012. import { Scene } from "babylonjs/scene";
  56013. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56015. import { Effect } from "babylonjs/Materials/effect";
  56016. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56017. import { Light } from "babylonjs/Lights/light";
  56018. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56019. /**
  56020. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56021. * These values define a cone of light starting from the position, emitting toward the direction.
  56022. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56023. * and the exponent defines the speed of the decay of the light with distance (reach).
  56024. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56025. */
  56026. export class SpotLight extends ShadowLight {
  56027. private _angle;
  56028. private _innerAngle;
  56029. private _cosHalfAngle;
  56030. private _lightAngleScale;
  56031. private _lightAngleOffset;
  56032. /**
  56033. * Gets the cone angle of the spot light in Radians.
  56034. */
  56035. get angle(): number;
  56036. /**
  56037. * Sets the cone angle of the spot light in Radians.
  56038. */
  56039. set angle(value: number);
  56040. /**
  56041. * Only used in gltf falloff mode, this defines the angle where
  56042. * the directional falloff will start before cutting at angle which could be seen
  56043. * as outer angle.
  56044. */
  56045. get innerAngle(): number;
  56046. /**
  56047. * Only used in gltf falloff mode, this defines the angle where
  56048. * the directional falloff will start before cutting at angle which could be seen
  56049. * as outer angle.
  56050. */
  56051. set innerAngle(value: number);
  56052. private _shadowAngleScale;
  56053. /**
  56054. * Allows scaling the angle of the light for shadow generation only.
  56055. */
  56056. get shadowAngleScale(): number;
  56057. /**
  56058. * Allows scaling the angle of the light for shadow generation only.
  56059. */
  56060. set shadowAngleScale(value: number);
  56061. /**
  56062. * The light decay speed with the distance from the emission spot.
  56063. */
  56064. exponent: number;
  56065. private _projectionTextureMatrix;
  56066. /**
  56067. * Allows reading the projecton texture
  56068. */
  56069. get projectionTextureMatrix(): Matrix;
  56070. protected _projectionTextureLightNear: number;
  56071. /**
  56072. * Gets the near clip of the Spotlight for texture projection.
  56073. */
  56074. get projectionTextureLightNear(): number;
  56075. /**
  56076. * Sets the near clip of the Spotlight for texture projection.
  56077. */
  56078. set projectionTextureLightNear(value: number);
  56079. protected _projectionTextureLightFar: number;
  56080. /**
  56081. * Gets the far clip of the Spotlight for texture projection.
  56082. */
  56083. get projectionTextureLightFar(): number;
  56084. /**
  56085. * Sets the far clip of the Spotlight for texture projection.
  56086. */
  56087. set projectionTextureLightFar(value: number);
  56088. protected _projectionTextureUpDirection: Vector3;
  56089. /**
  56090. * Gets the Up vector of the Spotlight for texture projection.
  56091. */
  56092. get projectionTextureUpDirection(): Vector3;
  56093. /**
  56094. * Sets the Up vector of the Spotlight for texture projection.
  56095. */
  56096. set projectionTextureUpDirection(value: Vector3);
  56097. private _projectionTexture;
  56098. /**
  56099. * Gets the projection texture of the light.
  56100. */
  56101. get projectionTexture(): Nullable<BaseTexture>;
  56102. /**
  56103. * Sets the projection texture of the light.
  56104. */
  56105. set projectionTexture(value: Nullable<BaseTexture>);
  56106. private _projectionTextureViewLightDirty;
  56107. private _projectionTextureProjectionLightDirty;
  56108. private _projectionTextureDirty;
  56109. private _projectionTextureViewTargetVector;
  56110. private _projectionTextureViewLightMatrix;
  56111. private _projectionTextureProjectionLightMatrix;
  56112. private _projectionTextureScalingMatrix;
  56113. /**
  56114. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56115. * It can cast shadows.
  56116. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56117. * @param name The light friendly name
  56118. * @param position The position of the spot light in the scene
  56119. * @param direction The direction of the light in the scene
  56120. * @param angle The cone angle of the light in Radians
  56121. * @param exponent The light decay speed with the distance from the emission spot
  56122. * @param scene The scene the lights belongs to
  56123. */
  56124. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56125. /**
  56126. * Returns the string "SpotLight".
  56127. * @returns the class name
  56128. */
  56129. getClassName(): string;
  56130. /**
  56131. * Returns the integer 2.
  56132. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56133. */
  56134. getTypeID(): number;
  56135. /**
  56136. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56137. */
  56138. protected _setDirection(value: Vector3): void;
  56139. /**
  56140. * Overrides the position setter to recompute the projection texture view light Matrix.
  56141. */
  56142. protected _setPosition(value: Vector3): void;
  56143. /**
  56144. * 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.
  56145. * Returns the SpotLight.
  56146. */
  56147. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56148. protected _computeProjectionTextureViewLightMatrix(): void;
  56149. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56150. /**
  56151. * Main function for light texture projection matrix computing.
  56152. */
  56153. protected _computeProjectionTextureMatrix(): void;
  56154. protected _buildUniformLayout(): void;
  56155. private _computeAngleValues;
  56156. /**
  56157. * Sets the passed Effect "effect" with the Light textures.
  56158. * @param effect The effect to update
  56159. * @param lightIndex The index of the light in the effect to update
  56160. * @returns The light
  56161. */
  56162. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56163. /**
  56164. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56165. * @param effect The effect to update
  56166. * @param lightIndex The index of the light in the effect to update
  56167. * @returns The spot light
  56168. */
  56169. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56170. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56171. /**
  56172. * Disposes the light and the associated resources.
  56173. */
  56174. dispose(): void;
  56175. /**
  56176. * Prepares the list of defines specific to the light type.
  56177. * @param defines the list of defines
  56178. * @param lightIndex defines the index of the light for the effect
  56179. */
  56180. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56181. }
  56182. }
  56183. declare module "babylonjs/Gizmos/lightGizmo" {
  56184. import { Nullable } from "babylonjs/types";
  56185. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56186. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56187. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56188. import { Light } from "babylonjs/Lights/light";
  56189. /**
  56190. * Gizmo that enables viewing a light
  56191. */
  56192. export class LightGizmo extends Gizmo {
  56193. private _lightMesh;
  56194. private _material;
  56195. private _cachedPosition;
  56196. private _cachedForward;
  56197. private _attachedMeshParent;
  56198. /**
  56199. * Creates a LightGizmo
  56200. * @param gizmoLayer The utility layer the gizmo will be added to
  56201. */
  56202. constructor(gizmoLayer?: UtilityLayerRenderer);
  56203. private _light;
  56204. /**
  56205. * The light that the gizmo is attached to
  56206. */
  56207. set light(light: Nullable<Light>);
  56208. get light(): Nullable<Light>;
  56209. /**
  56210. * Gets the material used to render the light gizmo
  56211. */
  56212. get material(): StandardMaterial;
  56213. /**
  56214. * @hidden
  56215. * Updates the gizmo to match the attached mesh's position/rotation
  56216. */
  56217. protected _update(): void;
  56218. private static _Scale;
  56219. /**
  56220. * Creates the lines for a light mesh
  56221. */
  56222. private static _CreateLightLines;
  56223. /**
  56224. * Disposes of the light gizmo
  56225. */
  56226. dispose(): void;
  56227. private static _CreateHemisphericLightMesh;
  56228. private static _CreatePointLightMesh;
  56229. private static _CreateSpotLightMesh;
  56230. private static _CreateDirectionalLightMesh;
  56231. }
  56232. }
  56233. declare module "babylonjs/Gizmos/index" {
  56234. export * from "babylonjs/Gizmos/axisDragGizmo";
  56235. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56236. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56237. export * from "babylonjs/Gizmos/gizmo";
  56238. export * from "babylonjs/Gizmos/gizmoManager";
  56239. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56240. export * from "babylonjs/Gizmos/positionGizmo";
  56241. export * from "babylonjs/Gizmos/rotationGizmo";
  56242. export * from "babylonjs/Gizmos/scaleGizmo";
  56243. export * from "babylonjs/Gizmos/lightGizmo";
  56244. export * from "babylonjs/Gizmos/planeDragGizmo";
  56245. }
  56246. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56247. /** @hidden */
  56248. export var backgroundFragmentDeclaration: {
  56249. name: string;
  56250. shader: string;
  56251. };
  56252. }
  56253. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56254. /** @hidden */
  56255. export var backgroundUboDeclaration: {
  56256. name: string;
  56257. shader: string;
  56258. };
  56259. }
  56260. declare module "babylonjs/Shaders/background.fragment" {
  56261. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56262. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56263. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56264. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56265. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56266. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56267. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56268. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56269. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56270. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56271. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56272. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56274. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56275. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56276. /** @hidden */
  56277. export var backgroundPixelShader: {
  56278. name: string;
  56279. shader: string;
  56280. };
  56281. }
  56282. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56283. /** @hidden */
  56284. export var backgroundVertexDeclaration: {
  56285. name: string;
  56286. shader: string;
  56287. };
  56288. }
  56289. declare module "babylonjs/Shaders/background.vertex" {
  56290. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56291. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56292. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56293. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56294. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56295. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56296. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56297. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56298. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56299. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56300. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56301. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56302. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56303. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56304. /** @hidden */
  56305. export var backgroundVertexShader: {
  56306. name: string;
  56307. shader: string;
  56308. };
  56309. }
  56310. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56311. import { Nullable, int, float } from "babylonjs/types";
  56312. import { Scene } from "babylonjs/scene";
  56313. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56314. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56316. import { Mesh } from "babylonjs/Meshes/mesh";
  56317. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56318. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56319. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56321. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56322. import { Color3 } from "babylonjs/Maths/math.color";
  56323. import "babylonjs/Shaders/background.fragment";
  56324. import "babylonjs/Shaders/background.vertex";
  56325. /**
  56326. * Background material used to create an efficient environement around your scene.
  56327. */
  56328. export class BackgroundMaterial extends PushMaterial {
  56329. /**
  56330. * Standard reflectance value at parallel view angle.
  56331. */
  56332. static StandardReflectance0: number;
  56333. /**
  56334. * Standard reflectance value at grazing angle.
  56335. */
  56336. static StandardReflectance90: number;
  56337. protected _primaryColor: Color3;
  56338. /**
  56339. * Key light Color (multiply against the environement texture)
  56340. */
  56341. primaryColor: Color3;
  56342. protected __perceptualColor: Nullable<Color3>;
  56343. /**
  56344. * Experimental Internal Use Only.
  56345. *
  56346. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56347. * This acts as a helper to set the primary color to a more "human friendly" value.
  56348. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56349. * output color as close as possible from the chosen value.
  56350. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56351. * part of lighting setup.)
  56352. */
  56353. get _perceptualColor(): Nullable<Color3>;
  56354. set _perceptualColor(value: Nullable<Color3>);
  56355. protected _primaryColorShadowLevel: float;
  56356. /**
  56357. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56358. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56359. */
  56360. get primaryColorShadowLevel(): float;
  56361. set primaryColorShadowLevel(value: float);
  56362. protected _primaryColorHighlightLevel: float;
  56363. /**
  56364. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56365. * The primary color is used at the level chosen to define what the white area would look.
  56366. */
  56367. get primaryColorHighlightLevel(): float;
  56368. set primaryColorHighlightLevel(value: float);
  56369. protected _reflectionTexture: Nullable<BaseTexture>;
  56370. /**
  56371. * Reflection Texture used in the material.
  56372. * Should be author in a specific way for the best result (refer to the documentation).
  56373. */
  56374. reflectionTexture: Nullable<BaseTexture>;
  56375. protected _reflectionBlur: float;
  56376. /**
  56377. * Reflection Texture level of blur.
  56378. *
  56379. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56380. * texture twice.
  56381. */
  56382. reflectionBlur: float;
  56383. protected _diffuseTexture: Nullable<BaseTexture>;
  56384. /**
  56385. * Diffuse Texture used in the material.
  56386. * Should be author in a specific way for the best result (refer to the documentation).
  56387. */
  56388. diffuseTexture: Nullable<BaseTexture>;
  56389. protected _shadowLights: Nullable<IShadowLight[]>;
  56390. /**
  56391. * Specify the list of lights casting shadow on the material.
  56392. * All scene shadow lights will be included if null.
  56393. */
  56394. shadowLights: Nullable<IShadowLight[]>;
  56395. protected _shadowLevel: float;
  56396. /**
  56397. * Helps adjusting the shadow to a softer level if required.
  56398. * 0 means black shadows and 1 means no shadows.
  56399. */
  56400. shadowLevel: float;
  56401. protected _sceneCenter: Vector3;
  56402. /**
  56403. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56404. * It is usually zero but might be interesting to modify according to your setup.
  56405. */
  56406. sceneCenter: Vector3;
  56407. protected _opacityFresnel: boolean;
  56408. /**
  56409. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56410. * This helps ensuring a nice transition when the camera goes under the ground.
  56411. */
  56412. opacityFresnel: boolean;
  56413. protected _reflectionFresnel: boolean;
  56414. /**
  56415. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56416. * This helps adding a mirror texture on the ground.
  56417. */
  56418. reflectionFresnel: boolean;
  56419. protected _reflectionFalloffDistance: number;
  56420. /**
  56421. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56422. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56423. */
  56424. reflectionFalloffDistance: number;
  56425. protected _reflectionAmount: number;
  56426. /**
  56427. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56428. */
  56429. reflectionAmount: number;
  56430. protected _reflectionReflectance0: number;
  56431. /**
  56432. * This specifies the weight of the reflection at grazing angle.
  56433. */
  56434. reflectionReflectance0: number;
  56435. protected _reflectionReflectance90: number;
  56436. /**
  56437. * This specifies the weight of the reflection at a perpendicular point of view.
  56438. */
  56439. reflectionReflectance90: number;
  56440. /**
  56441. * Sets the reflection reflectance fresnel values according to the default standard
  56442. * empirically know to work well :-)
  56443. */
  56444. set reflectionStandardFresnelWeight(value: number);
  56445. protected _useRGBColor: boolean;
  56446. /**
  56447. * Helps to directly use the maps channels instead of their level.
  56448. */
  56449. useRGBColor: boolean;
  56450. protected _enableNoise: boolean;
  56451. /**
  56452. * This helps reducing the banding effect that could occur on the background.
  56453. */
  56454. enableNoise: boolean;
  56455. /**
  56456. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56457. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56458. * Recommended to be keep at 1.0 except for special cases.
  56459. */
  56460. get fovMultiplier(): number;
  56461. set fovMultiplier(value: number);
  56462. private _fovMultiplier;
  56463. /**
  56464. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56465. */
  56466. useEquirectangularFOV: boolean;
  56467. private _maxSimultaneousLights;
  56468. /**
  56469. * Number of Simultaneous lights allowed on the material.
  56470. */
  56471. maxSimultaneousLights: int;
  56472. private _shadowOnly;
  56473. /**
  56474. * Make the material only render shadows
  56475. */
  56476. shadowOnly: boolean;
  56477. /**
  56478. * Default configuration related to image processing available in the Background Material.
  56479. */
  56480. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56481. /**
  56482. * Keep track of the image processing observer to allow dispose and replace.
  56483. */
  56484. private _imageProcessingObserver;
  56485. /**
  56486. * Attaches a new image processing configuration to the PBR Material.
  56487. * @param configuration (if null the scene configuration will be use)
  56488. */
  56489. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56490. /**
  56491. * Gets the image processing configuration used either in this material.
  56492. */
  56493. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56494. /**
  56495. * Sets the Default image processing configuration used either in the this material.
  56496. *
  56497. * If sets to null, the scene one is in use.
  56498. */
  56499. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56500. /**
  56501. * Gets wether the color curves effect is enabled.
  56502. */
  56503. get cameraColorCurvesEnabled(): boolean;
  56504. /**
  56505. * Sets wether the color curves effect is enabled.
  56506. */
  56507. set cameraColorCurvesEnabled(value: boolean);
  56508. /**
  56509. * Gets wether the color grading effect is enabled.
  56510. */
  56511. get cameraColorGradingEnabled(): boolean;
  56512. /**
  56513. * Gets wether the color grading effect is enabled.
  56514. */
  56515. set cameraColorGradingEnabled(value: boolean);
  56516. /**
  56517. * Gets wether tonemapping is enabled or not.
  56518. */
  56519. get cameraToneMappingEnabled(): boolean;
  56520. /**
  56521. * Sets wether tonemapping is enabled or not
  56522. */
  56523. set cameraToneMappingEnabled(value: boolean);
  56524. /**
  56525. * The camera exposure used on this material.
  56526. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56527. * This corresponds to a photographic exposure.
  56528. */
  56529. get cameraExposure(): float;
  56530. /**
  56531. * The camera exposure used on this material.
  56532. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56533. * This corresponds to a photographic exposure.
  56534. */
  56535. set cameraExposure(value: float);
  56536. /**
  56537. * Gets The camera contrast used on this material.
  56538. */
  56539. get cameraContrast(): float;
  56540. /**
  56541. * Sets The camera contrast used on this material.
  56542. */
  56543. set cameraContrast(value: float);
  56544. /**
  56545. * Gets the Color Grading 2D Lookup Texture.
  56546. */
  56547. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56548. /**
  56549. * Sets the Color Grading 2D Lookup Texture.
  56550. */
  56551. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56552. /**
  56553. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56554. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56555. * 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;
  56556. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56557. */
  56558. get cameraColorCurves(): Nullable<ColorCurves>;
  56559. /**
  56560. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56561. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56562. * 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;
  56563. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56564. */
  56565. set cameraColorCurves(value: Nullable<ColorCurves>);
  56566. /**
  56567. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56568. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56569. */
  56570. switchToBGR: boolean;
  56571. private _renderTargets;
  56572. private _reflectionControls;
  56573. private _white;
  56574. private _primaryShadowColor;
  56575. private _primaryHighlightColor;
  56576. /**
  56577. * Instantiates a Background Material in the given scene
  56578. * @param name The friendly name of the material
  56579. * @param scene The scene to add the material to
  56580. */
  56581. constructor(name: string, scene: Scene);
  56582. /**
  56583. * Gets a boolean indicating that current material needs to register RTT
  56584. */
  56585. get hasRenderTargetTextures(): boolean;
  56586. /**
  56587. * The entire material has been created in order to prevent overdraw.
  56588. * @returns false
  56589. */
  56590. needAlphaTesting(): boolean;
  56591. /**
  56592. * The entire material has been created in order to prevent overdraw.
  56593. * @returns true if blending is enable
  56594. */
  56595. needAlphaBlending(): boolean;
  56596. /**
  56597. * Checks wether the material is ready to be rendered for a given mesh.
  56598. * @param mesh The mesh to render
  56599. * @param subMesh The submesh to check against
  56600. * @param useInstances Specify wether or not the material is used with instances
  56601. * @returns true if all the dependencies are ready (Textures, Effects...)
  56602. */
  56603. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56604. /**
  56605. * Compute the primary color according to the chosen perceptual color.
  56606. */
  56607. private _computePrimaryColorFromPerceptualColor;
  56608. /**
  56609. * Compute the highlights and shadow colors according to their chosen levels.
  56610. */
  56611. private _computePrimaryColors;
  56612. /**
  56613. * Build the uniform buffer used in the material.
  56614. */
  56615. buildUniformLayout(): void;
  56616. /**
  56617. * Unbind the material.
  56618. */
  56619. unbind(): void;
  56620. /**
  56621. * Bind only the world matrix to the material.
  56622. * @param world The world matrix to bind.
  56623. */
  56624. bindOnlyWorldMatrix(world: Matrix): void;
  56625. /**
  56626. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56627. * @param world The world matrix to bind.
  56628. * @param subMesh The submesh to bind for.
  56629. */
  56630. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56631. /**
  56632. * Checks to see if a texture is used in the material.
  56633. * @param texture - Base texture to use.
  56634. * @returns - Boolean specifying if a texture is used in the material.
  56635. */
  56636. hasTexture(texture: BaseTexture): boolean;
  56637. /**
  56638. * Dispose the material.
  56639. * @param forceDisposeEffect Force disposal of the associated effect.
  56640. * @param forceDisposeTextures Force disposal of the associated textures.
  56641. */
  56642. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56643. /**
  56644. * Clones the material.
  56645. * @param name The cloned name.
  56646. * @returns The cloned material.
  56647. */
  56648. clone(name: string): BackgroundMaterial;
  56649. /**
  56650. * Serializes the current material to its JSON representation.
  56651. * @returns The JSON representation.
  56652. */
  56653. serialize(): any;
  56654. /**
  56655. * Gets the class name of the material
  56656. * @returns "BackgroundMaterial"
  56657. */
  56658. getClassName(): string;
  56659. /**
  56660. * Parse a JSON input to create back a background material.
  56661. * @param source The JSON data to parse
  56662. * @param scene The scene to create the parsed material in
  56663. * @param rootUrl The root url of the assets the material depends upon
  56664. * @returns the instantiated BackgroundMaterial.
  56665. */
  56666. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56667. }
  56668. }
  56669. declare module "babylonjs/Helpers/environmentHelper" {
  56670. import { Observable } from "babylonjs/Misc/observable";
  56671. import { Nullable } from "babylonjs/types";
  56672. import { Scene } from "babylonjs/scene";
  56673. import { Vector3 } from "babylonjs/Maths/math.vector";
  56674. import { Color3 } from "babylonjs/Maths/math.color";
  56675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56676. import { Mesh } from "babylonjs/Meshes/mesh";
  56677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56678. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56679. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56680. import "babylonjs/Meshes/Builders/planeBuilder";
  56681. import "babylonjs/Meshes/Builders/boxBuilder";
  56682. /**
  56683. * Represents the different options available during the creation of
  56684. * a Environment helper.
  56685. *
  56686. * This can control the default ground, skybox and image processing setup of your scene.
  56687. */
  56688. export interface IEnvironmentHelperOptions {
  56689. /**
  56690. * Specifies whether or not to create a ground.
  56691. * True by default.
  56692. */
  56693. createGround: boolean;
  56694. /**
  56695. * Specifies the ground size.
  56696. * 15 by default.
  56697. */
  56698. groundSize: number;
  56699. /**
  56700. * The texture used on the ground for the main color.
  56701. * Comes from the BabylonJS CDN by default.
  56702. *
  56703. * Remarks: Can be either a texture or a url.
  56704. */
  56705. groundTexture: string | BaseTexture;
  56706. /**
  56707. * The color mixed in the ground texture by default.
  56708. * BabylonJS clearColor by default.
  56709. */
  56710. groundColor: Color3;
  56711. /**
  56712. * Specifies the ground opacity.
  56713. * 1 by default.
  56714. */
  56715. groundOpacity: number;
  56716. /**
  56717. * Enables the ground to receive shadows.
  56718. * True by default.
  56719. */
  56720. enableGroundShadow: boolean;
  56721. /**
  56722. * Helps preventing the shadow to be fully black on the ground.
  56723. * 0.5 by default.
  56724. */
  56725. groundShadowLevel: number;
  56726. /**
  56727. * Creates a mirror texture attach to the ground.
  56728. * false by default.
  56729. */
  56730. enableGroundMirror: boolean;
  56731. /**
  56732. * Specifies the ground mirror size ratio.
  56733. * 0.3 by default as the default kernel is 64.
  56734. */
  56735. groundMirrorSizeRatio: number;
  56736. /**
  56737. * Specifies the ground mirror blur kernel size.
  56738. * 64 by default.
  56739. */
  56740. groundMirrorBlurKernel: number;
  56741. /**
  56742. * Specifies the ground mirror visibility amount.
  56743. * 1 by default
  56744. */
  56745. groundMirrorAmount: number;
  56746. /**
  56747. * Specifies the ground mirror reflectance weight.
  56748. * This uses the standard weight of the background material to setup the fresnel effect
  56749. * of the mirror.
  56750. * 1 by default.
  56751. */
  56752. groundMirrorFresnelWeight: number;
  56753. /**
  56754. * Specifies the ground mirror Falloff distance.
  56755. * This can helps reducing the size of the reflection.
  56756. * 0 by Default.
  56757. */
  56758. groundMirrorFallOffDistance: number;
  56759. /**
  56760. * Specifies the ground mirror texture type.
  56761. * Unsigned Int by Default.
  56762. */
  56763. groundMirrorTextureType: number;
  56764. /**
  56765. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56766. * the shown objects.
  56767. */
  56768. groundYBias: number;
  56769. /**
  56770. * Specifies whether or not to create a skybox.
  56771. * True by default.
  56772. */
  56773. createSkybox: boolean;
  56774. /**
  56775. * Specifies the skybox size.
  56776. * 20 by default.
  56777. */
  56778. skyboxSize: number;
  56779. /**
  56780. * The texture used on the skybox for the main color.
  56781. * Comes from the BabylonJS CDN by default.
  56782. *
  56783. * Remarks: Can be either a texture or a url.
  56784. */
  56785. skyboxTexture: string | BaseTexture;
  56786. /**
  56787. * The color mixed in the skybox texture by default.
  56788. * BabylonJS clearColor by default.
  56789. */
  56790. skyboxColor: Color3;
  56791. /**
  56792. * The background rotation around the Y axis of the scene.
  56793. * This helps aligning the key lights of your scene with the background.
  56794. * 0 by default.
  56795. */
  56796. backgroundYRotation: number;
  56797. /**
  56798. * Compute automatically the size of the elements to best fit with the scene.
  56799. */
  56800. sizeAuto: boolean;
  56801. /**
  56802. * Default position of the rootMesh if autoSize is not true.
  56803. */
  56804. rootPosition: Vector3;
  56805. /**
  56806. * Sets up the image processing in the scene.
  56807. * true by default.
  56808. */
  56809. setupImageProcessing: boolean;
  56810. /**
  56811. * The texture used as your environment texture in the scene.
  56812. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56813. *
  56814. * Remarks: Can be either a texture or a url.
  56815. */
  56816. environmentTexture: string | BaseTexture;
  56817. /**
  56818. * The value of the exposure to apply to the scene.
  56819. * 0.6 by default if setupImageProcessing is true.
  56820. */
  56821. cameraExposure: number;
  56822. /**
  56823. * The value of the contrast to apply to the scene.
  56824. * 1.6 by default if setupImageProcessing is true.
  56825. */
  56826. cameraContrast: number;
  56827. /**
  56828. * Specifies whether or not tonemapping should be enabled in the scene.
  56829. * true by default if setupImageProcessing is true.
  56830. */
  56831. toneMappingEnabled: boolean;
  56832. }
  56833. /**
  56834. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56835. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56836. * It also helps with the default setup of your imageProcessing configuration.
  56837. */
  56838. export class EnvironmentHelper {
  56839. /**
  56840. * Default ground texture URL.
  56841. */
  56842. private static _groundTextureCDNUrl;
  56843. /**
  56844. * Default skybox texture URL.
  56845. */
  56846. private static _skyboxTextureCDNUrl;
  56847. /**
  56848. * Default environment texture URL.
  56849. */
  56850. private static _environmentTextureCDNUrl;
  56851. /**
  56852. * Creates the default options for the helper.
  56853. */
  56854. private static _getDefaultOptions;
  56855. private _rootMesh;
  56856. /**
  56857. * Gets the root mesh created by the helper.
  56858. */
  56859. get rootMesh(): Mesh;
  56860. private _skybox;
  56861. /**
  56862. * Gets the skybox created by the helper.
  56863. */
  56864. get skybox(): Nullable<Mesh>;
  56865. private _skyboxTexture;
  56866. /**
  56867. * Gets the skybox texture created by the helper.
  56868. */
  56869. get skyboxTexture(): Nullable<BaseTexture>;
  56870. private _skyboxMaterial;
  56871. /**
  56872. * Gets the skybox material created by the helper.
  56873. */
  56874. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56875. private _ground;
  56876. /**
  56877. * Gets the ground mesh created by the helper.
  56878. */
  56879. get ground(): Nullable<Mesh>;
  56880. private _groundTexture;
  56881. /**
  56882. * Gets the ground texture created by the helper.
  56883. */
  56884. get groundTexture(): Nullable<BaseTexture>;
  56885. private _groundMirror;
  56886. /**
  56887. * Gets the ground mirror created by the helper.
  56888. */
  56889. get groundMirror(): Nullable<MirrorTexture>;
  56890. /**
  56891. * Gets the ground mirror render list to helps pushing the meshes
  56892. * you wish in the ground reflection.
  56893. */
  56894. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56895. private _groundMaterial;
  56896. /**
  56897. * Gets the ground material created by the helper.
  56898. */
  56899. get groundMaterial(): Nullable<BackgroundMaterial>;
  56900. /**
  56901. * Stores the creation options.
  56902. */
  56903. private readonly _scene;
  56904. private _options;
  56905. /**
  56906. * This observable will be notified with any error during the creation of the environment,
  56907. * mainly texture creation errors.
  56908. */
  56909. onErrorObservable: Observable<{
  56910. message?: string;
  56911. exception?: any;
  56912. }>;
  56913. /**
  56914. * constructor
  56915. * @param options Defines the options we want to customize the helper
  56916. * @param scene The scene to add the material to
  56917. */
  56918. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56919. /**
  56920. * Updates the background according to the new options
  56921. * @param options
  56922. */
  56923. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56924. /**
  56925. * Sets the primary color of all the available elements.
  56926. * @param color the main color to affect to the ground and the background
  56927. */
  56928. setMainColor(color: Color3): void;
  56929. /**
  56930. * Setup the image processing according to the specified options.
  56931. */
  56932. private _setupImageProcessing;
  56933. /**
  56934. * Setup the environment texture according to the specified options.
  56935. */
  56936. private _setupEnvironmentTexture;
  56937. /**
  56938. * Setup the background according to the specified options.
  56939. */
  56940. private _setupBackground;
  56941. /**
  56942. * Get the scene sizes according to the setup.
  56943. */
  56944. private _getSceneSize;
  56945. /**
  56946. * Setup the ground according to the specified options.
  56947. */
  56948. private _setupGround;
  56949. /**
  56950. * Setup the ground material according to the specified options.
  56951. */
  56952. private _setupGroundMaterial;
  56953. /**
  56954. * Setup the ground diffuse texture according to the specified options.
  56955. */
  56956. private _setupGroundDiffuseTexture;
  56957. /**
  56958. * Setup the ground mirror texture according to the specified options.
  56959. */
  56960. private _setupGroundMirrorTexture;
  56961. /**
  56962. * Setup the ground to receive the mirror texture.
  56963. */
  56964. private _setupMirrorInGroundMaterial;
  56965. /**
  56966. * Setup the skybox according to the specified options.
  56967. */
  56968. private _setupSkybox;
  56969. /**
  56970. * Setup the skybox material according to the specified options.
  56971. */
  56972. private _setupSkyboxMaterial;
  56973. /**
  56974. * Setup the skybox reflection texture according to the specified options.
  56975. */
  56976. private _setupSkyboxReflectionTexture;
  56977. private _errorHandler;
  56978. /**
  56979. * Dispose all the elements created by the Helper.
  56980. */
  56981. dispose(): void;
  56982. }
  56983. }
  56984. declare module "babylonjs/Helpers/photoDome" {
  56985. import { Observable } from "babylonjs/Misc/observable";
  56986. import { Nullable } from "babylonjs/types";
  56987. import { Scene } from "babylonjs/scene";
  56988. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56989. import { Mesh } from "babylonjs/Meshes/mesh";
  56990. import { Texture } from "babylonjs/Materials/Textures/texture";
  56991. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56992. import "babylonjs/Meshes/Builders/sphereBuilder";
  56993. /**
  56994. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56995. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56996. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56997. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56998. */
  56999. export class PhotoDome extends TransformNode {
  57000. /**
  57001. * Define the image as a Monoscopic panoramic 360 image.
  57002. */
  57003. static readonly MODE_MONOSCOPIC: number;
  57004. /**
  57005. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57006. */
  57007. static readonly MODE_TOPBOTTOM: number;
  57008. /**
  57009. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57010. */
  57011. static readonly MODE_SIDEBYSIDE: number;
  57012. private _useDirectMapping;
  57013. /**
  57014. * The texture being displayed on the sphere
  57015. */
  57016. protected _photoTexture: Texture;
  57017. /**
  57018. * Gets or sets the texture being displayed on the sphere
  57019. */
  57020. get photoTexture(): Texture;
  57021. set photoTexture(value: Texture);
  57022. /**
  57023. * Observable raised when an error occured while loading the 360 image
  57024. */
  57025. onLoadErrorObservable: Observable<string>;
  57026. /**
  57027. * The skybox material
  57028. */
  57029. protected _material: BackgroundMaterial;
  57030. /**
  57031. * The surface used for the skybox
  57032. */
  57033. protected _mesh: Mesh;
  57034. /**
  57035. * Gets the mesh used for the skybox.
  57036. */
  57037. get mesh(): Mesh;
  57038. /**
  57039. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57040. * Also see the options.resolution property.
  57041. */
  57042. get fovMultiplier(): number;
  57043. set fovMultiplier(value: number);
  57044. private _imageMode;
  57045. /**
  57046. * Gets or set the current video mode for the video. It can be:
  57047. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  57048. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57049. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57050. */
  57051. get imageMode(): number;
  57052. set imageMode(value: number);
  57053. /**
  57054. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  57055. * @param name Element's name, child elements will append suffixes for their own names.
  57056. * @param urlsOfPhoto defines the url of the photo to display
  57057. * @param options defines an object containing optional or exposed sub element properties
  57058. * @param onError defines a callback called when an error occured while loading the texture
  57059. */
  57060. constructor(name: string, urlOfPhoto: string, options: {
  57061. resolution?: number;
  57062. size?: number;
  57063. useDirectMapping?: boolean;
  57064. faceForward?: boolean;
  57065. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57066. private _onBeforeCameraRenderObserver;
  57067. private _changeImageMode;
  57068. /**
  57069. * Releases resources associated with this node.
  57070. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57071. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57072. */
  57073. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57074. }
  57075. }
  57076. declare module "babylonjs/Misc/rgbdTextureTools" {
  57077. import "babylonjs/Shaders/rgbdDecode.fragment";
  57078. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57079. import { Texture } from "babylonjs/Materials/Textures/texture";
  57080. /**
  57081. * Class used to host RGBD texture specific utilities
  57082. */
  57083. export class RGBDTextureTools {
  57084. /**
  57085. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57086. * @param texture the texture to expand.
  57087. */
  57088. static ExpandRGBDTexture(texture: Texture): void;
  57089. }
  57090. }
  57091. declare module "babylonjs/Misc/brdfTextureTools" {
  57092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57093. import { Scene } from "babylonjs/scene";
  57094. /**
  57095. * Class used to host texture specific utilities
  57096. */
  57097. export class BRDFTextureTools {
  57098. /**
  57099. * Prevents texture cache collision
  57100. */
  57101. private static _instanceNumber;
  57102. /**
  57103. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57104. * @param scene defines the hosting scene
  57105. * @returns the environment BRDF texture
  57106. */
  57107. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57108. private static _environmentBRDFBase64Texture;
  57109. }
  57110. }
  57111. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57112. import { Nullable } from "babylonjs/types";
  57113. import { Color3 } from "babylonjs/Maths/math.color";
  57114. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57115. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57116. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57117. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57118. import { Engine } from "babylonjs/Engines/engine";
  57119. import { Scene } from "babylonjs/scene";
  57120. /**
  57121. * @hidden
  57122. */
  57123. export interface IMaterialClearCoatDefines {
  57124. CLEARCOAT: boolean;
  57125. CLEARCOAT_DEFAULTIOR: boolean;
  57126. CLEARCOAT_TEXTURE: boolean;
  57127. CLEARCOAT_TEXTUREDIRECTUV: number;
  57128. CLEARCOAT_BUMP: boolean;
  57129. CLEARCOAT_BUMPDIRECTUV: number;
  57130. CLEARCOAT_TINT: boolean;
  57131. CLEARCOAT_TINT_TEXTURE: boolean;
  57132. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57133. /** @hidden */
  57134. _areTexturesDirty: boolean;
  57135. }
  57136. /**
  57137. * Define the code related to the clear coat parameters of the pbr material.
  57138. */
  57139. export class PBRClearCoatConfiguration {
  57140. /**
  57141. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57142. * The default fits with a polyurethane material.
  57143. */
  57144. private static readonly _DefaultIndexOfRefraction;
  57145. private _isEnabled;
  57146. /**
  57147. * Defines if the clear coat is enabled in the material.
  57148. */
  57149. isEnabled: boolean;
  57150. /**
  57151. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57152. */
  57153. intensity: number;
  57154. /**
  57155. * Defines the clear coat layer roughness.
  57156. */
  57157. roughness: number;
  57158. private _indexOfRefraction;
  57159. /**
  57160. * Defines the index of refraction of the clear coat.
  57161. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57162. * The default fits with a polyurethane material.
  57163. * Changing the default value is more performance intensive.
  57164. */
  57165. indexOfRefraction: number;
  57166. private _texture;
  57167. /**
  57168. * Stores the clear coat values in a texture.
  57169. */
  57170. texture: Nullable<BaseTexture>;
  57171. private _bumpTexture;
  57172. /**
  57173. * Define the clear coat specific bump texture.
  57174. */
  57175. bumpTexture: Nullable<BaseTexture>;
  57176. private _isTintEnabled;
  57177. /**
  57178. * Defines if the clear coat tint is enabled in the material.
  57179. */
  57180. isTintEnabled: boolean;
  57181. /**
  57182. * Defines the clear coat tint of the material.
  57183. * This is only use if tint is enabled
  57184. */
  57185. tintColor: Color3;
  57186. /**
  57187. * Defines the distance at which the tint color should be found in the
  57188. * clear coat media.
  57189. * This is only use if tint is enabled
  57190. */
  57191. tintColorAtDistance: number;
  57192. /**
  57193. * Defines the clear coat layer thickness.
  57194. * This is only use if tint is enabled
  57195. */
  57196. tintThickness: number;
  57197. private _tintTexture;
  57198. /**
  57199. * Stores the clear tint values in a texture.
  57200. * rgb is tint
  57201. * a is a thickness factor
  57202. */
  57203. tintTexture: Nullable<BaseTexture>;
  57204. /** @hidden */
  57205. private _internalMarkAllSubMeshesAsTexturesDirty;
  57206. /** @hidden */
  57207. _markAllSubMeshesAsTexturesDirty(): void;
  57208. /**
  57209. * Instantiate a new istance of clear coat configuration.
  57210. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57211. */
  57212. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57213. /**
  57214. * Gets wehter the submesh is ready to be used or not.
  57215. * @param defines the list of "defines" to update.
  57216. * @param scene defines the scene the material belongs to.
  57217. * @param engine defines the engine the material belongs to.
  57218. * @param disableBumpMap defines wether the material disables bump or not.
  57219. * @returns - boolean indicating that the submesh is ready or not.
  57220. */
  57221. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57222. /**
  57223. * Checks to see if a texture is used in the material.
  57224. * @param defines the list of "defines" to update.
  57225. * @param scene defines the scene to the material belongs to.
  57226. */
  57227. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57228. /**
  57229. * Binds the material data.
  57230. * @param uniformBuffer defines the Uniform buffer to fill in.
  57231. * @param scene defines the scene the material belongs to.
  57232. * @param engine defines the engine the material belongs to.
  57233. * @param disableBumpMap defines wether the material disables bump or not.
  57234. * @param isFrozen defines wether the material is frozen or not.
  57235. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57236. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57237. */
  57238. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57239. /**
  57240. * Checks to see if a texture is used in the material.
  57241. * @param texture - Base texture to use.
  57242. * @returns - Boolean specifying if a texture is used in the material.
  57243. */
  57244. hasTexture(texture: BaseTexture): boolean;
  57245. /**
  57246. * Returns an array of the actively used textures.
  57247. * @param activeTextures Array of BaseTextures
  57248. */
  57249. getActiveTextures(activeTextures: BaseTexture[]): void;
  57250. /**
  57251. * Returns the animatable textures.
  57252. * @param animatables Array of animatable textures.
  57253. */
  57254. getAnimatables(animatables: IAnimatable[]): void;
  57255. /**
  57256. * Disposes the resources of the material.
  57257. * @param forceDisposeTextures - Forces the disposal of all textures.
  57258. */
  57259. dispose(forceDisposeTextures?: boolean): void;
  57260. /**
  57261. * Get the current class name of the texture useful for serialization or dynamic coding.
  57262. * @returns "PBRClearCoatConfiguration"
  57263. */
  57264. getClassName(): string;
  57265. /**
  57266. * Add fallbacks to the effect fallbacks list.
  57267. * @param defines defines the Base texture to use.
  57268. * @param fallbacks defines the current fallback list.
  57269. * @param currentRank defines the current fallback rank.
  57270. * @returns the new fallback rank.
  57271. */
  57272. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57273. /**
  57274. * Add the required uniforms to the current list.
  57275. * @param uniforms defines the current uniform list.
  57276. */
  57277. static AddUniforms(uniforms: string[]): void;
  57278. /**
  57279. * Add the required samplers to the current list.
  57280. * @param samplers defines the current sampler list.
  57281. */
  57282. static AddSamplers(samplers: string[]): void;
  57283. /**
  57284. * Add the required uniforms to the current buffer.
  57285. * @param uniformBuffer defines the current uniform buffer.
  57286. */
  57287. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57288. /**
  57289. * Makes a duplicate of the current configuration into another one.
  57290. * @param clearCoatConfiguration define the config where to copy the info
  57291. */
  57292. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57293. /**
  57294. * Serializes this clear coat configuration.
  57295. * @returns - An object with the serialized config.
  57296. */
  57297. serialize(): any;
  57298. /**
  57299. * Parses a anisotropy Configuration from a serialized object.
  57300. * @param source - Serialized object.
  57301. * @param scene Defines the scene we are parsing for
  57302. * @param rootUrl Defines the rootUrl to load from
  57303. */
  57304. parse(source: any, scene: Scene, rootUrl: string): void;
  57305. }
  57306. }
  57307. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57308. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57310. import { Vector2 } from "babylonjs/Maths/math.vector";
  57311. import { Scene } from "babylonjs/scene";
  57312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57313. import { Nullable } from "babylonjs/types";
  57314. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57315. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57316. /**
  57317. * @hidden
  57318. */
  57319. export interface IMaterialAnisotropicDefines {
  57320. ANISOTROPIC: boolean;
  57321. ANISOTROPIC_TEXTURE: boolean;
  57322. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57323. MAINUV1: boolean;
  57324. _areTexturesDirty: boolean;
  57325. _needUVs: boolean;
  57326. }
  57327. /**
  57328. * Define the code related to the anisotropic parameters of the pbr material.
  57329. */
  57330. export class PBRAnisotropicConfiguration {
  57331. private _isEnabled;
  57332. /**
  57333. * Defines if the anisotropy is enabled in the material.
  57334. */
  57335. isEnabled: boolean;
  57336. /**
  57337. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57338. */
  57339. intensity: number;
  57340. /**
  57341. * Defines if the effect is along the tangents, bitangents or in between.
  57342. * By default, the effect is "strectching" the highlights along the tangents.
  57343. */
  57344. direction: Vector2;
  57345. private _texture;
  57346. /**
  57347. * Stores the anisotropy values in a texture.
  57348. * rg is direction (like normal from -1 to 1)
  57349. * b is a intensity
  57350. */
  57351. texture: Nullable<BaseTexture>;
  57352. /** @hidden */
  57353. private _internalMarkAllSubMeshesAsTexturesDirty;
  57354. /** @hidden */
  57355. _markAllSubMeshesAsTexturesDirty(): void;
  57356. /**
  57357. * Instantiate a new istance of anisotropy configuration.
  57358. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57359. */
  57360. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57361. /**
  57362. * Specifies that the submesh is ready to be used.
  57363. * @param defines the list of "defines" to update.
  57364. * @param scene defines the scene the material belongs to.
  57365. * @returns - boolean indicating that the submesh is ready or not.
  57366. */
  57367. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57368. /**
  57369. * Checks to see if a texture is used in the material.
  57370. * @param defines the list of "defines" to update.
  57371. * @param mesh the mesh we are preparing the defines for.
  57372. * @param scene defines the scene the material belongs to.
  57373. */
  57374. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57375. /**
  57376. * Binds the material data.
  57377. * @param uniformBuffer defines the Uniform buffer to fill in.
  57378. * @param scene defines the scene the material belongs to.
  57379. * @param isFrozen defines wether the material is frozen or not.
  57380. */
  57381. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57382. /**
  57383. * Checks to see if a texture is used in the material.
  57384. * @param texture - Base texture to use.
  57385. * @returns - Boolean specifying if a texture is used in the material.
  57386. */
  57387. hasTexture(texture: BaseTexture): boolean;
  57388. /**
  57389. * Returns an array of the actively used textures.
  57390. * @param activeTextures Array of BaseTextures
  57391. */
  57392. getActiveTextures(activeTextures: BaseTexture[]): void;
  57393. /**
  57394. * Returns the animatable textures.
  57395. * @param animatables Array of animatable textures.
  57396. */
  57397. getAnimatables(animatables: IAnimatable[]): void;
  57398. /**
  57399. * Disposes the resources of the material.
  57400. * @param forceDisposeTextures - Forces the disposal of all textures.
  57401. */
  57402. dispose(forceDisposeTextures?: boolean): void;
  57403. /**
  57404. * Get the current class name of the texture useful for serialization or dynamic coding.
  57405. * @returns "PBRAnisotropicConfiguration"
  57406. */
  57407. getClassName(): string;
  57408. /**
  57409. * Add fallbacks to the effect fallbacks list.
  57410. * @param defines defines the Base texture to use.
  57411. * @param fallbacks defines the current fallback list.
  57412. * @param currentRank defines the current fallback rank.
  57413. * @returns the new fallback rank.
  57414. */
  57415. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57416. /**
  57417. * Add the required uniforms to the current list.
  57418. * @param uniforms defines the current uniform list.
  57419. */
  57420. static AddUniforms(uniforms: string[]): void;
  57421. /**
  57422. * Add the required uniforms to the current buffer.
  57423. * @param uniformBuffer defines the current uniform buffer.
  57424. */
  57425. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57426. /**
  57427. * Add the required samplers to the current list.
  57428. * @param samplers defines the current sampler list.
  57429. */
  57430. static AddSamplers(samplers: string[]): void;
  57431. /**
  57432. * Makes a duplicate of the current configuration into another one.
  57433. * @param anisotropicConfiguration define the config where to copy the info
  57434. */
  57435. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57436. /**
  57437. * Serializes this anisotropy configuration.
  57438. * @returns - An object with the serialized config.
  57439. */
  57440. serialize(): any;
  57441. /**
  57442. * Parses a anisotropy Configuration from a serialized object.
  57443. * @param source - Serialized object.
  57444. * @param scene Defines the scene we are parsing for
  57445. * @param rootUrl Defines the rootUrl to load from
  57446. */
  57447. parse(source: any, scene: Scene, rootUrl: string): void;
  57448. }
  57449. }
  57450. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57451. import { Scene } from "babylonjs/scene";
  57452. /**
  57453. * @hidden
  57454. */
  57455. export interface IMaterialBRDFDefines {
  57456. BRDF_V_HEIGHT_CORRELATED: boolean;
  57457. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57458. SPHERICAL_HARMONICS: boolean;
  57459. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57460. /** @hidden */
  57461. _areMiscDirty: boolean;
  57462. }
  57463. /**
  57464. * Define the code related to the BRDF parameters of the pbr material.
  57465. */
  57466. export class PBRBRDFConfiguration {
  57467. /**
  57468. * Default value used for the energy conservation.
  57469. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57470. */
  57471. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57472. /**
  57473. * Default value used for the Smith Visibility Height Correlated mode.
  57474. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57475. */
  57476. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57477. /**
  57478. * Default value used for the IBL diffuse part.
  57479. * This can help switching back to the polynomials mode globally which is a tiny bit
  57480. * less GPU intensive at the drawback of a lower quality.
  57481. */
  57482. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57483. /**
  57484. * Default value used for activating energy conservation for the specular workflow.
  57485. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57486. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57487. */
  57488. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57489. private _useEnergyConservation;
  57490. /**
  57491. * Defines if the material uses energy conservation.
  57492. */
  57493. useEnergyConservation: boolean;
  57494. private _useSmithVisibilityHeightCorrelated;
  57495. /**
  57496. * LEGACY Mode set to false
  57497. * Defines if the material uses height smith correlated visibility term.
  57498. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57499. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57500. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57501. * Not relying on height correlated will also disable energy conservation.
  57502. */
  57503. useSmithVisibilityHeightCorrelated: boolean;
  57504. private _useSphericalHarmonics;
  57505. /**
  57506. * LEGACY Mode set to false
  57507. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57508. * diffuse part of the IBL.
  57509. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57510. * to the ground truth.
  57511. */
  57512. useSphericalHarmonics: boolean;
  57513. private _useSpecularGlossinessInputEnergyConservation;
  57514. /**
  57515. * Defines if the material uses energy conservation, when the specular workflow is active.
  57516. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57517. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57518. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57519. */
  57520. useSpecularGlossinessInputEnergyConservation: boolean;
  57521. /** @hidden */
  57522. private _internalMarkAllSubMeshesAsMiscDirty;
  57523. /** @hidden */
  57524. _markAllSubMeshesAsMiscDirty(): void;
  57525. /**
  57526. * Instantiate a new istance of clear coat configuration.
  57527. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57528. */
  57529. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57530. /**
  57531. * Checks to see if a texture is used in the material.
  57532. * @param defines the list of "defines" to update.
  57533. */
  57534. prepareDefines(defines: IMaterialBRDFDefines): void;
  57535. /**
  57536. * Get the current class name of the texture useful for serialization or dynamic coding.
  57537. * @returns "PBRClearCoatConfiguration"
  57538. */
  57539. getClassName(): string;
  57540. /**
  57541. * Makes a duplicate of the current configuration into another one.
  57542. * @param brdfConfiguration define the config where to copy the info
  57543. */
  57544. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57545. /**
  57546. * Serializes this BRDF configuration.
  57547. * @returns - An object with the serialized config.
  57548. */
  57549. serialize(): any;
  57550. /**
  57551. * Parses a anisotropy Configuration from a serialized object.
  57552. * @param source - Serialized object.
  57553. * @param scene Defines the scene we are parsing for
  57554. * @param rootUrl Defines the rootUrl to load from
  57555. */
  57556. parse(source: any, scene: Scene, rootUrl: string): void;
  57557. }
  57558. }
  57559. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57560. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57561. import { Color3 } from "babylonjs/Maths/math.color";
  57562. import { Scene } from "babylonjs/scene";
  57563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57564. import { Nullable } from "babylonjs/types";
  57565. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57566. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57567. /**
  57568. * @hidden
  57569. */
  57570. export interface IMaterialSheenDefines {
  57571. SHEEN: boolean;
  57572. SHEEN_TEXTURE: boolean;
  57573. SHEEN_TEXTUREDIRECTUV: number;
  57574. SHEEN_LINKWITHALBEDO: boolean;
  57575. SHEEN_ROUGHNESS: boolean;
  57576. SHEEN_ALBEDOSCALING: boolean;
  57577. /** @hidden */
  57578. _areTexturesDirty: boolean;
  57579. }
  57580. /**
  57581. * Define the code related to the Sheen parameters of the pbr material.
  57582. */
  57583. export class PBRSheenConfiguration {
  57584. private _isEnabled;
  57585. /**
  57586. * Defines if the material uses sheen.
  57587. */
  57588. isEnabled: boolean;
  57589. private _linkSheenWithAlbedo;
  57590. /**
  57591. * Defines if the sheen is linked to the sheen color.
  57592. */
  57593. linkSheenWithAlbedo: boolean;
  57594. /**
  57595. * Defines the sheen intensity.
  57596. */
  57597. intensity: number;
  57598. /**
  57599. * Defines the sheen color.
  57600. */
  57601. color: Color3;
  57602. private _texture;
  57603. /**
  57604. * Stores the sheen tint values in a texture.
  57605. * rgb is tint
  57606. * a is a intensity or roughness if roughness has been defined
  57607. */
  57608. texture: Nullable<BaseTexture>;
  57609. private _roughness;
  57610. /**
  57611. * Defines the sheen roughness.
  57612. * It is not taken into account if linkSheenWithAlbedo is true.
  57613. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57614. */
  57615. roughness: Nullable<number>;
  57616. private _albedoScaling;
  57617. /**
  57618. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57619. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57620. * making it easier to setup and tweak the effect
  57621. */
  57622. albedoScaling: boolean;
  57623. /** @hidden */
  57624. private _internalMarkAllSubMeshesAsTexturesDirty;
  57625. /** @hidden */
  57626. _markAllSubMeshesAsTexturesDirty(): void;
  57627. /**
  57628. * Instantiate a new istance of clear coat configuration.
  57629. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57630. */
  57631. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57632. /**
  57633. * Specifies that the submesh is ready to be used.
  57634. * @param defines the list of "defines" to update.
  57635. * @param scene defines the scene the material belongs to.
  57636. * @returns - boolean indicating that the submesh is ready or not.
  57637. */
  57638. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57639. /**
  57640. * Checks to see if a texture is used in the material.
  57641. * @param defines the list of "defines" to update.
  57642. * @param scene defines the scene the material belongs to.
  57643. */
  57644. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57645. /**
  57646. * Binds the material data.
  57647. * @param uniformBuffer defines the Uniform buffer to fill in.
  57648. * @param scene defines the scene the material belongs to.
  57649. * @param isFrozen defines wether the material is frozen or not.
  57650. */
  57651. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57652. /**
  57653. * Checks to see if a texture is used in the material.
  57654. * @param texture - Base texture to use.
  57655. * @returns - Boolean specifying if a texture is used in the material.
  57656. */
  57657. hasTexture(texture: BaseTexture): boolean;
  57658. /**
  57659. * Returns an array of the actively used textures.
  57660. * @param activeTextures Array of BaseTextures
  57661. */
  57662. getActiveTextures(activeTextures: BaseTexture[]): void;
  57663. /**
  57664. * Returns the animatable textures.
  57665. * @param animatables Array of animatable textures.
  57666. */
  57667. getAnimatables(animatables: IAnimatable[]): void;
  57668. /**
  57669. * Disposes the resources of the material.
  57670. * @param forceDisposeTextures - Forces the disposal of all textures.
  57671. */
  57672. dispose(forceDisposeTextures?: boolean): void;
  57673. /**
  57674. * Get the current class name of the texture useful for serialization or dynamic coding.
  57675. * @returns "PBRSheenConfiguration"
  57676. */
  57677. getClassName(): string;
  57678. /**
  57679. * Add fallbacks to the effect fallbacks list.
  57680. * @param defines defines the Base texture to use.
  57681. * @param fallbacks defines the current fallback list.
  57682. * @param currentRank defines the current fallback rank.
  57683. * @returns the new fallback rank.
  57684. */
  57685. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57686. /**
  57687. * Add the required uniforms to the current list.
  57688. * @param uniforms defines the current uniform list.
  57689. */
  57690. static AddUniforms(uniforms: string[]): void;
  57691. /**
  57692. * Add the required uniforms to the current buffer.
  57693. * @param uniformBuffer defines the current uniform buffer.
  57694. */
  57695. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57696. /**
  57697. * Add the required samplers to the current list.
  57698. * @param samplers defines the current sampler list.
  57699. */
  57700. static AddSamplers(samplers: string[]): void;
  57701. /**
  57702. * Makes a duplicate of the current configuration into another one.
  57703. * @param sheenConfiguration define the config where to copy the info
  57704. */
  57705. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57706. /**
  57707. * Serializes this BRDF configuration.
  57708. * @returns - An object with the serialized config.
  57709. */
  57710. serialize(): any;
  57711. /**
  57712. * Parses a anisotropy Configuration from a serialized object.
  57713. * @param source - Serialized object.
  57714. * @param scene Defines the scene we are parsing for
  57715. * @param rootUrl Defines the rootUrl to load from
  57716. */
  57717. parse(source: any, scene: Scene, rootUrl: string): void;
  57718. }
  57719. }
  57720. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57721. import { Nullable } from "babylonjs/types";
  57722. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57723. import { Color3 } from "babylonjs/Maths/math.color";
  57724. import { SmartArray } from "babylonjs/Misc/smartArray";
  57725. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57726. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57727. import { Effect } from "babylonjs/Materials/effect";
  57728. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57729. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57730. import { Engine } from "babylonjs/Engines/engine";
  57731. import { Scene } from "babylonjs/scene";
  57732. /**
  57733. * @hidden
  57734. */
  57735. export interface IMaterialSubSurfaceDefines {
  57736. SUBSURFACE: boolean;
  57737. SS_REFRACTION: boolean;
  57738. SS_TRANSLUCENCY: boolean;
  57739. SS_SCATTERING: boolean;
  57740. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57741. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57742. SS_REFRACTIONMAP_3D: boolean;
  57743. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57744. SS_LODINREFRACTIONALPHA: boolean;
  57745. SS_GAMMAREFRACTION: boolean;
  57746. SS_RGBDREFRACTION: boolean;
  57747. SS_LINEARSPECULARREFRACTION: boolean;
  57748. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57749. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57750. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57751. /** @hidden */
  57752. _areTexturesDirty: boolean;
  57753. }
  57754. /**
  57755. * Define the code related to the sub surface parameters of the pbr material.
  57756. */
  57757. export class PBRSubSurfaceConfiguration {
  57758. private _isRefractionEnabled;
  57759. /**
  57760. * Defines if the refraction is enabled in the material.
  57761. */
  57762. isRefractionEnabled: boolean;
  57763. private _isTranslucencyEnabled;
  57764. /**
  57765. * Defines if the translucency is enabled in the material.
  57766. */
  57767. isTranslucencyEnabled: boolean;
  57768. private _isScatteringEnabled;
  57769. /**
  57770. * Defines if the sub surface scattering is enabled in the material.
  57771. */
  57772. isScatteringEnabled: boolean;
  57773. private _scatteringDiffusionProfileIndex;
  57774. /**
  57775. * Diffusion profile for subsurface scattering.
  57776. * Useful for better scattering in the skins or foliages.
  57777. */
  57778. get scatteringDiffusionProfile(): Nullable<Color3>;
  57779. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57780. /**
  57781. * Defines the refraction intensity of the material.
  57782. * The refraction when enabled replaces the Diffuse part of the material.
  57783. * The intensity helps transitionning between diffuse and refraction.
  57784. */
  57785. refractionIntensity: number;
  57786. /**
  57787. * Defines the translucency intensity of the material.
  57788. * When translucency has been enabled, this defines how much of the "translucency"
  57789. * is addded to the diffuse part of the material.
  57790. */
  57791. translucencyIntensity: number;
  57792. /**
  57793. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57794. */
  57795. useAlbedoToTintRefraction: boolean;
  57796. private _thicknessTexture;
  57797. /**
  57798. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57799. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57800. * 0 would mean minimumThickness
  57801. * 1 would mean maximumThickness
  57802. * The other channels might be use as a mask to vary the different effects intensity.
  57803. */
  57804. thicknessTexture: Nullable<BaseTexture>;
  57805. private _refractionTexture;
  57806. /**
  57807. * Defines the texture to use for refraction.
  57808. */
  57809. refractionTexture: Nullable<BaseTexture>;
  57810. private _indexOfRefraction;
  57811. /**
  57812. * Index of refraction of the material base layer.
  57813. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57814. *
  57815. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57816. *
  57817. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57818. */
  57819. indexOfRefraction: number;
  57820. private _volumeIndexOfRefraction;
  57821. /**
  57822. * Index of refraction of the material's volume.
  57823. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57824. *
  57825. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57826. * the volume will use the same IOR as the surface.
  57827. */
  57828. get volumeIndexOfRefraction(): number;
  57829. set volumeIndexOfRefraction(value: number);
  57830. private _invertRefractionY;
  57831. /**
  57832. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57833. */
  57834. invertRefractionY: boolean;
  57835. private _linkRefractionWithTransparency;
  57836. /**
  57837. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57838. * Materials half opaque for instance using refraction could benefit from this control.
  57839. */
  57840. linkRefractionWithTransparency: boolean;
  57841. /**
  57842. * Defines the minimum thickness stored in the thickness map.
  57843. * If no thickness map is defined, this value will be used to simulate thickness.
  57844. */
  57845. minimumThickness: number;
  57846. /**
  57847. * Defines the maximum thickness stored in the thickness map.
  57848. */
  57849. maximumThickness: number;
  57850. /**
  57851. * Defines the volume tint of the material.
  57852. * This is used for both translucency and scattering.
  57853. */
  57854. tintColor: Color3;
  57855. /**
  57856. * Defines the distance at which the tint color should be found in the media.
  57857. * This is used for refraction only.
  57858. */
  57859. tintColorAtDistance: number;
  57860. /**
  57861. * Defines how far each channel transmit through the media.
  57862. * It is defined as a color to simplify it selection.
  57863. */
  57864. diffusionDistance: Color3;
  57865. private _useMaskFromThicknessTexture;
  57866. /**
  57867. * Stores the intensity of the different subsurface effects in the thickness texture.
  57868. * * the green channel is the translucency intensity.
  57869. * * the blue channel is the scattering intensity.
  57870. * * the alpha channel is the refraction intensity.
  57871. */
  57872. useMaskFromThicknessTexture: boolean;
  57873. private _scene;
  57874. /** @hidden */
  57875. private _internalMarkAllSubMeshesAsTexturesDirty;
  57876. private _internalMarkScenePrePassDirty;
  57877. /** @hidden */
  57878. _markAllSubMeshesAsTexturesDirty(): void;
  57879. /** @hidden */
  57880. _markScenePrePassDirty(): void;
  57881. /**
  57882. * Instantiate a new istance of sub surface configuration.
  57883. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57884. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57885. * @param scene The scene
  57886. */
  57887. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57888. /**
  57889. * Gets wehter the submesh is ready to be used or not.
  57890. * @param defines the list of "defines" to update.
  57891. * @param scene defines the scene the material belongs to.
  57892. * @returns - boolean indicating that the submesh is ready or not.
  57893. */
  57894. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57895. /**
  57896. * Checks to see if a texture is used in the material.
  57897. * @param defines the list of "defines" to update.
  57898. * @param scene defines the scene to the material belongs to.
  57899. */
  57900. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57901. /**
  57902. * Binds the material data.
  57903. * @param uniformBuffer defines the Uniform buffer to fill in.
  57904. * @param scene defines the scene the material belongs to.
  57905. * @param engine defines the engine the material belongs to.
  57906. * @param isFrozen defines whether the material is frozen or not.
  57907. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57908. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57909. */
  57910. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57911. /**
  57912. * Unbinds the material from the mesh.
  57913. * @param activeEffect defines the effect that should be unbound from.
  57914. * @returns true if unbound, otherwise false
  57915. */
  57916. unbind(activeEffect: Effect): boolean;
  57917. /**
  57918. * Returns the texture used for refraction or null if none is used.
  57919. * @param scene defines the scene the material belongs to.
  57920. * @returns - Refraction texture if present. If no refraction texture and refraction
  57921. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57922. */
  57923. private _getRefractionTexture;
  57924. /**
  57925. * Returns true if alpha blending should be disabled.
  57926. */
  57927. get disableAlphaBlending(): boolean;
  57928. /**
  57929. * Fills the list of render target textures.
  57930. * @param renderTargets the list of render targets to update
  57931. */
  57932. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57933. /**
  57934. * Checks to see if a texture is used in the material.
  57935. * @param texture - Base texture to use.
  57936. * @returns - Boolean specifying if a texture is used in the material.
  57937. */
  57938. hasTexture(texture: BaseTexture): boolean;
  57939. /**
  57940. * Gets a boolean indicating that current material needs to register RTT
  57941. * @returns true if this uses a render target otherwise false.
  57942. */
  57943. hasRenderTargetTextures(): boolean;
  57944. /**
  57945. * Returns an array of the actively used textures.
  57946. * @param activeTextures Array of BaseTextures
  57947. */
  57948. getActiveTextures(activeTextures: BaseTexture[]): void;
  57949. /**
  57950. * Returns the animatable textures.
  57951. * @param animatables Array of animatable textures.
  57952. */
  57953. getAnimatables(animatables: IAnimatable[]): void;
  57954. /**
  57955. * Disposes the resources of the material.
  57956. * @param forceDisposeTextures - Forces the disposal of all textures.
  57957. */
  57958. dispose(forceDisposeTextures?: boolean): void;
  57959. /**
  57960. * Get the current class name of the texture useful for serialization or dynamic coding.
  57961. * @returns "PBRSubSurfaceConfiguration"
  57962. */
  57963. getClassName(): string;
  57964. /**
  57965. * Add fallbacks to the effect fallbacks list.
  57966. * @param defines defines the Base texture to use.
  57967. * @param fallbacks defines the current fallback list.
  57968. * @param currentRank defines the current fallback rank.
  57969. * @returns the new fallback rank.
  57970. */
  57971. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57972. /**
  57973. * Add the required uniforms to the current list.
  57974. * @param uniforms defines the current uniform list.
  57975. */
  57976. static AddUniforms(uniforms: string[]): void;
  57977. /**
  57978. * Add the required samplers to the current list.
  57979. * @param samplers defines the current sampler list.
  57980. */
  57981. static AddSamplers(samplers: string[]): void;
  57982. /**
  57983. * Add the required uniforms to the current buffer.
  57984. * @param uniformBuffer defines the current uniform buffer.
  57985. */
  57986. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57987. /**
  57988. * Makes a duplicate of the current configuration into another one.
  57989. * @param configuration define the config where to copy the info
  57990. */
  57991. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57992. /**
  57993. * Serializes this Sub Surface configuration.
  57994. * @returns - An object with the serialized config.
  57995. */
  57996. serialize(): any;
  57997. /**
  57998. * Parses a anisotropy Configuration from a serialized object.
  57999. * @param source - Serialized object.
  58000. * @param scene Defines the scene we are parsing for
  58001. * @param rootUrl Defines the rootUrl to load from
  58002. */
  58003. parse(source: any, scene: Scene, rootUrl: string): void;
  58004. }
  58005. }
  58006. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58007. /** @hidden */
  58008. export var pbrFragmentDeclaration: {
  58009. name: string;
  58010. shader: string;
  58011. };
  58012. }
  58013. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58014. /** @hidden */
  58015. export var pbrUboDeclaration: {
  58016. name: string;
  58017. shader: string;
  58018. };
  58019. }
  58020. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58021. /** @hidden */
  58022. export var pbrFragmentExtraDeclaration: {
  58023. name: string;
  58024. shader: string;
  58025. };
  58026. }
  58027. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58028. /** @hidden */
  58029. export var pbrFragmentSamplersDeclaration: {
  58030. name: string;
  58031. shader: string;
  58032. };
  58033. }
  58034. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58035. /** @hidden */
  58036. export var importanceSampling: {
  58037. name: string;
  58038. shader: string;
  58039. };
  58040. }
  58041. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58042. /** @hidden */
  58043. export var pbrHelperFunctions: {
  58044. name: string;
  58045. shader: string;
  58046. };
  58047. }
  58048. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58049. /** @hidden */
  58050. export var harmonicsFunctions: {
  58051. name: string;
  58052. shader: string;
  58053. };
  58054. }
  58055. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58056. /** @hidden */
  58057. export var pbrDirectLightingSetupFunctions: {
  58058. name: string;
  58059. shader: string;
  58060. };
  58061. }
  58062. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58063. /** @hidden */
  58064. export var pbrDirectLightingFalloffFunctions: {
  58065. name: string;
  58066. shader: string;
  58067. };
  58068. }
  58069. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58070. /** @hidden */
  58071. export var pbrBRDFFunctions: {
  58072. name: string;
  58073. shader: string;
  58074. };
  58075. }
  58076. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58077. /** @hidden */
  58078. export var hdrFilteringFunctions: {
  58079. name: string;
  58080. shader: string;
  58081. };
  58082. }
  58083. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58084. /** @hidden */
  58085. export var pbrDirectLightingFunctions: {
  58086. name: string;
  58087. shader: string;
  58088. };
  58089. }
  58090. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58091. /** @hidden */
  58092. export var pbrIBLFunctions: {
  58093. name: string;
  58094. shader: string;
  58095. };
  58096. }
  58097. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58098. /** @hidden */
  58099. export var pbrBlockAlbedoOpacity: {
  58100. name: string;
  58101. shader: string;
  58102. };
  58103. }
  58104. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58105. /** @hidden */
  58106. export var pbrBlockReflectivity: {
  58107. name: string;
  58108. shader: string;
  58109. };
  58110. }
  58111. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58112. /** @hidden */
  58113. export var pbrBlockAmbientOcclusion: {
  58114. name: string;
  58115. shader: string;
  58116. };
  58117. }
  58118. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58119. /** @hidden */
  58120. export var pbrBlockAlphaFresnel: {
  58121. name: string;
  58122. shader: string;
  58123. };
  58124. }
  58125. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58126. /** @hidden */
  58127. export var pbrBlockAnisotropic: {
  58128. name: string;
  58129. shader: string;
  58130. };
  58131. }
  58132. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58133. /** @hidden */
  58134. export var pbrBlockReflection: {
  58135. name: string;
  58136. shader: string;
  58137. };
  58138. }
  58139. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58140. /** @hidden */
  58141. export var pbrBlockSheen: {
  58142. name: string;
  58143. shader: string;
  58144. };
  58145. }
  58146. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58147. /** @hidden */
  58148. export var pbrBlockClearcoat: {
  58149. name: string;
  58150. shader: string;
  58151. };
  58152. }
  58153. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58154. /** @hidden */
  58155. export var pbrBlockSubSurface: {
  58156. name: string;
  58157. shader: string;
  58158. };
  58159. }
  58160. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58161. /** @hidden */
  58162. export var pbrBlockNormalGeometric: {
  58163. name: string;
  58164. shader: string;
  58165. };
  58166. }
  58167. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58168. /** @hidden */
  58169. export var pbrBlockNormalFinal: {
  58170. name: string;
  58171. shader: string;
  58172. };
  58173. }
  58174. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58175. /** @hidden */
  58176. export var pbrBlockLightmapInit: {
  58177. name: string;
  58178. shader: string;
  58179. };
  58180. }
  58181. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58182. /** @hidden */
  58183. export var pbrBlockGeometryInfo: {
  58184. name: string;
  58185. shader: string;
  58186. };
  58187. }
  58188. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58189. /** @hidden */
  58190. export var pbrBlockReflectance0: {
  58191. name: string;
  58192. shader: string;
  58193. };
  58194. }
  58195. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58196. /** @hidden */
  58197. export var pbrBlockReflectance: {
  58198. name: string;
  58199. shader: string;
  58200. };
  58201. }
  58202. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58203. /** @hidden */
  58204. export var pbrBlockDirectLighting: {
  58205. name: string;
  58206. shader: string;
  58207. };
  58208. }
  58209. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58210. /** @hidden */
  58211. export var pbrBlockFinalLitComponents: {
  58212. name: string;
  58213. shader: string;
  58214. };
  58215. }
  58216. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58217. /** @hidden */
  58218. export var pbrBlockFinalUnlitComponents: {
  58219. name: string;
  58220. shader: string;
  58221. };
  58222. }
  58223. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58224. /** @hidden */
  58225. export var pbrBlockFinalColorComposition: {
  58226. name: string;
  58227. shader: string;
  58228. };
  58229. }
  58230. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58231. /** @hidden */
  58232. export var pbrBlockImageProcessing: {
  58233. name: string;
  58234. shader: string;
  58235. };
  58236. }
  58237. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58238. /** @hidden */
  58239. export var pbrDebug: {
  58240. name: string;
  58241. shader: string;
  58242. };
  58243. }
  58244. declare module "babylonjs/Shaders/pbr.fragment" {
  58245. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58246. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58247. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58248. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58249. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58250. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58251. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58252. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58253. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58254. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58255. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58256. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58257. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58258. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58259. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58260. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58261. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58262. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58263. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58264. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58265. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58266. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58267. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58268. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58269. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58270. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58271. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58272. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58273. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58274. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58275. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58276. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58277. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58278. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58279. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58280. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58281. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58282. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58283. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58284. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58285. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58286. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58287. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58288. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58289. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58290. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58291. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58292. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58293. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58294. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58295. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58296. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58297. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58298. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58299. /** @hidden */
  58300. export var pbrPixelShader: {
  58301. name: string;
  58302. shader: string;
  58303. };
  58304. }
  58305. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58306. /** @hidden */
  58307. export var pbrVertexDeclaration: {
  58308. name: string;
  58309. shader: string;
  58310. };
  58311. }
  58312. declare module "babylonjs/Shaders/pbr.vertex" {
  58313. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58314. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58315. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58316. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58317. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58318. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58319. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58320. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58321. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58322. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58323. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58324. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58326. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58328. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58330. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58331. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58332. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58333. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58334. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58335. /** @hidden */
  58336. export var pbrVertexShader: {
  58337. name: string;
  58338. shader: string;
  58339. };
  58340. }
  58341. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58342. import { Nullable } from "babylonjs/types";
  58343. import { Scene } from "babylonjs/scene";
  58344. import { Matrix } from "babylonjs/Maths/math.vector";
  58345. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58347. import { Mesh } from "babylonjs/Meshes/mesh";
  58348. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58349. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58350. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58351. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58352. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58353. import { Color3 } from "babylonjs/Maths/math.color";
  58354. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58355. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58356. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58357. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58359. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58360. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58361. import "babylonjs/Shaders/pbr.fragment";
  58362. import "babylonjs/Shaders/pbr.vertex";
  58363. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58364. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58365. /**
  58366. * Manages the defines for the PBR Material.
  58367. * @hidden
  58368. */
  58369. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58370. PBR: boolean;
  58371. NUM_SAMPLES: string;
  58372. REALTIME_FILTERING: boolean;
  58373. MAINUV1: boolean;
  58374. MAINUV2: boolean;
  58375. UV1: boolean;
  58376. UV2: boolean;
  58377. ALBEDO: boolean;
  58378. GAMMAALBEDO: boolean;
  58379. ALBEDODIRECTUV: number;
  58380. VERTEXCOLOR: boolean;
  58381. DETAIL: boolean;
  58382. DETAILDIRECTUV: number;
  58383. DETAIL_NORMALBLENDMETHOD: number;
  58384. AMBIENT: boolean;
  58385. AMBIENTDIRECTUV: number;
  58386. AMBIENTINGRAYSCALE: boolean;
  58387. OPACITY: boolean;
  58388. VERTEXALPHA: boolean;
  58389. OPACITYDIRECTUV: number;
  58390. OPACITYRGB: boolean;
  58391. ALPHATEST: boolean;
  58392. DEPTHPREPASS: boolean;
  58393. ALPHABLEND: boolean;
  58394. ALPHAFROMALBEDO: boolean;
  58395. ALPHATESTVALUE: string;
  58396. SPECULAROVERALPHA: boolean;
  58397. RADIANCEOVERALPHA: boolean;
  58398. ALPHAFRESNEL: boolean;
  58399. LINEARALPHAFRESNEL: boolean;
  58400. PREMULTIPLYALPHA: boolean;
  58401. EMISSIVE: boolean;
  58402. EMISSIVEDIRECTUV: number;
  58403. REFLECTIVITY: boolean;
  58404. REFLECTIVITYDIRECTUV: number;
  58405. SPECULARTERM: boolean;
  58406. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58407. MICROSURFACEAUTOMATIC: boolean;
  58408. LODBASEDMICROSFURACE: boolean;
  58409. MICROSURFACEMAP: boolean;
  58410. MICROSURFACEMAPDIRECTUV: number;
  58411. METALLICWORKFLOW: boolean;
  58412. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58413. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58414. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58415. AOSTOREINMETALMAPRED: boolean;
  58416. METALLIC_REFLECTANCE: boolean;
  58417. METALLIC_REFLECTANCEDIRECTUV: number;
  58418. ENVIRONMENTBRDF: boolean;
  58419. ENVIRONMENTBRDF_RGBD: boolean;
  58420. NORMAL: boolean;
  58421. TANGENT: boolean;
  58422. BUMP: boolean;
  58423. BUMPDIRECTUV: number;
  58424. OBJECTSPACE_NORMALMAP: boolean;
  58425. PARALLAX: boolean;
  58426. PARALLAXOCCLUSION: boolean;
  58427. NORMALXYSCALE: boolean;
  58428. LIGHTMAP: boolean;
  58429. LIGHTMAPDIRECTUV: number;
  58430. USELIGHTMAPASSHADOWMAP: boolean;
  58431. GAMMALIGHTMAP: boolean;
  58432. RGBDLIGHTMAP: boolean;
  58433. REFLECTION: boolean;
  58434. REFLECTIONMAP_3D: boolean;
  58435. REFLECTIONMAP_SPHERICAL: boolean;
  58436. REFLECTIONMAP_PLANAR: boolean;
  58437. REFLECTIONMAP_CUBIC: boolean;
  58438. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58439. REFLECTIONMAP_PROJECTION: boolean;
  58440. REFLECTIONMAP_SKYBOX: boolean;
  58441. REFLECTIONMAP_EXPLICIT: boolean;
  58442. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58443. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58444. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58445. INVERTCUBICMAP: boolean;
  58446. USESPHERICALFROMREFLECTIONMAP: boolean;
  58447. USEIRRADIANCEMAP: boolean;
  58448. SPHERICAL_HARMONICS: boolean;
  58449. USESPHERICALINVERTEX: boolean;
  58450. REFLECTIONMAP_OPPOSITEZ: boolean;
  58451. LODINREFLECTIONALPHA: boolean;
  58452. GAMMAREFLECTION: boolean;
  58453. RGBDREFLECTION: boolean;
  58454. LINEARSPECULARREFLECTION: boolean;
  58455. RADIANCEOCCLUSION: boolean;
  58456. HORIZONOCCLUSION: boolean;
  58457. INSTANCES: boolean;
  58458. THIN_INSTANCES: boolean;
  58459. PREPASS: boolean;
  58460. SCENE_MRT_COUNT: number;
  58461. NUM_BONE_INFLUENCERS: number;
  58462. BonesPerMesh: number;
  58463. BONETEXTURE: boolean;
  58464. NONUNIFORMSCALING: boolean;
  58465. MORPHTARGETS: boolean;
  58466. MORPHTARGETS_NORMAL: boolean;
  58467. MORPHTARGETS_TANGENT: boolean;
  58468. MORPHTARGETS_UV: boolean;
  58469. NUM_MORPH_INFLUENCERS: number;
  58470. IMAGEPROCESSING: boolean;
  58471. VIGNETTE: boolean;
  58472. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58473. VIGNETTEBLENDMODEOPAQUE: boolean;
  58474. TONEMAPPING: boolean;
  58475. TONEMAPPING_ACES: boolean;
  58476. CONTRAST: boolean;
  58477. COLORCURVES: boolean;
  58478. COLORGRADING: boolean;
  58479. COLORGRADING3D: boolean;
  58480. SAMPLER3DGREENDEPTH: boolean;
  58481. SAMPLER3DBGRMAP: boolean;
  58482. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58483. EXPOSURE: boolean;
  58484. MULTIVIEW: boolean;
  58485. USEPHYSICALLIGHTFALLOFF: boolean;
  58486. USEGLTFLIGHTFALLOFF: boolean;
  58487. TWOSIDEDLIGHTING: boolean;
  58488. SHADOWFLOAT: boolean;
  58489. CLIPPLANE: boolean;
  58490. CLIPPLANE2: boolean;
  58491. CLIPPLANE3: boolean;
  58492. CLIPPLANE4: boolean;
  58493. CLIPPLANE5: boolean;
  58494. CLIPPLANE6: boolean;
  58495. POINTSIZE: boolean;
  58496. FOG: boolean;
  58497. LOGARITHMICDEPTH: boolean;
  58498. FORCENORMALFORWARD: boolean;
  58499. SPECULARAA: boolean;
  58500. CLEARCOAT: boolean;
  58501. CLEARCOAT_DEFAULTIOR: boolean;
  58502. CLEARCOAT_TEXTURE: boolean;
  58503. CLEARCOAT_TEXTUREDIRECTUV: number;
  58504. CLEARCOAT_BUMP: boolean;
  58505. CLEARCOAT_BUMPDIRECTUV: number;
  58506. CLEARCOAT_TINT: boolean;
  58507. CLEARCOAT_TINT_TEXTURE: boolean;
  58508. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58509. ANISOTROPIC: boolean;
  58510. ANISOTROPIC_TEXTURE: boolean;
  58511. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58512. BRDF_V_HEIGHT_CORRELATED: boolean;
  58513. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58514. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58515. SHEEN: boolean;
  58516. SHEEN_TEXTURE: boolean;
  58517. SHEEN_TEXTUREDIRECTUV: number;
  58518. SHEEN_LINKWITHALBEDO: boolean;
  58519. SHEEN_ROUGHNESS: boolean;
  58520. SHEEN_ALBEDOSCALING: boolean;
  58521. SUBSURFACE: boolean;
  58522. SS_REFRACTION: boolean;
  58523. SS_TRANSLUCENCY: boolean;
  58524. SS_SCATTERING: boolean;
  58525. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58526. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58527. SS_REFRACTIONMAP_3D: boolean;
  58528. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58529. SS_LODINREFRACTIONALPHA: boolean;
  58530. SS_GAMMAREFRACTION: boolean;
  58531. SS_RGBDREFRACTION: boolean;
  58532. SS_LINEARSPECULARREFRACTION: boolean;
  58533. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58534. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58535. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58536. UNLIT: boolean;
  58537. DEBUGMODE: number;
  58538. /**
  58539. * Initializes the PBR Material defines.
  58540. */
  58541. constructor();
  58542. /**
  58543. * Resets the PBR Material defines.
  58544. */
  58545. reset(): void;
  58546. }
  58547. /**
  58548. * The Physically based material base class of BJS.
  58549. *
  58550. * This offers the main features of a standard PBR material.
  58551. * For more information, please refer to the documentation :
  58552. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58553. */
  58554. export abstract class PBRBaseMaterial extends PushMaterial {
  58555. /**
  58556. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58557. */
  58558. static readonly PBRMATERIAL_OPAQUE: number;
  58559. /**
  58560. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58561. */
  58562. static readonly PBRMATERIAL_ALPHATEST: number;
  58563. /**
  58564. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58565. */
  58566. static readonly PBRMATERIAL_ALPHABLEND: number;
  58567. /**
  58568. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58569. * They are also discarded below the alpha cutoff threshold to improve performances.
  58570. */
  58571. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58572. /**
  58573. * Defines the default value of how much AO map is occluding the analytical lights
  58574. * (point spot...).
  58575. */
  58576. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58577. /**
  58578. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58579. */
  58580. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58581. /**
  58582. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58583. * to enhance interoperability with other engines.
  58584. */
  58585. static readonly LIGHTFALLOFF_GLTF: number;
  58586. /**
  58587. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58588. * to enhance interoperability with other materials.
  58589. */
  58590. static readonly LIGHTFALLOFF_STANDARD: number;
  58591. /**
  58592. * Intensity of the direct lights e.g. the four lights available in your scene.
  58593. * This impacts both the direct diffuse and specular highlights.
  58594. */
  58595. protected _directIntensity: number;
  58596. /**
  58597. * Intensity of the emissive part of the material.
  58598. * This helps controlling the emissive effect without modifying the emissive color.
  58599. */
  58600. protected _emissiveIntensity: number;
  58601. /**
  58602. * Intensity of the environment e.g. how much the environment will light the object
  58603. * either through harmonics for rough material or through the refelction for shiny ones.
  58604. */
  58605. protected _environmentIntensity: number;
  58606. /**
  58607. * This is a special control allowing the reduction of the specular highlights coming from the
  58608. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58609. */
  58610. protected _specularIntensity: number;
  58611. /**
  58612. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58613. */
  58614. private _lightingInfos;
  58615. /**
  58616. * Debug Control allowing disabling the bump map on this material.
  58617. */
  58618. protected _disableBumpMap: boolean;
  58619. /**
  58620. * AKA Diffuse Texture in standard nomenclature.
  58621. */
  58622. protected _albedoTexture: Nullable<BaseTexture>;
  58623. /**
  58624. * AKA Occlusion Texture in other nomenclature.
  58625. */
  58626. protected _ambientTexture: Nullable<BaseTexture>;
  58627. /**
  58628. * AKA Occlusion Texture Intensity in other nomenclature.
  58629. */
  58630. protected _ambientTextureStrength: number;
  58631. /**
  58632. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58633. * 1 means it completely occludes it
  58634. * 0 mean it has no impact
  58635. */
  58636. protected _ambientTextureImpactOnAnalyticalLights: number;
  58637. /**
  58638. * Stores the alpha values in a texture.
  58639. */
  58640. protected _opacityTexture: Nullable<BaseTexture>;
  58641. /**
  58642. * Stores the reflection values in a texture.
  58643. */
  58644. protected _reflectionTexture: Nullable<BaseTexture>;
  58645. /**
  58646. * Stores the emissive values in a texture.
  58647. */
  58648. protected _emissiveTexture: Nullable<BaseTexture>;
  58649. /**
  58650. * AKA Specular texture in other nomenclature.
  58651. */
  58652. protected _reflectivityTexture: Nullable<BaseTexture>;
  58653. /**
  58654. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58655. */
  58656. protected _metallicTexture: Nullable<BaseTexture>;
  58657. /**
  58658. * Specifies the metallic scalar of the metallic/roughness workflow.
  58659. * Can also be used to scale the metalness values of the metallic texture.
  58660. */
  58661. protected _metallic: Nullable<number>;
  58662. /**
  58663. * Specifies the roughness scalar of the metallic/roughness workflow.
  58664. * Can also be used to scale the roughness values of the metallic texture.
  58665. */
  58666. protected _roughness: Nullable<number>;
  58667. /**
  58668. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58669. * By default the indexOfrefraction is used to compute F0;
  58670. *
  58671. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58672. *
  58673. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58674. * F90 = metallicReflectanceColor;
  58675. */
  58676. protected _metallicF0Factor: number;
  58677. /**
  58678. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58679. * By default the F90 is always 1;
  58680. *
  58681. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58682. *
  58683. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58684. * F90 = metallicReflectanceColor;
  58685. */
  58686. protected _metallicReflectanceColor: Color3;
  58687. /**
  58688. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58689. * This is multiply against the scalar values defined in the material.
  58690. */
  58691. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58692. /**
  58693. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58694. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58695. */
  58696. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58697. /**
  58698. * Stores surface normal data used to displace a mesh in a texture.
  58699. */
  58700. protected _bumpTexture: Nullable<BaseTexture>;
  58701. /**
  58702. * Stores the pre-calculated light information of a mesh in a texture.
  58703. */
  58704. protected _lightmapTexture: Nullable<BaseTexture>;
  58705. /**
  58706. * The color of a material in ambient lighting.
  58707. */
  58708. protected _ambientColor: Color3;
  58709. /**
  58710. * AKA Diffuse Color in other nomenclature.
  58711. */
  58712. protected _albedoColor: Color3;
  58713. /**
  58714. * AKA Specular Color in other nomenclature.
  58715. */
  58716. protected _reflectivityColor: Color3;
  58717. /**
  58718. * The color applied when light is reflected from a material.
  58719. */
  58720. protected _reflectionColor: Color3;
  58721. /**
  58722. * The color applied when light is emitted from a material.
  58723. */
  58724. protected _emissiveColor: Color3;
  58725. /**
  58726. * AKA Glossiness in other nomenclature.
  58727. */
  58728. protected _microSurface: number;
  58729. /**
  58730. * Specifies that the material will use the light map as a show map.
  58731. */
  58732. protected _useLightmapAsShadowmap: boolean;
  58733. /**
  58734. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58735. * makes the reflect vector face the model (under horizon).
  58736. */
  58737. protected _useHorizonOcclusion: boolean;
  58738. /**
  58739. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58740. * too much the area relying on ambient texture to define their ambient occlusion.
  58741. */
  58742. protected _useRadianceOcclusion: boolean;
  58743. /**
  58744. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58745. */
  58746. protected _useAlphaFromAlbedoTexture: boolean;
  58747. /**
  58748. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58749. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58750. */
  58751. protected _useSpecularOverAlpha: boolean;
  58752. /**
  58753. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58754. */
  58755. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58756. /**
  58757. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58758. */
  58759. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58760. /**
  58761. * Specifies if the metallic texture contains the roughness information in its green channel.
  58762. */
  58763. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58764. /**
  58765. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58766. */
  58767. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58768. /**
  58769. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58770. */
  58771. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58772. /**
  58773. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58774. */
  58775. protected _useAmbientInGrayScale: boolean;
  58776. /**
  58777. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58778. * The material will try to infer what glossiness each pixel should be.
  58779. */
  58780. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58781. /**
  58782. * Defines the falloff type used in this material.
  58783. * It by default is Physical.
  58784. */
  58785. protected _lightFalloff: number;
  58786. /**
  58787. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58788. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58789. */
  58790. protected _useRadianceOverAlpha: boolean;
  58791. /**
  58792. * Allows using an object space normal map (instead of tangent space).
  58793. */
  58794. protected _useObjectSpaceNormalMap: boolean;
  58795. /**
  58796. * Allows using the bump map in parallax mode.
  58797. */
  58798. protected _useParallax: boolean;
  58799. /**
  58800. * Allows using the bump map in parallax occlusion mode.
  58801. */
  58802. protected _useParallaxOcclusion: boolean;
  58803. /**
  58804. * Controls the scale bias of the parallax mode.
  58805. */
  58806. protected _parallaxScaleBias: number;
  58807. /**
  58808. * If sets to true, disables all the lights affecting the material.
  58809. */
  58810. protected _disableLighting: boolean;
  58811. /**
  58812. * Number of Simultaneous lights allowed on the material.
  58813. */
  58814. protected _maxSimultaneousLights: number;
  58815. /**
  58816. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58817. */
  58818. protected _invertNormalMapX: boolean;
  58819. /**
  58820. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58821. */
  58822. protected _invertNormalMapY: boolean;
  58823. /**
  58824. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58825. */
  58826. protected _twoSidedLighting: boolean;
  58827. /**
  58828. * Defines the alpha limits in alpha test mode.
  58829. */
  58830. protected _alphaCutOff: number;
  58831. /**
  58832. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58833. */
  58834. protected _forceAlphaTest: 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 is converted to gamma to compute the fresnel)
  58838. */
  58839. protected _useAlphaFresnel: boolean;
  58840. /**
  58841. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58842. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58843. */
  58844. protected _useLinearAlphaFresnel: boolean;
  58845. /**
  58846. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58847. * from cos thetav and roughness:
  58848. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58849. */
  58850. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58851. /**
  58852. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58853. */
  58854. protected _forceIrradianceInFragment: boolean;
  58855. private _realTimeFiltering;
  58856. /**
  58857. * Enables realtime filtering on the texture.
  58858. */
  58859. get realTimeFiltering(): boolean;
  58860. set realTimeFiltering(b: boolean);
  58861. private _realTimeFilteringQuality;
  58862. /**
  58863. * Quality switch for realtime filtering
  58864. */
  58865. get realTimeFilteringQuality(): number;
  58866. set realTimeFilteringQuality(n: number);
  58867. /**
  58868. * Can this material render to several textures at once
  58869. */
  58870. get canRenderToMRT(): boolean;
  58871. /**
  58872. * Force normal to face away from face.
  58873. */
  58874. protected _forceNormalForward: boolean;
  58875. /**
  58876. * Enables specular anti aliasing in the PBR shader.
  58877. * It will both interacts on the Geometry for analytical and IBL lighting.
  58878. * It also prefilter the roughness map based on the bump values.
  58879. */
  58880. protected _enableSpecularAntiAliasing: boolean;
  58881. /**
  58882. * Default configuration related to image processing available in the PBR Material.
  58883. */
  58884. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58885. /**
  58886. * Keep track of the image processing observer to allow dispose and replace.
  58887. */
  58888. private _imageProcessingObserver;
  58889. /**
  58890. * Attaches a new image processing configuration to the PBR Material.
  58891. * @param configuration
  58892. */
  58893. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58894. /**
  58895. * Stores the available render targets.
  58896. */
  58897. private _renderTargets;
  58898. /**
  58899. * Sets the global ambient color for the material used in lighting calculations.
  58900. */
  58901. private _globalAmbientColor;
  58902. /**
  58903. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58904. */
  58905. private _useLogarithmicDepth;
  58906. /**
  58907. * If set to true, no lighting calculations will be applied.
  58908. */
  58909. private _unlit;
  58910. private _debugMode;
  58911. /**
  58912. * @hidden
  58913. * This is reserved for the inspector.
  58914. * Defines the material debug mode.
  58915. * It helps seeing only some components of the material while troubleshooting.
  58916. */
  58917. debugMode: number;
  58918. /**
  58919. * @hidden
  58920. * This is reserved for the inspector.
  58921. * Specify from where on screen the debug mode should start.
  58922. * The value goes from -1 (full screen) to 1 (not visible)
  58923. * It helps with side by side comparison against the final render
  58924. * This defaults to -1
  58925. */
  58926. private debugLimit;
  58927. /**
  58928. * @hidden
  58929. * This is reserved for the inspector.
  58930. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58931. * You can use the factor to better multiply the final value.
  58932. */
  58933. private debugFactor;
  58934. /**
  58935. * Defines the clear coat layer parameters for the material.
  58936. */
  58937. readonly clearCoat: PBRClearCoatConfiguration;
  58938. /**
  58939. * Defines the anisotropic parameters for the material.
  58940. */
  58941. readonly anisotropy: PBRAnisotropicConfiguration;
  58942. /**
  58943. * Defines the BRDF parameters for the material.
  58944. */
  58945. readonly brdf: PBRBRDFConfiguration;
  58946. /**
  58947. * Defines the Sheen parameters for the material.
  58948. */
  58949. readonly sheen: PBRSheenConfiguration;
  58950. /**
  58951. * Defines the SubSurface parameters for the material.
  58952. */
  58953. readonly subSurface: PBRSubSurfaceConfiguration;
  58954. /**
  58955. * Defines the detail map parameters for the material.
  58956. */
  58957. readonly detailMap: DetailMapConfiguration;
  58958. protected _rebuildInParallel: boolean;
  58959. /**
  58960. * Instantiates a new PBRMaterial instance.
  58961. *
  58962. * @param name The material name
  58963. * @param scene The scene the material will be use in.
  58964. */
  58965. constructor(name: string, scene: Scene);
  58966. /**
  58967. * Gets a boolean indicating that current material needs to register RTT
  58968. */
  58969. get hasRenderTargetTextures(): boolean;
  58970. /**
  58971. * Gets the name of the material class.
  58972. */
  58973. getClassName(): string;
  58974. /**
  58975. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58976. */
  58977. get useLogarithmicDepth(): boolean;
  58978. /**
  58979. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58980. */
  58981. set useLogarithmicDepth(value: boolean);
  58982. /**
  58983. * Returns true if alpha blending should be disabled.
  58984. */
  58985. protected get _disableAlphaBlending(): boolean;
  58986. /**
  58987. * Specifies whether or not this material should be rendered in alpha blend mode.
  58988. */
  58989. needAlphaBlending(): boolean;
  58990. /**
  58991. * Specifies whether or not this material should be rendered in alpha test mode.
  58992. */
  58993. needAlphaTesting(): boolean;
  58994. /**
  58995. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58996. */
  58997. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58998. /**
  58999. * Gets the texture used for the alpha test.
  59000. */
  59001. getAlphaTestTexture(): Nullable<BaseTexture>;
  59002. /**
  59003. * Specifies that the submesh is ready to be used.
  59004. * @param mesh - BJS mesh.
  59005. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59006. * @param useInstances - Specifies that instances should be used.
  59007. * @returns - boolean indicating that the submesh is ready or not.
  59008. */
  59009. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59010. /**
  59011. * Specifies if the material uses metallic roughness workflow.
  59012. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59013. */
  59014. isMetallicWorkflow(): boolean;
  59015. private _prepareEffect;
  59016. private _prepareDefines;
  59017. /**
  59018. * Force shader compilation
  59019. */
  59020. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59021. /**
  59022. * Initializes the uniform buffer layout for the shader.
  59023. */
  59024. buildUniformLayout(): void;
  59025. /**
  59026. * Unbinds the material from the mesh
  59027. */
  59028. unbind(): void;
  59029. /**
  59030. * Binds the submesh data.
  59031. * @param world - The world matrix.
  59032. * @param mesh - The BJS mesh.
  59033. * @param subMesh - A submesh of the BJS mesh.
  59034. */
  59035. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59036. /**
  59037. * Returns the animatable textures.
  59038. * @returns - Array of animatable textures.
  59039. */
  59040. getAnimatables(): IAnimatable[];
  59041. /**
  59042. * Returns the texture used for reflections.
  59043. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59044. */
  59045. private _getReflectionTexture;
  59046. /**
  59047. * Returns an array of the actively used textures.
  59048. * @returns - Array of BaseTextures
  59049. */
  59050. getActiveTextures(): BaseTexture[];
  59051. /**
  59052. * Checks to see if a texture is used in the material.
  59053. * @param texture - Base texture to use.
  59054. * @returns - Boolean specifying if a texture is used in the material.
  59055. */
  59056. hasTexture(texture: BaseTexture): boolean;
  59057. /**
  59058. * Sets the required values to the prepass renderer.
  59059. * @param prePassRenderer defines the prepass renderer to setup
  59060. */
  59061. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59062. /**
  59063. * Disposes the resources of the material.
  59064. * @param forceDisposeEffect - Forces the disposal of effects.
  59065. * @param forceDisposeTextures - Forces the disposal of all textures.
  59066. */
  59067. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59068. }
  59069. }
  59070. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59071. import { Nullable } from "babylonjs/types";
  59072. import { Scene } from "babylonjs/scene";
  59073. import { Color3 } from "babylonjs/Maths/math.color";
  59074. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59075. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59077. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59078. /**
  59079. * The Physically based material of BJS.
  59080. *
  59081. * This offers the main features of a standard PBR material.
  59082. * For more information, please refer to the documentation :
  59083. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59084. */
  59085. export class PBRMaterial extends PBRBaseMaterial {
  59086. /**
  59087. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59088. */
  59089. static readonly PBRMATERIAL_OPAQUE: number;
  59090. /**
  59091. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59092. */
  59093. static readonly PBRMATERIAL_ALPHATEST: number;
  59094. /**
  59095. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59096. */
  59097. static readonly PBRMATERIAL_ALPHABLEND: number;
  59098. /**
  59099. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59100. * They are also discarded below the alpha cutoff threshold to improve performances.
  59101. */
  59102. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59103. /**
  59104. * Defines the default value of how much AO map is occluding the analytical lights
  59105. * (point spot...).
  59106. */
  59107. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59108. /**
  59109. * Intensity of the direct lights e.g. the four lights available in your scene.
  59110. * This impacts both the direct diffuse and specular highlights.
  59111. */
  59112. directIntensity: number;
  59113. /**
  59114. * Intensity of the emissive part of the material.
  59115. * This helps controlling the emissive effect without modifying the emissive color.
  59116. */
  59117. emissiveIntensity: number;
  59118. /**
  59119. * Intensity of the environment e.g. how much the environment will light the object
  59120. * either through harmonics for rough material or through the refelction for shiny ones.
  59121. */
  59122. environmentIntensity: number;
  59123. /**
  59124. * This is a special control allowing the reduction of the specular highlights coming from the
  59125. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59126. */
  59127. specularIntensity: number;
  59128. /**
  59129. * Debug Control allowing disabling the bump map on this material.
  59130. */
  59131. disableBumpMap: boolean;
  59132. /**
  59133. * AKA Diffuse Texture in standard nomenclature.
  59134. */
  59135. albedoTexture: BaseTexture;
  59136. /**
  59137. * AKA Occlusion Texture in other nomenclature.
  59138. */
  59139. ambientTexture: BaseTexture;
  59140. /**
  59141. * AKA Occlusion Texture Intensity in other nomenclature.
  59142. */
  59143. ambientTextureStrength: number;
  59144. /**
  59145. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59146. * 1 means it completely occludes it
  59147. * 0 mean it has no impact
  59148. */
  59149. ambientTextureImpactOnAnalyticalLights: number;
  59150. /**
  59151. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59152. */
  59153. opacityTexture: BaseTexture;
  59154. /**
  59155. * Stores the reflection values in a texture.
  59156. */
  59157. reflectionTexture: Nullable<BaseTexture>;
  59158. /**
  59159. * Stores the emissive values in a texture.
  59160. */
  59161. emissiveTexture: BaseTexture;
  59162. /**
  59163. * AKA Specular texture in other nomenclature.
  59164. */
  59165. reflectivityTexture: BaseTexture;
  59166. /**
  59167. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59168. */
  59169. metallicTexture: BaseTexture;
  59170. /**
  59171. * Specifies the metallic scalar of the metallic/roughness workflow.
  59172. * Can also be used to scale the metalness values of the metallic texture.
  59173. */
  59174. metallic: Nullable<number>;
  59175. /**
  59176. * Specifies the roughness scalar of the metallic/roughness workflow.
  59177. * Can also be used to scale the roughness values of the metallic texture.
  59178. */
  59179. roughness: Nullable<number>;
  59180. /**
  59181. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59182. * By default the indexOfrefraction is used to compute F0;
  59183. *
  59184. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59185. *
  59186. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59187. * F90 = metallicReflectanceColor;
  59188. */
  59189. metallicF0Factor: number;
  59190. /**
  59191. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59192. * By default the F90 is always 1;
  59193. *
  59194. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59195. *
  59196. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59197. * F90 = metallicReflectanceColor;
  59198. */
  59199. metallicReflectanceColor: Color3;
  59200. /**
  59201. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59202. * This is multiply against the scalar values defined in the material.
  59203. */
  59204. metallicReflectanceTexture: Nullable<BaseTexture>;
  59205. /**
  59206. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59207. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59208. */
  59209. microSurfaceTexture: BaseTexture;
  59210. /**
  59211. * Stores surface normal data used to displace a mesh in a texture.
  59212. */
  59213. bumpTexture: BaseTexture;
  59214. /**
  59215. * Stores the pre-calculated light information of a mesh in a texture.
  59216. */
  59217. lightmapTexture: BaseTexture;
  59218. /**
  59219. * Stores the refracted light information in a texture.
  59220. */
  59221. get refractionTexture(): Nullable<BaseTexture>;
  59222. set refractionTexture(value: Nullable<BaseTexture>);
  59223. /**
  59224. * The color of a material in ambient lighting.
  59225. */
  59226. ambientColor: Color3;
  59227. /**
  59228. * AKA Diffuse Color in other nomenclature.
  59229. */
  59230. albedoColor: Color3;
  59231. /**
  59232. * AKA Specular Color in other nomenclature.
  59233. */
  59234. reflectivityColor: Color3;
  59235. /**
  59236. * The color reflected from the material.
  59237. */
  59238. reflectionColor: Color3;
  59239. /**
  59240. * The color emitted from the material.
  59241. */
  59242. emissiveColor: Color3;
  59243. /**
  59244. * AKA Glossiness in other nomenclature.
  59245. */
  59246. microSurface: number;
  59247. /**
  59248. * Index of refraction of the material base layer.
  59249. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59250. *
  59251. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59252. *
  59253. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59254. */
  59255. get indexOfRefraction(): number;
  59256. set indexOfRefraction(value: number);
  59257. /**
  59258. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59259. */
  59260. get invertRefractionY(): boolean;
  59261. set invertRefractionY(value: boolean);
  59262. /**
  59263. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59264. * Materials half opaque for instance using refraction could benefit from this control.
  59265. */
  59266. get linkRefractionWithTransparency(): boolean;
  59267. set linkRefractionWithTransparency(value: boolean);
  59268. /**
  59269. * If true, the light map contains occlusion information instead of lighting info.
  59270. */
  59271. useLightmapAsShadowmap: boolean;
  59272. /**
  59273. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59274. */
  59275. useAlphaFromAlbedoTexture: boolean;
  59276. /**
  59277. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59278. */
  59279. forceAlphaTest: boolean;
  59280. /**
  59281. * Defines the alpha limits in alpha test mode.
  59282. */
  59283. alphaCutOff: number;
  59284. /**
  59285. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59286. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59287. */
  59288. useSpecularOverAlpha: boolean;
  59289. /**
  59290. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59291. */
  59292. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59293. /**
  59294. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59295. */
  59296. useRoughnessFromMetallicTextureAlpha: boolean;
  59297. /**
  59298. * Specifies if the metallic texture contains the roughness information in its green channel.
  59299. */
  59300. useRoughnessFromMetallicTextureGreen: boolean;
  59301. /**
  59302. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59303. */
  59304. useMetallnessFromMetallicTextureBlue: boolean;
  59305. /**
  59306. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59307. */
  59308. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59309. /**
  59310. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59311. */
  59312. useAmbientInGrayScale: boolean;
  59313. /**
  59314. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59315. * The material will try to infer what glossiness each pixel should be.
  59316. */
  59317. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59318. /**
  59319. * BJS is using an harcoded light falloff based on a manually sets up range.
  59320. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59321. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59322. */
  59323. get usePhysicalLightFalloff(): boolean;
  59324. /**
  59325. * BJS is using an harcoded light falloff based on a manually sets up range.
  59326. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59327. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59328. */
  59329. set usePhysicalLightFalloff(value: 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. get useGLTFLightFalloff(): boolean;
  59335. /**
  59336. * In order to support the falloff compatibility with gltf, a special mode has been added
  59337. * to reproduce the gltf light falloff.
  59338. */
  59339. set useGLTFLightFalloff(value: boolean);
  59340. /**
  59341. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59342. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59343. */
  59344. useRadianceOverAlpha: boolean;
  59345. /**
  59346. * Allows using an object space normal map (instead of tangent space).
  59347. */
  59348. useObjectSpaceNormalMap: boolean;
  59349. /**
  59350. * Allows using the bump map in parallax mode.
  59351. */
  59352. useParallax: boolean;
  59353. /**
  59354. * Allows using the bump map in parallax occlusion mode.
  59355. */
  59356. useParallaxOcclusion: boolean;
  59357. /**
  59358. * Controls the scale bias of the parallax mode.
  59359. */
  59360. parallaxScaleBias: number;
  59361. /**
  59362. * If sets to true, disables all the lights affecting the material.
  59363. */
  59364. disableLighting: boolean;
  59365. /**
  59366. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59367. */
  59368. forceIrradianceInFragment: boolean;
  59369. /**
  59370. * Number of Simultaneous lights allowed on the material.
  59371. */
  59372. maxSimultaneousLights: number;
  59373. /**
  59374. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59375. */
  59376. invertNormalMapX: boolean;
  59377. /**
  59378. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59379. */
  59380. invertNormalMapY: boolean;
  59381. /**
  59382. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59383. */
  59384. twoSidedLighting: 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 is converted to gamma to compute the fresnel)
  59388. */
  59389. useAlphaFresnel: boolean;
  59390. /**
  59391. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59392. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59393. */
  59394. useLinearAlphaFresnel: boolean;
  59395. /**
  59396. * Let user defines the brdf lookup texture used for IBL.
  59397. * A default 8bit version is embedded but you could point at :
  59398. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59399. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59400. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59401. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59402. */
  59403. environmentBRDFTexture: Nullable<BaseTexture>;
  59404. /**
  59405. * Force normal to face away from face.
  59406. */
  59407. forceNormalForward: boolean;
  59408. /**
  59409. * Enables specular anti aliasing in the PBR shader.
  59410. * It will both interacts on the Geometry for analytical and IBL lighting.
  59411. * It also prefilter the roughness map based on the bump values.
  59412. */
  59413. enableSpecularAntiAliasing: boolean;
  59414. /**
  59415. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59416. * makes the reflect vector face the model (under horizon).
  59417. */
  59418. useHorizonOcclusion: boolean;
  59419. /**
  59420. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59421. * too much the area relying on ambient texture to define their ambient occlusion.
  59422. */
  59423. useRadianceOcclusion: boolean;
  59424. /**
  59425. * If set to true, no lighting calculations will be applied.
  59426. */
  59427. unlit: boolean;
  59428. /**
  59429. * Gets the image processing configuration used either in this material.
  59430. */
  59431. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59432. /**
  59433. * Sets the Default image processing configuration used either in the this material.
  59434. *
  59435. * If sets to null, the scene one is in use.
  59436. */
  59437. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59438. /**
  59439. * Gets wether the color curves effect is enabled.
  59440. */
  59441. get cameraColorCurvesEnabled(): boolean;
  59442. /**
  59443. * Sets wether the color curves effect is enabled.
  59444. */
  59445. set cameraColorCurvesEnabled(value: boolean);
  59446. /**
  59447. * Gets wether the color grading effect is enabled.
  59448. */
  59449. get cameraColorGradingEnabled(): boolean;
  59450. /**
  59451. * Gets wether the color grading effect is enabled.
  59452. */
  59453. set cameraColorGradingEnabled(value: boolean);
  59454. /**
  59455. * Gets wether tonemapping is enabled or not.
  59456. */
  59457. get cameraToneMappingEnabled(): boolean;
  59458. /**
  59459. * Sets wether tonemapping is enabled or not
  59460. */
  59461. set cameraToneMappingEnabled(value: boolean);
  59462. /**
  59463. * The camera exposure used on this material.
  59464. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59465. * This corresponds to a photographic exposure.
  59466. */
  59467. get cameraExposure(): number;
  59468. /**
  59469. * The camera exposure used on this material.
  59470. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59471. * This corresponds to a photographic exposure.
  59472. */
  59473. set cameraExposure(value: number);
  59474. /**
  59475. * Gets The camera contrast used on this material.
  59476. */
  59477. get cameraContrast(): number;
  59478. /**
  59479. * Sets The camera contrast used on this material.
  59480. */
  59481. set cameraContrast(value: number);
  59482. /**
  59483. * Gets the Color Grading 2D Lookup Texture.
  59484. */
  59485. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59486. /**
  59487. * Sets the Color Grading 2D Lookup Texture.
  59488. */
  59489. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59490. /**
  59491. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59492. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59493. * 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;
  59494. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59495. */
  59496. get cameraColorCurves(): Nullable<ColorCurves>;
  59497. /**
  59498. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59499. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59500. * 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;
  59501. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59502. */
  59503. set cameraColorCurves(value: Nullable<ColorCurves>);
  59504. /**
  59505. * Instantiates a new PBRMaterial instance.
  59506. *
  59507. * @param name The material name
  59508. * @param scene The scene the material will be use in.
  59509. */
  59510. constructor(name: string, scene: Scene);
  59511. /**
  59512. * Returns the name of this material class.
  59513. */
  59514. getClassName(): string;
  59515. /**
  59516. * Makes a duplicate of the current material.
  59517. * @param name - name to use for the new material.
  59518. */
  59519. clone(name: string): PBRMaterial;
  59520. /**
  59521. * Serializes this PBR Material.
  59522. * @returns - An object with the serialized material.
  59523. */
  59524. serialize(): any;
  59525. /**
  59526. * Parses a PBR Material from a serialized object.
  59527. * @param source - Serialized object.
  59528. * @param scene - BJS scene instance.
  59529. * @param rootUrl - url for the scene object
  59530. * @returns - PBRMaterial
  59531. */
  59532. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59533. }
  59534. }
  59535. declare module "babylonjs/Misc/dds" {
  59536. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59538. import { Nullable } from "babylonjs/types";
  59539. import { Scene } from "babylonjs/scene";
  59540. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59541. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59542. /**
  59543. * Direct draw surface info
  59544. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59545. */
  59546. export interface DDSInfo {
  59547. /**
  59548. * Width of the texture
  59549. */
  59550. width: number;
  59551. /**
  59552. * Width of the texture
  59553. */
  59554. height: number;
  59555. /**
  59556. * Number of Mipmaps for the texture
  59557. * @see https://en.wikipedia.org/wiki/Mipmap
  59558. */
  59559. mipmapCount: number;
  59560. /**
  59561. * If the textures format is a known fourCC format
  59562. * @see https://www.fourcc.org/
  59563. */
  59564. isFourCC: boolean;
  59565. /**
  59566. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59567. */
  59568. isRGB: boolean;
  59569. /**
  59570. * If the texture is a lumincance format
  59571. */
  59572. isLuminance: boolean;
  59573. /**
  59574. * If this is a cube texture
  59575. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59576. */
  59577. isCube: boolean;
  59578. /**
  59579. * If the texture is a compressed format eg. FOURCC_DXT1
  59580. */
  59581. isCompressed: boolean;
  59582. /**
  59583. * The dxgiFormat of the texture
  59584. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59585. */
  59586. dxgiFormat: number;
  59587. /**
  59588. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59589. */
  59590. textureType: number;
  59591. /**
  59592. * Sphericle polynomial created for the dds texture
  59593. */
  59594. sphericalPolynomial?: SphericalPolynomial;
  59595. }
  59596. /**
  59597. * Class used to provide DDS decompression tools
  59598. */
  59599. export class DDSTools {
  59600. /**
  59601. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59602. */
  59603. static StoreLODInAlphaChannel: boolean;
  59604. /**
  59605. * Gets DDS information from an array buffer
  59606. * @param data defines the array buffer view to read data from
  59607. * @returns the DDS information
  59608. */
  59609. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59610. private static _FloatView;
  59611. private static _Int32View;
  59612. private static _ToHalfFloat;
  59613. private static _FromHalfFloat;
  59614. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59615. private static _GetHalfFloatRGBAArrayBuffer;
  59616. private static _GetFloatRGBAArrayBuffer;
  59617. private static _GetFloatAsUIntRGBAArrayBuffer;
  59618. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59619. private static _GetRGBAArrayBuffer;
  59620. private static _ExtractLongWordOrder;
  59621. private static _GetRGBArrayBuffer;
  59622. private static _GetLuminanceArrayBuffer;
  59623. /**
  59624. * Uploads DDS Levels to a Babylon Texture
  59625. * @hidden
  59626. */
  59627. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59628. }
  59629. module "babylonjs/Engines/thinEngine" {
  59630. interface ThinEngine {
  59631. /**
  59632. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59633. * @param rootUrl defines the url where the file to load is located
  59634. * @param scene defines the current scene
  59635. * @param lodScale defines scale to apply to the mip map selection
  59636. * @param lodOffset defines offset to apply to the mip map selection
  59637. * @param onLoad defines an optional callback raised when the texture is loaded
  59638. * @param onError defines an optional callback raised if there is an issue to load the texture
  59639. * @param format defines the format of the data
  59640. * @param forcedExtension defines the extension to use to pick the right loader
  59641. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59642. * @returns the cube texture as an InternalTexture
  59643. */
  59644. 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;
  59645. }
  59646. }
  59647. }
  59648. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59649. import { Nullable } from "babylonjs/types";
  59650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59651. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59652. /**
  59653. * Implementation of the DDS Texture Loader.
  59654. * @hidden
  59655. */
  59656. export class _DDSTextureLoader implements IInternalTextureLoader {
  59657. /**
  59658. * Defines wether the loader supports cascade loading the different faces.
  59659. */
  59660. readonly supportCascades: boolean;
  59661. /**
  59662. * This returns if the loader support the current file information.
  59663. * @param extension defines the file extension of the file being loaded
  59664. * @returns true if the loader can load the specified file
  59665. */
  59666. canLoad(extension: string): boolean;
  59667. /**
  59668. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59669. * @param data contains the texture data
  59670. * @param texture defines the BabylonJS internal texture
  59671. * @param createPolynomials will be true if polynomials have been requested
  59672. * @param onLoad defines the callback to trigger once the texture is ready
  59673. * @param onError defines the callback to trigger in case of error
  59674. */
  59675. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59676. /**
  59677. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59678. * @param data contains the texture data
  59679. * @param texture defines the BabylonJS internal texture
  59680. * @param callback defines the method to call once ready to upload
  59681. */
  59682. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59683. }
  59684. }
  59685. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59686. import { Nullable } from "babylonjs/types";
  59687. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59688. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59689. /**
  59690. * Implementation of the ENV Texture Loader.
  59691. * @hidden
  59692. */
  59693. export class _ENVTextureLoader implements IInternalTextureLoader {
  59694. /**
  59695. * Defines wether the loader supports cascade loading the different faces.
  59696. */
  59697. readonly supportCascades: boolean;
  59698. /**
  59699. * This returns if the loader support the current file information.
  59700. * @param extension defines the file extension of the file being loaded
  59701. * @returns true if the loader can load the specified file
  59702. */
  59703. canLoad(extension: string): boolean;
  59704. /**
  59705. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59706. * @param data contains the texture data
  59707. * @param texture defines the BabylonJS internal texture
  59708. * @param createPolynomials will be true if polynomials have been requested
  59709. * @param onLoad defines the callback to trigger once the texture is ready
  59710. * @param onError defines the callback to trigger in case of error
  59711. */
  59712. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59713. /**
  59714. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59715. * @param data contains the texture data
  59716. * @param texture defines the BabylonJS internal texture
  59717. * @param callback defines the method to call once ready to upload
  59718. */
  59719. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59720. }
  59721. }
  59722. declare module "babylonjs/Misc/khronosTextureContainer" {
  59723. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59724. /**
  59725. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59726. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59727. */
  59728. export class KhronosTextureContainer {
  59729. /** contents of the KTX container file */
  59730. data: ArrayBufferView;
  59731. private static HEADER_LEN;
  59732. private static COMPRESSED_2D;
  59733. private static COMPRESSED_3D;
  59734. private static TEX_2D;
  59735. private static TEX_3D;
  59736. /**
  59737. * Gets the openGL type
  59738. */
  59739. glType: number;
  59740. /**
  59741. * Gets the openGL type size
  59742. */
  59743. glTypeSize: number;
  59744. /**
  59745. * Gets the openGL format
  59746. */
  59747. glFormat: number;
  59748. /**
  59749. * Gets the openGL internal format
  59750. */
  59751. glInternalFormat: number;
  59752. /**
  59753. * Gets the base internal format
  59754. */
  59755. glBaseInternalFormat: number;
  59756. /**
  59757. * Gets image width in pixel
  59758. */
  59759. pixelWidth: number;
  59760. /**
  59761. * Gets image height in pixel
  59762. */
  59763. pixelHeight: number;
  59764. /**
  59765. * Gets image depth in pixels
  59766. */
  59767. pixelDepth: number;
  59768. /**
  59769. * Gets the number of array elements
  59770. */
  59771. numberOfArrayElements: number;
  59772. /**
  59773. * Gets the number of faces
  59774. */
  59775. numberOfFaces: number;
  59776. /**
  59777. * Gets the number of mipmap levels
  59778. */
  59779. numberOfMipmapLevels: number;
  59780. /**
  59781. * Gets the bytes of key value data
  59782. */
  59783. bytesOfKeyValueData: number;
  59784. /**
  59785. * Gets the load type
  59786. */
  59787. loadType: number;
  59788. /**
  59789. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59790. */
  59791. isInvalid: boolean;
  59792. /**
  59793. * Creates a new KhronosTextureContainer
  59794. * @param data contents of the KTX container file
  59795. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59796. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59797. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59798. */
  59799. constructor(
  59800. /** contents of the KTX container file */
  59801. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59802. /**
  59803. * Uploads KTX content to a Babylon Texture.
  59804. * It is assumed that the texture has already been created & is currently bound
  59805. * @hidden
  59806. */
  59807. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59808. private _upload2DCompressedLevels;
  59809. /**
  59810. * Checks if the given data starts with a KTX file identifier.
  59811. * @param data the data to check
  59812. * @returns true if the data is a KTX file or false otherwise
  59813. */
  59814. static IsValid(data: ArrayBufferView): boolean;
  59815. }
  59816. }
  59817. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59818. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59819. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59820. /**
  59821. * Class for loading KTX2 files
  59822. * !!! Experimental Extension Subject to Changes !!!
  59823. * @hidden
  59824. */
  59825. export class KhronosTextureContainer2 {
  59826. private static _ModulePromise;
  59827. private static _TranscodeFormat;
  59828. constructor(engine: ThinEngine);
  59829. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59830. private _determineTranscodeFormat;
  59831. /**
  59832. * Checks if the given data starts with a KTX2 file identifier.
  59833. * @param data the data to check
  59834. * @returns true if the data is a KTX2 file or false otherwise
  59835. */
  59836. static IsValid(data: ArrayBufferView): boolean;
  59837. }
  59838. }
  59839. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59840. import { Nullable } from "babylonjs/types";
  59841. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59842. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59843. /**
  59844. * Implementation of the KTX Texture Loader.
  59845. * @hidden
  59846. */
  59847. export class _KTXTextureLoader implements IInternalTextureLoader {
  59848. /**
  59849. * Defines wether the loader supports cascade loading the different faces.
  59850. */
  59851. readonly supportCascades: boolean;
  59852. /**
  59853. * This returns if the loader support the current file information.
  59854. * @param extension defines the file extension of the file being loaded
  59855. * @param mimeType defines the optional mime type of the file being loaded
  59856. * @returns true if the loader can load the specified file
  59857. */
  59858. canLoad(extension: string, mimeType?: string): boolean;
  59859. /**
  59860. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59861. * @param data contains the texture data
  59862. * @param texture defines the BabylonJS internal texture
  59863. * @param createPolynomials will be true if polynomials have been requested
  59864. * @param onLoad defines the callback to trigger once the texture is ready
  59865. * @param onError defines the callback to trigger in case of error
  59866. */
  59867. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59868. /**
  59869. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59870. * @param data contains the texture data
  59871. * @param texture defines the BabylonJS internal texture
  59872. * @param callback defines the method to call once ready to upload
  59873. */
  59874. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59875. }
  59876. }
  59877. declare module "babylonjs/Helpers/sceneHelpers" {
  59878. import { Nullable } from "babylonjs/types";
  59879. import { Mesh } from "babylonjs/Meshes/mesh";
  59880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59881. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59882. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59883. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59884. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59885. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59886. import "babylonjs/Meshes/Builders/boxBuilder";
  59887. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59888. /** @hidden */
  59889. export var _forceSceneHelpersToBundle: boolean;
  59890. module "babylonjs/scene" {
  59891. interface Scene {
  59892. /**
  59893. * Creates a default light for the scene.
  59894. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59895. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59896. */
  59897. createDefaultLight(replace?: boolean): void;
  59898. /**
  59899. * Creates a default camera for the scene.
  59900. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59901. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59902. * @param replace has default false, when true replaces the active camera in the scene
  59903. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59904. */
  59905. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59906. /**
  59907. * Creates a default camera and a default light.
  59908. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59909. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59910. * @param replace has the default false, when true replaces the active camera/light in the scene
  59911. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59912. */
  59913. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59914. /**
  59915. * Creates a new sky box
  59916. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59917. * @param environmentTexture defines the texture to use as environment texture
  59918. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59919. * @param scale defines the overall scale of the skybox
  59920. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59921. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59922. * @returns a new mesh holding the sky box
  59923. */
  59924. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59925. /**
  59926. * Creates a new environment
  59927. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59928. * @param options defines the options you can use to configure the environment
  59929. * @returns the new EnvironmentHelper
  59930. */
  59931. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59932. /**
  59933. * Creates a new VREXperienceHelper
  59934. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59935. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59936. * @returns a new VREXperienceHelper
  59937. */
  59938. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59939. /**
  59940. * Creates a new WebXRDefaultExperience
  59941. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59942. * @param options experience options
  59943. * @returns a promise for a new WebXRDefaultExperience
  59944. */
  59945. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59946. }
  59947. }
  59948. }
  59949. declare module "babylonjs/Helpers/videoDome" {
  59950. import { Scene } from "babylonjs/scene";
  59951. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59952. import { Mesh } from "babylonjs/Meshes/mesh";
  59953. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59954. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59955. import "babylonjs/Meshes/Builders/sphereBuilder";
  59956. /**
  59957. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59958. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59959. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59960. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59961. */
  59962. export class VideoDome extends TransformNode {
  59963. /**
  59964. * Define the video source as a Monoscopic panoramic 360 video.
  59965. */
  59966. static readonly MODE_MONOSCOPIC: number;
  59967. /**
  59968. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59969. */
  59970. static readonly MODE_TOPBOTTOM: number;
  59971. /**
  59972. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59973. */
  59974. static readonly MODE_SIDEBYSIDE: number;
  59975. private _halfDome;
  59976. private _useDirectMapping;
  59977. /**
  59978. * The video texture being displayed on the sphere
  59979. */
  59980. protected _videoTexture: VideoTexture;
  59981. /**
  59982. * Gets the video texture being displayed on the sphere
  59983. */
  59984. get videoTexture(): VideoTexture;
  59985. /**
  59986. * The skybox material
  59987. */
  59988. protected _material: BackgroundMaterial;
  59989. /**
  59990. * The surface used for the video dome
  59991. */
  59992. protected _mesh: Mesh;
  59993. /**
  59994. * Gets the mesh used for the video dome.
  59995. */
  59996. get mesh(): Mesh;
  59997. /**
  59998. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59999. */
  60000. private _halfDomeMask;
  60001. /**
  60002. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60003. * Also see the options.resolution property.
  60004. */
  60005. get fovMultiplier(): number;
  60006. set fovMultiplier(value: number);
  60007. private _videoMode;
  60008. /**
  60009. * Gets or set the current video mode for the video. It can be:
  60010. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  60011. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60012. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60013. */
  60014. get videoMode(): number;
  60015. set videoMode(value: number);
  60016. /**
  60017. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  60018. *
  60019. */
  60020. get halfDome(): boolean;
  60021. /**
  60022. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60023. */
  60024. set halfDome(enabled: boolean);
  60025. /**
  60026. * Oberserver used in Stereoscopic VR Mode.
  60027. */
  60028. private _onBeforeCameraRenderObserver;
  60029. /**
  60030. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  60031. * @param name Element's name, child elements will append suffixes for their own names.
  60032. * @param urlsOrVideo defines the url(s) or the video element to use
  60033. * @param options An object containing optional or exposed sub element properties
  60034. */
  60035. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  60036. resolution?: number;
  60037. clickToPlay?: boolean;
  60038. autoPlay?: boolean;
  60039. loop?: boolean;
  60040. size?: number;
  60041. poster?: string;
  60042. faceForward?: boolean;
  60043. useDirectMapping?: boolean;
  60044. halfDomeMode?: boolean;
  60045. }, scene: Scene);
  60046. private _changeVideoMode;
  60047. /**
  60048. * Releases resources associated with this node.
  60049. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60050. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60051. */
  60052. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60053. }
  60054. }
  60055. declare module "babylonjs/Helpers/index" {
  60056. export * from "babylonjs/Helpers/environmentHelper";
  60057. export * from "babylonjs/Helpers/photoDome";
  60058. export * from "babylonjs/Helpers/sceneHelpers";
  60059. export * from "babylonjs/Helpers/videoDome";
  60060. }
  60061. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60062. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60063. import { IDisposable } from "babylonjs/scene";
  60064. import { Engine } from "babylonjs/Engines/engine";
  60065. /**
  60066. * This class can be used to get instrumentation data from a Babylon engine
  60067. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60068. */
  60069. export class EngineInstrumentation implements IDisposable {
  60070. /**
  60071. * Define the instrumented engine.
  60072. */
  60073. engine: Engine;
  60074. private _captureGPUFrameTime;
  60075. private _gpuFrameTimeToken;
  60076. private _gpuFrameTime;
  60077. private _captureShaderCompilationTime;
  60078. private _shaderCompilationTime;
  60079. private _onBeginFrameObserver;
  60080. private _onEndFrameObserver;
  60081. private _onBeforeShaderCompilationObserver;
  60082. private _onAfterShaderCompilationObserver;
  60083. /**
  60084. * Gets the perf counter used for GPU frame time
  60085. */
  60086. get gpuFrameTimeCounter(): PerfCounter;
  60087. /**
  60088. * Gets the GPU frame time capture status
  60089. */
  60090. get captureGPUFrameTime(): boolean;
  60091. /**
  60092. * Enable or disable the GPU frame time capture
  60093. */
  60094. set captureGPUFrameTime(value: boolean);
  60095. /**
  60096. * Gets the perf counter used for shader compilation time
  60097. */
  60098. get shaderCompilationTimeCounter(): PerfCounter;
  60099. /**
  60100. * Gets the shader compilation time capture status
  60101. */
  60102. get captureShaderCompilationTime(): boolean;
  60103. /**
  60104. * Enable or disable the shader compilation time capture
  60105. */
  60106. set captureShaderCompilationTime(value: boolean);
  60107. /**
  60108. * Instantiates a new engine instrumentation.
  60109. * This class can be used to get instrumentation data from a Babylon engine
  60110. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60111. * @param engine Defines the engine to instrument
  60112. */
  60113. constructor(
  60114. /**
  60115. * Define the instrumented engine.
  60116. */
  60117. engine: Engine);
  60118. /**
  60119. * Dispose and release associated resources.
  60120. */
  60121. dispose(): void;
  60122. }
  60123. }
  60124. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60125. import { Scene, IDisposable } from "babylonjs/scene";
  60126. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60127. /**
  60128. * This class can be used to get instrumentation data from a Babylon engine
  60129. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60130. */
  60131. export class SceneInstrumentation implements IDisposable {
  60132. /**
  60133. * Defines the scene to instrument
  60134. */
  60135. scene: Scene;
  60136. private _captureActiveMeshesEvaluationTime;
  60137. private _activeMeshesEvaluationTime;
  60138. private _captureRenderTargetsRenderTime;
  60139. private _renderTargetsRenderTime;
  60140. private _captureFrameTime;
  60141. private _frameTime;
  60142. private _captureRenderTime;
  60143. private _renderTime;
  60144. private _captureInterFrameTime;
  60145. private _interFrameTime;
  60146. private _captureParticlesRenderTime;
  60147. private _particlesRenderTime;
  60148. private _captureSpritesRenderTime;
  60149. private _spritesRenderTime;
  60150. private _capturePhysicsTime;
  60151. private _physicsTime;
  60152. private _captureAnimationsTime;
  60153. private _animationsTime;
  60154. private _captureCameraRenderTime;
  60155. private _cameraRenderTime;
  60156. private _onBeforeActiveMeshesEvaluationObserver;
  60157. private _onAfterActiveMeshesEvaluationObserver;
  60158. private _onBeforeRenderTargetsRenderObserver;
  60159. private _onAfterRenderTargetsRenderObserver;
  60160. private _onAfterRenderObserver;
  60161. private _onBeforeDrawPhaseObserver;
  60162. private _onAfterDrawPhaseObserver;
  60163. private _onBeforeAnimationsObserver;
  60164. private _onBeforeParticlesRenderingObserver;
  60165. private _onAfterParticlesRenderingObserver;
  60166. private _onBeforeSpritesRenderingObserver;
  60167. private _onAfterSpritesRenderingObserver;
  60168. private _onBeforePhysicsObserver;
  60169. private _onAfterPhysicsObserver;
  60170. private _onAfterAnimationsObserver;
  60171. private _onBeforeCameraRenderObserver;
  60172. private _onAfterCameraRenderObserver;
  60173. /**
  60174. * Gets the perf counter used for active meshes evaluation time
  60175. */
  60176. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60177. /**
  60178. * Gets the active meshes evaluation time capture status
  60179. */
  60180. get captureActiveMeshesEvaluationTime(): boolean;
  60181. /**
  60182. * Enable or disable the active meshes evaluation time capture
  60183. */
  60184. set captureActiveMeshesEvaluationTime(value: boolean);
  60185. /**
  60186. * Gets the perf counter used for render targets render time
  60187. */
  60188. get renderTargetsRenderTimeCounter(): PerfCounter;
  60189. /**
  60190. * Gets the render targets render time capture status
  60191. */
  60192. get captureRenderTargetsRenderTime(): boolean;
  60193. /**
  60194. * Enable or disable the render targets render time capture
  60195. */
  60196. set captureRenderTargetsRenderTime(value: boolean);
  60197. /**
  60198. * Gets the perf counter used for particles render time
  60199. */
  60200. get particlesRenderTimeCounter(): PerfCounter;
  60201. /**
  60202. * Gets the particles render time capture status
  60203. */
  60204. get captureParticlesRenderTime(): boolean;
  60205. /**
  60206. * Enable or disable the particles render time capture
  60207. */
  60208. set captureParticlesRenderTime(value: boolean);
  60209. /**
  60210. * Gets the perf counter used for sprites render time
  60211. */
  60212. get spritesRenderTimeCounter(): PerfCounter;
  60213. /**
  60214. * Gets the sprites render time capture status
  60215. */
  60216. get captureSpritesRenderTime(): boolean;
  60217. /**
  60218. * Enable or disable the sprites render time capture
  60219. */
  60220. set captureSpritesRenderTime(value: boolean);
  60221. /**
  60222. * Gets the perf counter used for physics time
  60223. */
  60224. get physicsTimeCounter(): PerfCounter;
  60225. /**
  60226. * Gets the physics time capture status
  60227. */
  60228. get capturePhysicsTime(): boolean;
  60229. /**
  60230. * Enable or disable the physics time capture
  60231. */
  60232. set capturePhysicsTime(value: boolean);
  60233. /**
  60234. * Gets the perf counter used for animations time
  60235. */
  60236. get animationsTimeCounter(): PerfCounter;
  60237. /**
  60238. * Gets the animations time capture status
  60239. */
  60240. get captureAnimationsTime(): boolean;
  60241. /**
  60242. * Enable or disable the animations time capture
  60243. */
  60244. set captureAnimationsTime(value: boolean);
  60245. /**
  60246. * Gets the perf counter used for frame time capture
  60247. */
  60248. get frameTimeCounter(): PerfCounter;
  60249. /**
  60250. * Gets the frame time capture status
  60251. */
  60252. get captureFrameTime(): boolean;
  60253. /**
  60254. * Enable or disable the frame time capture
  60255. */
  60256. set captureFrameTime(value: boolean);
  60257. /**
  60258. * Gets the perf counter used for inter-frames time capture
  60259. */
  60260. get interFrameTimeCounter(): PerfCounter;
  60261. /**
  60262. * Gets the inter-frames time capture status
  60263. */
  60264. get captureInterFrameTime(): boolean;
  60265. /**
  60266. * Enable or disable the inter-frames time capture
  60267. */
  60268. set captureInterFrameTime(value: boolean);
  60269. /**
  60270. * Gets the perf counter used for render time capture
  60271. */
  60272. get renderTimeCounter(): PerfCounter;
  60273. /**
  60274. * Gets the render time capture status
  60275. */
  60276. get captureRenderTime(): boolean;
  60277. /**
  60278. * Enable or disable the render time capture
  60279. */
  60280. set captureRenderTime(value: boolean);
  60281. /**
  60282. * Gets the perf counter used for camera render time capture
  60283. */
  60284. get cameraRenderTimeCounter(): PerfCounter;
  60285. /**
  60286. * Gets the camera render time capture status
  60287. */
  60288. get captureCameraRenderTime(): boolean;
  60289. /**
  60290. * Enable or disable the camera render time capture
  60291. */
  60292. set captureCameraRenderTime(value: boolean);
  60293. /**
  60294. * Gets the perf counter used for draw calls
  60295. */
  60296. get drawCallsCounter(): PerfCounter;
  60297. /**
  60298. * Instantiates a new scene instrumentation.
  60299. * This class can be used to get instrumentation data from a Babylon engine
  60300. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60301. * @param scene Defines the scene to instrument
  60302. */
  60303. constructor(
  60304. /**
  60305. * Defines the scene to instrument
  60306. */
  60307. scene: Scene);
  60308. /**
  60309. * Dispose and release associated resources.
  60310. */
  60311. dispose(): void;
  60312. }
  60313. }
  60314. declare module "babylonjs/Instrumentation/index" {
  60315. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60316. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60317. export * from "babylonjs/Instrumentation/timeToken";
  60318. }
  60319. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60320. /** @hidden */
  60321. export var glowMapGenerationPixelShader: {
  60322. name: string;
  60323. shader: string;
  60324. };
  60325. }
  60326. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60327. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60329. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60330. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60331. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60332. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60333. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60334. /** @hidden */
  60335. export var glowMapGenerationVertexShader: {
  60336. name: string;
  60337. shader: string;
  60338. };
  60339. }
  60340. declare module "babylonjs/Layers/effectLayer" {
  60341. import { Observable } from "babylonjs/Misc/observable";
  60342. import { Nullable } from "babylonjs/types";
  60343. import { Camera } from "babylonjs/Cameras/camera";
  60344. import { Scene } from "babylonjs/scene";
  60345. import { ISize } from "babylonjs/Maths/math.size";
  60346. import { Color4 } from "babylonjs/Maths/math.color";
  60347. import { Engine } from "babylonjs/Engines/engine";
  60348. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60350. import { Mesh } from "babylonjs/Meshes/mesh";
  60351. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60352. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60354. import { Effect } from "babylonjs/Materials/effect";
  60355. import { Material } from "babylonjs/Materials/material";
  60356. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60357. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60358. /**
  60359. * Effect layer options. This helps customizing the behaviour
  60360. * of the effect layer.
  60361. */
  60362. export interface IEffectLayerOptions {
  60363. /**
  60364. * Multiplication factor apply to the canvas size to compute the render target size
  60365. * used to generated the objects (the smaller the faster).
  60366. */
  60367. mainTextureRatio: number;
  60368. /**
  60369. * Enforces a fixed size texture to ensure effect stability across devices.
  60370. */
  60371. mainTextureFixedSize?: number;
  60372. /**
  60373. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60374. */
  60375. alphaBlendingMode: number;
  60376. /**
  60377. * The camera attached to the layer.
  60378. */
  60379. camera: Nullable<Camera>;
  60380. /**
  60381. * The rendering group to draw the layer in.
  60382. */
  60383. renderingGroupId: number;
  60384. }
  60385. /**
  60386. * The effect layer Helps adding post process effect blended with the main pass.
  60387. *
  60388. * This can be for instance use to generate glow or higlight effects on the scene.
  60389. *
  60390. * The effect layer class can not be used directly and is intented to inherited from to be
  60391. * customized per effects.
  60392. */
  60393. export abstract class EffectLayer {
  60394. private _vertexBuffers;
  60395. private _indexBuffer;
  60396. private _cachedDefines;
  60397. private _effectLayerMapGenerationEffect;
  60398. private _effectLayerOptions;
  60399. private _mergeEffect;
  60400. protected _scene: Scene;
  60401. protected _engine: Engine;
  60402. protected _maxSize: number;
  60403. protected _mainTextureDesiredSize: ISize;
  60404. protected _mainTexture: RenderTargetTexture;
  60405. protected _shouldRender: boolean;
  60406. protected _postProcesses: PostProcess[];
  60407. protected _textures: BaseTexture[];
  60408. protected _emissiveTextureAndColor: {
  60409. texture: Nullable<BaseTexture>;
  60410. color: Color4;
  60411. };
  60412. /**
  60413. * The name of the layer
  60414. */
  60415. name: string;
  60416. /**
  60417. * The clear color of the texture used to generate the glow map.
  60418. */
  60419. neutralColor: Color4;
  60420. /**
  60421. * Specifies whether the highlight layer is enabled or not.
  60422. */
  60423. isEnabled: boolean;
  60424. /**
  60425. * Gets the camera attached to the layer.
  60426. */
  60427. get camera(): Nullable<Camera>;
  60428. /**
  60429. * Gets the rendering group id the layer should render in.
  60430. */
  60431. get renderingGroupId(): number;
  60432. set renderingGroupId(renderingGroupId: number);
  60433. /**
  60434. * An event triggered when the effect layer has been disposed.
  60435. */
  60436. onDisposeObservable: Observable<EffectLayer>;
  60437. /**
  60438. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60439. */
  60440. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60441. /**
  60442. * An event triggered when the generated texture is being merged in the scene.
  60443. */
  60444. onBeforeComposeObservable: Observable<EffectLayer>;
  60445. /**
  60446. * An event triggered when the mesh is rendered into the effect render target.
  60447. */
  60448. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60449. /**
  60450. * An event triggered after the mesh has been rendered into the effect render target.
  60451. */
  60452. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60453. /**
  60454. * An event triggered when the generated texture has been merged in the scene.
  60455. */
  60456. onAfterComposeObservable: Observable<EffectLayer>;
  60457. /**
  60458. * An event triggered when the efffect layer changes its size.
  60459. */
  60460. onSizeChangedObservable: Observable<EffectLayer>;
  60461. /** @hidden */
  60462. static _SceneComponentInitialization: (scene: Scene) => void;
  60463. /**
  60464. * Instantiates a new effect Layer and references it in the scene.
  60465. * @param name The name of the layer
  60466. * @param scene The scene to use the layer in
  60467. */
  60468. constructor(
  60469. /** The Friendly of the effect in the scene */
  60470. name: string, scene: Scene);
  60471. /**
  60472. * Get the effect name of the layer.
  60473. * @return The effect name
  60474. */
  60475. abstract getEffectName(): string;
  60476. /**
  60477. * Checks for the readiness of the element composing the layer.
  60478. * @param subMesh the mesh to check for
  60479. * @param useInstances specify whether or not to use instances to render the mesh
  60480. * @return true if ready otherwise, false
  60481. */
  60482. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60483. /**
  60484. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60485. * @returns true if the effect requires stencil during the main canvas render pass.
  60486. */
  60487. abstract needStencil(): boolean;
  60488. /**
  60489. * Create the merge effect. This is the shader use to blit the information back
  60490. * to the main canvas at the end of the scene rendering.
  60491. * @returns The effect containing the shader used to merge the effect on the main canvas
  60492. */
  60493. protected abstract _createMergeEffect(): Effect;
  60494. /**
  60495. * Creates the render target textures and post processes used in the effect layer.
  60496. */
  60497. protected abstract _createTextureAndPostProcesses(): void;
  60498. /**
  60499. * Implementation specific of rendering the generating effect on the main canvas.
  60500. * @param effect The effect used to render through
  60501. */
  60502. protected abstract _internalRender(effect: Effect): void;
  60503. /**
  60504. * Sets the required values for both the emissive texture and and the main color.
  60505. */
  60506. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60507. /**
  60508. * Free any resources and references associated to a mesh.
  60509. * Internal use
  60510. * @param mesh The mesh to free.
  60511. */
  60512. abstract _disposeMesh(mesh: Mesh): void;
  60513. /**
  60514. * Serializes this layer (Glow or Highlight for example)
  60515. * @returns a serialized layer object
  60516. */
  60517. abstract serialize?(): any;
  60518. /**
  60519. * Initializes the effect layer with the required options.
  60520. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60521. */
  60522. protected _init(options: Partial<IEffectLayerOptions>): void;
  60523. /**
  60524. * Generates the index buffer of the full screen quad blending to the main canvas.
  60525. */
  60526. private _generateIndexBuffer;
  60527. /**
  60528. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60529. */
  60530. private _generateVertexBuffer;
  60531. /**
  60532. * Sets the main texture desired size which is the closest power of two
  60533. * of the engine canvas size.
  60534. */
  60535. private _setMainTextureSize;
  60536. /**
  60537. * Creates the main texture for the effect layer.
  60538. */
  60539. protected _createMainTexture(): void;
  60540. /**
  60541. * Adds specific effects defines.
  60542. * @param defines The defines to add specifics to.
  60543. */
  60544. protected _addCustomEffectDefines(defines: string[]): void;
  60545. /**
  60546. * Checks for the readiness of the element composing the layer.
  60547. * @param subMesh the mesh to check for
  60548. * @param useInstances specify whether or not to use instances to render the mesh
  60549. * @param emissiveTexture the associated emissive texture used to generate the glow
  60550. * @return true if ready otherwise, false
  60551. */
  60552. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60553. /**
  60554. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60555. */
  60556. render(): void;
  60557. /**
  60558. * Determine if a given mesh will be used in the current effect.
  60559. * @param mesh mesh to test
  60560. * @returns true if the mesh will be used
  60561. */
  60562. hasMesh(mesh: AbstractMesh): boolean;
  60563. /**
  60564. * Returns true if the layer contains information to display, otherwise false.
  60565. * @returns true if the glow layer should be rendered
  60566. */
  60567. shouldRender(): boolean;
  60568. /**
  60569. * Returns true if the mesh should render, otherwise false.
  60570. * @param mesh The mesh to render
  60571. * @returns true if it should render otherwise false
  60572. */
  60573. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60574. /**
  60575. * Returns true if the mesh can be rendered, otherwise false.
  60576. * @param mesh The mesh to render
  60577. * @param material The material used on the mesh
  60578. * @returns true if it can be rendered otherwise false
  60579. */
  60580. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60581. /**
  60582. * Returns true if the mesh should render, otherwise false.
  60583. * @param mesh The mesh to render
  60584. * @returns true if it should render otherwise false
  60585. */
  60586. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60587. /**
  60588. * Renders the submesh passed in parameter to the generation map.
  60589. */
  60590. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60591. /**
  60592. * Defines whether the current material of the mesh should be use to render the effect.
  60593. * @param mesh defines the current mesh to render
  60594. */
  60595. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60596. /**
  60597. * Rebuild the required buffers.
  60598. * @hidden Internal use only.
  60599. */
  60600. _rebuild(): void;
  60601. /**
  60602. * Dispose only the render target textures and post process.
  60603. */
  60604. private _disposeTextureAndPostProcesses;
  60605. /**
  60606. * Dispose the highlight layer and free resources.
  60607. */
  60608. dispose(): void;
  60609. /**
  60610. * Gets the class name of the effect layer
  60611. * @returns the string with the class name of the effect layer
  60612. */
  60613. getClassName(): string;
  60614. /**
  60615. * Creates an effect layer from parsed effect layer data
  60616. * @param parsedEffectLayer defines effect layer data
  60617. * @param scene defines the current scene
  60618. * @param rootUrl defines the root URL containing the effect layer information
  60619. * @returns a parsed effect Layer
  60620. */
  60621. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60622. }
  60623. }
  60624. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60625. import { Scene } from "babylonjs/scene";
  60626. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60627. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60628. import { AbstractScene } from "babylonjs/abstractScene";
  60629. module "babylonjs/abstractScene" {
  60630. interface AbstractScene {
  60631. /**
  60632. * The list of effect layers (highlights/glow) added to the scene
  60633. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60634. * @see https://doc.babylonjs.com/how_to/glow_layer
  60635. */
  60636. effectLayers: Array<EffectLayer>;
  60637. /**
  60638. * Removes the given effect layer from this scene.
  60639. * @param toRemove defines the effect layer to remove
  60640. * @returns the index of the removed effect layer
  60641. */
  60642. removeEffectLayer(toRemove: EffectLayer): number;
  60643. /**
  60644. * Adds the given effect layer to this scene
  60645. * @param newEffectLayer defines the effect layer to add
  60646. */
  60647. addEffectLayer(newEffectLayer: EffectLayer): void;
  60648. }
  60649. }
  60650. /**
  60651. * Defines the layer scene component responsible to manage any effect layers
  60652. * in a given scene.
  60653. */
  60654. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60655. /**
  60656. * The component name helpfull to identify the component in the list of scene components.
  60657. */
  60658. readonly name: string;
  60659. /**
  60660. * The scene the component belongs to.
  60661. */
  60662. scene: Scene;
  60663. private _engine;
  60664. private _renderEffects;
  60665. private _needStencil;
  60666. private _previousStencilState;
  60667. /**
  60668. * Creates a new instance of the component for the given scene
  60669. * @param scene Defines the scene to register the component in
  60670. */
  60671. constructor(scene: Scene);
  60672. /**
  60673. * Registers the component in a given scene
  60674. */
  60675. register(): void;
  60676. /**
  60677. * Rebuilds the elements related to this component in case of
  60678. * context lost for instance.
  60679. */
  60680. rebuild(): void;
  60681. /**
  60682. * Serializes the component data to the specified json object
  60683. * @param serializationObject The object to serialize to
  60684. */
  60685. serialize(serializationObject: any): void;
  60686. /**
  60687. * Adds all the elements from the container to the scene
  60688. * @param container the container holding the elements
  60689. */
  60690. addFromContainer(container: AbstractScene): void;
  60691. /**
  60692. * Removes all the elements in the container from the scene
  60693. * @param container contains the elements to remove
  60694. * @param dispose if the removed element should be disposed (default: false)
  60695. */
  60696. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60697. /**
  60698. * Disposes the component and the associated ressources.
  60699. */
  60700. dispose(): void;
  60701. private _isReadyForMesh;
  60702. private _renderMainTexture;
  60703. private _setStencil;
  60704. private _setStencilBack;
  60705. private _draw;
  60706. private _drawCamera;
  60707. private _drawRenderingGroup;
  60708. }
  60709. }
  60710. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60711. /** @hidden */
  60712. export var glowMapMergePixelShader: {
  60713. name: string;
  60714. shader: string;
  60715. };
  60716. }
  60717. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60718. /** @hidden */
  60719. export var glowMapMergeVertexShader: {
  60720. name: string;
  60721. shader: string;
  60722. };
  60723. }
  60724. declare module "babylonjs/Layers/glowLayer" {
  60725. import { Nullable } from "babylonjs/types";
  60726. import { Camera } from "babylonjs/Cameras/camera";
  60727. import { Scene } from "babylonjs/scene";
  60728. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60730. import { Mesh } from "babylonjs/Meshes/mesh";
  60731. import { Texture } from "babylonjs/Materials/Textures/texture";
  60732. import { Effect } from "babylonjs/Materials/effect";
  60733. import { Material } from "babylonjs/Materials/material";
  60734. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60735. import { Color4 } from "babylonjs/Maths/math.color";
  60736. import "babylonjs/Shaders/glowMapMerge.fragment";
  60737. import "babylonjs/Shaders/glowMapMerge.vertex";
  60738. import "babylonjs/Layers/effectLayerSceneComponent";
  60739. module "babylonjs/abstractScene" {
  60740. interface AbstractScene {
  60741. /**
  60742. * Return a the first highlight layer of the scene with a given name.
  60743. * @param name The name of the highlight layer to look for.
  60744. * @return The highlight layer if found otherwise null.
  60745. */
  60746. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60747. }
  60748. }
  60749. /**
  60750. * Glow layer options. This helps customizing the behaviour
  60751. * of the glow layer.
  60752. */
  60753. export interface IGlowLayerOptions {
  60754. /**
  60755. * Multiplication factor apply to the canvas size to compute the render target size
  60756. * used to generated the glowing objects (the smaller the faster).
  60757. */
  60758. mainTextureRatio: number;
  60759. /**
  60760. * Enforces a fixed size texture to ensure resize independant blur.
  60761. */
  60762. mainTextureFixedSize?: number;
  60763. /**
  60764. * How big is the kernel of the blur texture.
  60765. */
  60766. blurKernelSize: number;
  60767. /**
  60768. * The camera attached to the layer.
  60769. */
  60770. camera: Nullable<Camera>;
  60771. /**
  60772. * Enable MSAA by chosing the number of samples.
  60773. */
  60774. mainTextureSamples?: number;
  60775. /**
  60776. * The rendering group to draw the layer in.
  60777. */
  60778. renderingGroupId: number;
  60779. }
  60780. /**
  60781. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60782. *
  60783. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60784. *
  60785. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60786. */
  60787. export class GlowLayer extends EffectLayer {
  60788. /**
  60789. * Effect Name of the layer.
  60790. */
  60791. static readonly EffectName: string;
  60792. /**
  60793. * The default blur kernel size used for the glow.
  60794. */
  60795. static DefaultBlurKernelSize: number;
  60796. /**
  60797. * The default texture size ratio used for the glow.
  60798. */
  60799. static DefaultTextureRatio: number;
  60800. /**
  60801. * Sets the kernel size of the blur.
  60802. */
  60803. set blurKernelSize(value: number);
  60804. /**
  60805. * Gets the kernel size of the blur.
  60806. */
  60807. get blurKernelSize(): number;
  60808. /**
  60809. * Sets the glow intensity.
  60810. */
  60811. set intensity(value: number);
  60812. /**
  60813. * Gets the glow intensity.
  60814. */
  60815. get intensity(): number;
  60816. private _options;
  60817. private _intensity;
  60818. private _horizontalBlurPostprocess1;
  60819. private _verticalBlurPostprocess1;
  60820. private _horizontalBlurPostprocess2;
  60821. private _verticalBlurPostprocess2;
  60822. private _blurTexture1;
  60823. private _blurTexture2;
  60824. private _postProcesses1;
  60825. private _postProcesses2;
  60826. private _includedOnlyMeshes;
  60827. private _excludedMeshes;
  60828. private _meshesUsingTheirOwnMaterials;
  60829. /**
  60830. * Callback used to let the user override the color selection on a per mesh basis
  60831. */
  60832. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60833. /**
  60834. * Callback used to let the user override the texture selection on a per mesh basis
  60835. */
  60836. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60837. /**
  60838. * Instantiates a new glow Layer and references it to the scene.
  60839. * @param name The name of the layer
  60840. * @param scene The scene to use the layer in
  60841. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60842. */
  60843. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60844. /**
  60845. * Get the effect name of the layer.
  60846. * @return The effect name
  60847. */
  60848. getEffectName(): string;
  60849. /**
  60850. * Create the merge effect. This is the shader use to blit the information back
  60851. * to the main canvas at the end of the scene rendering.
  60852. */
  60853. protected _createMergeEffect(): Effect;
  60854. /**
  60855. * Creates the render target textures and post processes used in the glow layer.
  60856. */
  60857. protected _createTextureAndPostProcesses(): void;
  60858. /**
  60859. * Checks for the readiness of the element composing the layer.
  60860. * @param subMesh the mesh to check for
  60861. * @param useInstances specify wether or not to use instances to render the mesh
  60862. * @param emissiveTexture the associated emissive texture used to generate the glow
  60863. * @return true if ready otherwise, false
  60864. */
  60865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60866. /**
  60867. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60868. */
  60869. needStencil(): boolean;
  60870. /**
  60871. * Returns true if the mesh can be rendered, otherwise false.
  60872. * @param mesh The mesh to render
  60873. * @param material The material used on the mesh
  60874. * @returns true if it can be rendered otherwise false
  60875. */
  60876. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60877. /**
  60878. * Implementation specific of rendering the generating effect on the main canvas.
  60879. * @param effect The effect used to render through
  60880. */
  60881. protected _internalRender(effect: Effect): void;
  60882. /**
  60883. * Sets the required values for both the emissive texture and and the main color.
  60884. */
  60885. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60886. /**
  60887. * Returns true if the mesh should render, otherwise false.
  60888. * @param mesh The mesh to render
  60889. * @returns true if it should render otherwise false
  60890. */
  60891. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60892. /**
  60893. * Adds specific effects defines.
  60894. * @param defines The defines to add specifics to.
  60895. */
  60896. protected _addCustomEffectDefines(defines: string[]): void;
  60897. /**
  60898. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60899. * @param mesh The mesh to exclude from the glow layer
  60900. */
  60901. addExcludedMesh(mesh: Mesh): void;
  60902. /**
  60903. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60904. * @param mesh The mesh to remove
  60905. */
  60906. removeExcludedMesh(mesh: Mesh): void;
  60907. /**
  60908. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60909. * @param mesh The mesh to include in the glow layer
  60910. */
  60911. addIncludedOnlyMesh(mesh: Mesh): void;
  60912. /**
  60913. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60914. * @param mesh The mesh to remove
  60915. */
  60916. removeIncludedOnlyMesh(mesh: Mesh): void;
  60917. /**
  60918. * Determine if a given mesh will be used in the glow layer
  60919. * @param mesh The mesh to test
  60920. * @returns true if the mesh will be highlighted by the current glow layer
  60921. */
  60922. hasMesh(mesh: AbstractMesh): boolean;
  60923. /**
  60924. * Defines whether the current material of the mesh should be use to render the effect.
  60925. * @param mesh defines the current mesh to render
  60926. */
  60927. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60928. /**
  60929. * Add a mesh to be rendered through its own material and not with emissive only.
  60930. * @param mesh The mesh for which we need to use its material
  60931. */
  60932. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60933. /**
  60934. * Remove a mesh from being rendered through its own material and not with emissive only.
  60935. * @param mesh The mesh for which we need to not use its material
  60936. */
  60937. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60938. /**
  60939. * Free any resources and references associated to a mesh.
  60940. * Internal use
  60941. * @param mesh The mesh to free.
  60942. * @hidden
  60943. */
  60944. _disposeMesh(mesh: Mesh): void;
  60945. /**
  60946. * Gets the class name of the effect layer
  60947. * @returns the string with the class name of the effect layer
  60948. */
  60949. getClassName(): string;
  60950. /**
  60951. * Serializes this glow layer
  60952. * @returns a serialized glow layer object
  60953. */
  60954. serialize(): any;
  60955. /**
  60956. * Creates a Glow Layer from parsed glow layer data
  60957. * @param parsedGlowLayer defines glow layer data
  60958. * @param scene defines the current scene
  60959. * @param rootUrl defines the root URL containing the glow layer information
  60960. * @returns a parsed Glow Layer
  60961. */
  60962. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60963. }
  60964. }
  60965. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60966. /** @hidden */
  60967. export var glowBlurPostProcessPixelShader: {
  60968. name: string;
  60969. shader: string;
  60970. };
  60971. }
  60972. declare module "babylonjs/Layers/highlightLayer" {
  60973. import { Observable } from "babylonjs/Misc/observable";
  60974. import { Nullable } from "babylonjs/types";
  60975. import { Camera } from "babylonjs/Cameras/camera";
  60976. import { Scene } from "babylonjs/scene";
  60977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60979. import { Mesh } from "babylonjs/Meshes/mesh";
  60980. import { Effect } from "babylonjs/Materials/effect";
  60981. import { Material } from "babylonjs/Materials/material";
  60982. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60983. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60984. import "babylonjs/Shaders/glowMapMerge.fragment";
  60985. import "babylonjs/Shaders/glowMapMerge.vertex";
  60986. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60987. module "babylonjs/abstractScene" {
  60988. interface AbstractScene {
  60989. /**
  60990. * Return a the first highlight layer of the scene with a given name.
  60991. * @param name The name of the highlight layer to look for.
  60992. * @return The highlight layer if found otherwise null.
  60993. */
  60994. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60995. }
  60996. }
  60997. /**
  60998. * Highlight layer options. This helps customizing the behaviour
  60999. * of the highlight layer.
  61000. */
  61001. export interface IHighlightLayerOptions {
  61002. /**
  61003. * Multiplication factor apply to the canvas size to compute the render target size
  61004. * used to generated the glowing objects (the smaller the faster).
  61005. */
  61006. mainTextureRatio: number;
  61007. /**
  61008. * Enforces a fixed size texture to ensure resize independant blur.
  61009. */
  61010. mainTextureFixedSize?: number;
  61011. /**
  61012. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61013. * of the picture to blur (the smaller the faster).
  61014. */
  61015. blurTextureSizeRatio: number;
  61016. /**
  61017. * How big in texel of the blur texture is the vertical blur.
  61018. */
  61019. blurVerticalSize: number;
  61020. /**
  61021. * How big in texel of the blur texture is the horizontal blur.
  61022. */
  61023. blurHorizontalSize: number;
  61024. /**
  61025. * Alpha blending mode used to apply the blur. Default is combine.
  61026. */
  61027. alphaBlendingMode: number;
  61028. /**
  61029. * The camera attached to the layer.
  61030. */
  61031. camera: Nullable<Camera>;
  61032. /**
  61033. * Should we display highlight as a solid stroke?
  61034. */
  61035. isStroke?: boolean;
  61036. /**
  61037. * The rendering group to draw the layer in.
  61038. */
  61039. renderingGroupId: number;
  61040. }
  61041. /**
  61042. * The highlight layer Helps adding a glow effect around a mesh.
  61043. *
  61044. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61045. * glowy meshes to your scene.
  61046. *
  61047. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61048. */
  61049. export class HighlightLayer extends EffectLayer {
  61050. name: string;
  61051. /**
  61052. * Effect Name of the highlight layer.
  61053. */
  61054. static readonly EffectName: string;
  61055. /**
  61056. * The neutral color used during the preparation of the glow effect.
  61057. * This is black by default as the blend operation is a blend operation.
  61058. */
  61059. static NeutralColor: Color4;
  61060. /**
  61061. * Stencil value used for glowing meshes.
  61062. */
  61063. static GlowingMeshStencilReference: number;
  61064. /**
  61065. * Stencil value used for the other meshes in the scene.
  61066. */
  61067. static NormalMeshStencilReference: number;
  61068. /**
  61069. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61070. */
  61071. innerGlow: boolean;
  61072. /**
  61073. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61074. */
  61075. outerGlow: boolean;
  61076. /**
  61077. * Specifies the horizontal size of the blur.
  61078. */
  61079. set blurHorizontalSize(value: number);
  61080. /**
  61081. * Specifies the vertical size of the blur.
  61082. */
  61083. set blurVerticalSize(value: number);
  61084. /**
  61085. * Gets the horizontal size of the blur.
  61086. */
  61087. get blurHorizontalSize(): number;
  61088. /**
  61089. * Gets the vertical size of the blur.
  61090. */
  61091. get blurVerticalSize(): number;
  61092. /**
  61093. * An event triggered when the highlight layer is being blurred.
  61094. */
  61095. onBeforeBlurObservable: Observable<HighlightLayer>;
  61096. /**
  61097. * An event triggered when the highlight layer has been blurred.
  61098. */
  61099. onAfterBlurObservable: Observable<HighlightLayer>;
  61100. private _instanceGlowingMeshStencilReference;
  61101. private _options;
  61102. private _downSamplePostprocess;
  61103. private _horizontalBlurPostprocess;
  61104. private _verticalBlurPostprocess;
  61105. private _blurTexture;
  61106. private _meshes;
  61107. private _excludedMeshes;
  61108. /**
  61109. * Instantiates a new highlight Layer and references it to the scene..
  61110. * @param name The name of the layer
  61111. * @param scene The scene to use the layer in
  61112. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61113. */
  61114. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61115. /**
  61116. * Get the effect name of the layer.
  61117. * @return The effect name
  61118. */
  61119. getEffectName(): string;
  61120. /**
  61121. * Create the merge effect. This is the shader use to blit the information back
  61122. * to the main canvas at the end of the scene rendering.
  61123. */
  61124. protected _createMergeEffect(): Effect;
  61125. /**
  61126. * Creates the render target textures and post processes used in the highlight layer.
  61127. */
  61128. protected _createTextureAndPostProcesses(): void;
  61129. /**
  61130. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61131. */
  61132. needStencil(): boolean;
  61133. /**
  61134. * Checks for the readiness of the element composing the layer.
  61135. * @param subMesh the mesh to check for
  61136. * @param useInstances specify wether or not to use instances to render the mesh
  61137. * @param emissiveTexture the associated emissive texture used to generate the glow
  61138. * @return true if ready otherwise, false
  61139. */
  61140. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61141. /**
  61142. * Implementation specific of rendering the generating effect on the main canvas.
  61143. * @param effect The effect used to render through
  61144. */
  61145. protected _internalRender(effect: Effect): void;
  61146. /**
  61147. * Returns true if the layer contains information to display, otherwise false.
  61148. */
  61149. shouldRender(): boolean;
  61150. /**
  61151. * Returns true if the mesh should render, otherwise false.
  61152. * @param mesh The mesh to render
  61153. * @returns true if it should render otherwise false
  61154. */
  61155. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61156. /**
  61157. * Returns true if the mesh can be rendered, otherwise false.
  61158. * @param mesh The mesh to render
  61159. * @param material The material used on the mesh
  61160. * @returns true if it can be rendered otherwise false
  61161. */
  61162. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61163. /**
  61164. * Adds specific effects defines.
  61165. * @param defines The defines to add specifics to.
  61166. */
  61167. protected _addCustomEffectDefines(defines: string[]): void;
  61168. /**
  61169. * Sets the required values for both the emissive texture and and the main color.
  61170. */
  61171. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61172. /**
  61173. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61174. * @param mesh The mesh to exclude from the highlight layer
  61175. */
  61176. addExcludedMesh(mesh: Mesh): void;
  61177. /**
  61178. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61179. * @param mesh The mesh to highlight
  61180. */
  61181. removeExcludedMesh(mesh: Mesh): void;
  61182. /**
  61183. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61184. * @param mesh mesh to test
  61185. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61186. */
  61187. hasMesh(mesh: AbstractMesh): boolean;
  61188. /**
  61189. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61190. * @param mesh The mesh to highlight
  61191. * @param color The color of the highlight
  61192. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61193. */
  61194. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61195. /**
  61196. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61197. * @param mesh The mesh to highlight
  61198. */
  61199. removeMesh(mesh: Mesh): void;
  61200. /**
  61201. * Remove all the meshes currently referenced in the highlight layer
  61202. */
  61203. removeAllMeshes(): void;
  61204. /**
  61205. * Force the stencil to the normal expected value for none glowing parts
  61206. */
  61207. private _defaultStencilReference;
  61208. /**
  61209. * Free any resources and references associated to a mesh.
  61210. * Internal use
  61211. * @param mesh The mesh to free.
  61212. * @hidden
  61213. */
  61214. _disposeMesh(mesh: Mesh): void;
  61215. /**
  61216. * Dispose the highlight layer and free resources.
  61217. */
  61218. dispose(): void;
  61219. /**
  61220. * Gets the class name of the effect layer
  61221. * @returns the string with the class name of the effect layer
  61222. */
  61223. getClassName(): string;
  61224. /**
  61225. * Serializes this Highlight layer
  61226. * @returns a serialized Highlight layer object
  61227. */
  61228. serialize(): any;
  61229. /**
  61230. * Creates a Highlight layer from parsed Highlight layer data
  61231. * @param parsedHightlightLayer defines the Highlight layer data
  61232. * @param scene defines the current scene
  61233. * @param rootUrl defines the root URL containing the Highlight layer information
  61234. * @returns a parsed Highlight layer
  61235. */
  61236. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61237. }
  61238. }
  61239. declare module "babylonjs/Layers/layerSceneComponent" {
  61240. import { Scene } from "babylonjs/scene";
  61241. import { ISceneComponent } from "babylonjs/sceneComponent";
  61242. import { Layer } from "babylonjs/Layers/layer";
  61243. import { AbstractScene } from "babylonjs/abstractScene";
  61244. module "babylonjs/abstractScene" {
  61245. interface AbstractScene {
  61246. /**
  61247. * The list of layers (background and foreground) of the scene
  61248. */
  61249. layers: Array<Layer>;
  61250. }
  61251. }
  61252. /**
  61253. * Defines the layer scene component responsible to manage any layers
  61254. * in a given scene.
  61255. */
  61256. export class LayerSceneComponent implements ISceneComponent {
  61257. /**
  61258. * The component name helpfull to identify the component in the list of scene components.
  61259. */
  61260. readonly name: string;
  61261. /**
  61262. * The scene the component belongs to.
  61263. */
  61264. scene: Scene;
  61265. private _engine;
  61266. /**
  61267. * Creates a new instance of the component for the given scene
  61268. * @param scene Defines the scene to register the component in
  61269. */
  61270. constructor(scene: Scene);
  61271. /**
  61272. * Registers the component in a given scene
  61273. */
  61274. register(): void;
  61275. /**
  61276. * Rebuilds the elements related to this component in case of
  61277. * context lost for instance.
  61278. */
  61279. rebuild(): void;
  61280. /**
  61281. * Disposes the component and the associated ressources.
  61282. */
  61283. dispose(): void;
  61284. private _draw;
  61285. private _drawCameraPredicate;
  61286. private _drawCameraBackground;
  61287. private _drawCameraForeground;
  61288. private _drawRenderTargetPredicate;
  61289. private _drawRenderTargetBackground;
  61290. private _drawRenderTargetForeground;
  61291. /**
  61292. * Adds all the elements from the container to the scene
  61293. * @param container the container holding the elements
  61294. */
  61295. addFromContainer(container: AbstractScene): void;
  61296. /**
  61297. * Removes all the elements in the container from the scene
  61298. * @param container contains the elements to remove
  61299. * @param dispose if the removed element should be disposed (default: false)
  61300. */
  61301. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61302. }
  61303. }
  61304. declare module "babylonjs/Shaders/layer.fragment" {
  61305. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61306. /** @hidden */
  61307. export var layerPixelShader: {
  61308. name: string;
  61309. shader: string;
  61310. };
  61311. }
  61312. declare module "babylonjs/Shaders/layer.vertex" {
  61313. /** @hidden */
  61314. export var layerVertexShader: {
  61315. name: string;
  61316. shader: string;
  61317. };
  61318. }
  61319. declare module "babylonjs/Layers/layer" {
  61320. import { Observable } from "babylonjs/Misc/observable";
  61321. import { Nullable } from "babylonjs/types";
  61322. import { Scene } from "babylonjs/scene";
  61323. import { Vector2 } from "babylonjs/Maths/math.vector";
  61324. import { Color4 } from "babylonjs/Maths/math.color";
  61325. import { Texture } from "babylonjs/Materials/Textures/texture";
  61326. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61327. import "babylonjs/Shaders/layer.fragment";
  61328. import "babylonjs/Shaders/layer.vertex";
  61329. /**
  61330. * This represents a full screen 2d layer.
  61331. * This can be useful to display a picture in the background of your scene for instance.
  61332. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61333. */
  61334. export class Layer {
  61335. /**
  61336. * Define the name of the layer.
  61337. */
  61338. name: string;
  61339. /**
  61340. * Define the texture the layer should display.
  61341. */
  61342. texture: Nullable<Texture>;
  61343. /**
  61344. * Is the layer in background or foreground.
  61345. */
  61346. isBackground: boolean;
  61347. /**
  61348. * Define the color of the layer (instead of texture).
  61349. */
  61350. color: Color4;
  61351. /**
  61352. * Define the scale of the layer in order to zoom in out of the texture.
  61353. */
  61354. scale: Vector2;
  61355. /**
  61356. * Define an offset for the layer in order to shift the texture.
  61357. */
  61358. offset: Vector2;
  61359. /**
  61360. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61361. */
  61362. alphaBlendingMode: number;
  61363. /**
  61364. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61365. * Alpha test will not mix with the background color in case of transparency.
  61366. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61367. */
  61368. alphaTest: boolean;
  61369. /**
  61370. * Define a mask to restrict the layer to only some of the scene cameras.
  61371. */
  61372. layerMask: number;
  61373. /**
  61374. * Define the list of render target the layer is visible into.
  61375. */
  61376. renderTargetTextures: RenderTargetTexture[];
  61377. /**
  61378. * Define if the layer is only used in renderTarget or if it also
  61379. * renders in the main frame buffer of the canvas.
  61380. */
  61381. renderOnlyInRenderTargetTextures: boolean;
  61382. private _scene;
  61383. private _vertexBuffers;
  61384. private _indexBuffer;
  61385. private _effect;
  61386. private _previousDefines;
  61387. /**
  61388. * An event triggered when the layer is disposed.
  61389. */
  61390. onDisposeObservable: Observable<Layer>;
  61391. private _onDisposeObserver;
  61392. /**
  61393. * Back compatibility with callback before the onDisposeObservable existed.
  61394. * The set callback will be triggered when the layer has been disposed.
  61395. */
  61396. set onDispose(callback: () => void);
  61397. /**
  61398. * An event triggered before rendering the scene
  61399. */
  61400. onBeforeRenderObservable: Observable<Layer>;
  61401. private _onBeforeRenderObserver;
  61402. /**
  61403. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61404. * The set callback will be triggered just before rendering the layer.
  61405. */
  61406. set onBeforeRender(callback: () => void);
  61407. /**
  61408. * An event triggered after rendering the scene
  61409. */
  61410. onAfterRenderObservable: Observable<Layer>;
  61411. private _onAfterRenderObserver;
  61412. /**
  61413. * Back compatibility with callback before the onAfterRenderObservable existed.
  61414. * The set callback will be triggered just after rendering the layer.
  61415. */
  61416. set onAfterRender(callback: () => void);
  61417. /**
  61418. * Instantiates a new layer.
  61419. * This represents a full screen 2d layer.
  61420. * This can be useful to display a picture in the background of your scene for instance.
  61421. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61422. * @param name Define the name of the layer in the scene
  61423. * @param imgUrl Define the url of the texture to display in the layer
  61424. * @param scene Define the scene the layer belongs to
  61425. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61426. * @param color Defines a color for the layer
  61427. */
  61428. constructor(
  61429. /**
  61430. * Define the name of the layer.
  61431. */
  61432. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61433. private _createIndexBuffer;
  61434. /** @hidden */
  61435. _rebuild(): void;
  61436. /**
  61437. * Renders the layer in the scene.
  61438. */
  61439. render(): void;
  61440. /**
  61441. * Disposes and releases the associated ressources.
  61442. */
  61443. dispose(): void;
  61444. }
  61445. }
  61446. declare module "babylonjs/Layers/index" {
  61447. export * from "babylonjs/Layers/effectLayer";
  61448. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61449. export * from "babylonjs/Layers/glowLayer";
  61450. export * from "babylonjs/Layers/highlightLayer";
  61451. export * from "babylonjs/Layers/layer";
  61452. export * from "babylonjs/Layers/layerSceneComponent";
  61453. }
  61454. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61455. /** @hidden */
  61456. export var lensFlarePixelShader: {
  61457. name: string;
  61458. shader: string;
  61459. };
  61460. }
  61461. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61462. /** @hidden */
  61463. export var lensFlareVertexShader: {
  61464. name: string;
  61465. shader: string;
  61466. };
  61467. }
  61468. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61469. import { Scene } from "babylonjs/scene";
  61470. import { Vector3 } from "babylonjs/Maths/math.vector";
  61471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61472. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61473. import "babylonjs/Shaders/lensFlare.fragment";
  61474. import "babylonjs/Shaders/lensFlare.vertex";
  61475. import { Viewport } from "babylonjs/Maths/math.viewport";
  61476. /**
  61477. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61478. * It is usually composed of several `lensFlare`.
  61479. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61480. */
  61481. export class LensFlareSystem {
  61482. /**
  61483. * Define the name of the lens flare system
  61484. */
  61485. name: string;
  61486. /**
  61487. * List of lens flares used in this system.
  61488. */
  61489. lensFlares: LensFlare[];
  61490. /**
  61491. * Define a limit from the border the lens flare can be visible.
  61492. */
  61493. borderLimit: number;
  61494. /**
  61495. * Define a viewport border we do not want to see the lens flare in.
  61496. */
  61497. viewportBorder: number;
  61498. /**
  61499. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61500. */
  61501. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61502. /**
  61503. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61504. */
  61505. layerMask: number;
  61506. /**
  61507. * Define the id of the lens flare system in the scene.
  61508. * (equal to name by default)
  61509. */
  61510. id: string;
  61511. private _scene;
  61512. private _emitter;
  61513. private _vertexBuffers;
  61514. private _indexBuffer;
  61515. private _effect;
  61516. private _positionX;
  61517. private _positionY;
  61518. private _isEnabled;
  61519. /** @hidden */
  61520. static _SceneComponentInitialization: (scene: Scene) => void;
  61521. /**
  61522. * Instantiates a lens flare system.
  61523. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61524. * It is usually composed of several `lensFlare`.
  61525. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61526. * @param name Define the name of the lens flare system in the scene
  61527. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61528. * @param scene Define the scene the lens flare system belongs to
  61529. */
  61530. constructor(
  61531. /**
  61532. * Define the name of the lens flare system
  61533. */
  61534. name: string, emitter: any, scene: Scene);
  61535. /**
  61536. * Define if the lens flare system is enabled.
  61537. */
  61538. get isEnabled(): boolean;
  61539. set isEnabled(value: boolean);
  61540. /**
  61541. * Get the scene the effects belongs to.
  61542. * @returns the scene holding the lens flare system
  61543. */
  61544. getScene(): Scene;
  61545. /**
  61546. * Get the emitter of the lens flare system.
  61547. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61548. * @returns the emitter of the lens flare system
  61549. */
  61550. getEmitter(): any;
  61551. /**
  61552. * Set the emitter of the lens flare system.
  61553. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61554. * @param newEmitter Define the new emitter of the system
  61555. */
  61556. setEmitter(newEmitter: any): void;
  61557. /**
  61558. * Get the lens flare system emitter position.
  61559. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61560. * @returns the position
  61561. */
  61562. getEmitterPosition(): Vector3;
  61563. /**
  61564. * @hidden
  61565. */
  61566. computeEffectivePosition(globalViewport: Viewport): boolean;
  61567. /** @hidden */
  61568. _isVisible(): boolean;
  61569. /**
  61570. * @hidden
  61571. */
  61572. render(): boolean;
  61573. /**
  61574. * Dispose and release the lens flare with its associated resources.
  61575. */
  61576. dispose(): void;
  61577. /**
  61578. * Parse a lens flare system from a JSON repressentation
  61579. * @param parsedLensFlareSystem Define the JSON to parse
  61580. * @param scene Define the scene the parsed system should be instantiated in
  61581. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61582. * @returns the parsed system
  61583. */
  61584. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61585. /**
  61586. * Serialize the current Lens Flare System into a JSON representation.
  61587. * @returns the serialized JSON
  61588. */
  61589. serialize(): any;
  61590. }
  61591. }
  61592. declare module "babylonjs/LensFlares/lensFlare" {
  61593. import { Nullable } from "babylonjs/types";
  61594. import { Color3 } from "babylonjs/Maths/math.color";
  61595. import { Texture } from "babylonjs/Materials/Textures/texture";
  61596. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61597. /**
  61598. * This represents one of the lens effect in a `lensFlareSystem`.
  61599. * It controls one of the indiviual texture used in the effect.
  61600. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61601. */
  61602. export class LensFlare {
  61603. /**
  61604. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61605. */
  61606. size: number;
  61607. /**
  61608. * 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.
  61609. */
  61610. position: number;
  61611. /**
  61612. * Define the lens color.
  61613. */
  61614. color: Color3;
  61615. /**
  61616. * Define the lens texture.
  61617. */
  61618. texture: Nullable<Texture>;
  61619. /**
  61620. * Define the alpha mode to render this particular lens.
  61621. */
  61622. alphaMode: number;
  61623. private _system;
  61624. /**
  61625. * Creates a new Lens Flare.
  61626. * This represents one of the lens effect in a `lensFlareSystem`.
  61627. * It controls one of the indiviual texture used in the effect.
  61628. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61629. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61630. * @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.
  61631. * @param color Define the lens color
  61632. * @param imgUrl Define the lens texture url
  61633. * @param system Define the `lensFlareSystem` this flare is part of
  61634. * @returns The newly created Lens Flare
  61635. */
  61636. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61637. /**
  61638. * Instantiates a new Lens Flare.
  61639. * This represents one of the lens effect in a `lensFlareSystem`.
  61640. * It controls one of the indiviual texture used in the effect.
  61641. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61642. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61643. * @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.
  61644. * @param color Define the lens color
  61645. * @param imgUrl Define the lens texture url
  61646. * @param system Define the `lensFlareSystem` this flare is part of
  61647. */
  61648. constructor(
  61649. /**
  61650. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61651. */
  61652. size: number,
  61653. /**
  61654. * 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.
  61655. */
  61656. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61657. /**
  61658. * Dispose and release the lens flare with its associated resources.
  61659. */
  61660. dispose(): void;
  61661. }
  61662. }
  61663. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61664. import { Nullable } from "babylonjs/types";
  61665. import { Scene } from "babylonjs/scene";
  61666. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61667. import { AbstractScene } from "babylonjs/abstractScene";
  61668. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61669. module "babylonjs/abstractScene" {
  61670. interface AbstractScene {
  61671. /**
  61672. * The list of lens flare system added to the scene
  61673. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61674. */
  61675. lensFlareSystems: Array<LensFlareSystem>;
  61676. /**
  61677. * Removes the given lens flare system from this scene.
  61678. * @param toRemove The lens flare system to remove
  61679. * @returns The index of the removed lens flare system
  61680. */
  61681. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61682. /**
  61683. * Adds the given lens flare system to this scene
  61684. * @param newLensFlareSystem The lens flare system to add
  61685. */
  61686. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61687. /**
  61688. * Gets a lens flare system using its name
  61689. * @param name defines the name to look for
  61690. * @returns the lens flare system or null if not found
  61691. */
  61692. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61693. /**
  61694. * Gets a lens flare system using its id
  61695. * @param id defines the id to look for
  61696. * @returns the lens flare system or null if not found
  61697. */
  61698. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61699. }
  61700. }
  61701. /**
  61702. * Defines the lens flare scene component responsible to manage any lens flares
  61703. * in a given scene.
  61704. */
  61705. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61706. /**
  61707. * The component name helpfull to identify the component in the list of scene components.
  61708. */
  61709. readonly name: string;
  61710. /**
  61711. * The scene the component belongs to.
  61712. */
  61713. scene: Scene;
  61714. /**
  61715. * Creates a new instance of the component for the given scene
  61716. * @param scene Defines the scene to register the component in
  61717. */
  61718. constructor(scene: Scene);
  61719. /**
  61720. * Registers the component in a given scene
  61721. */
  61722. register(): void;
  61723. /**
  61724. * Rebuilds the elements related to this component in case of
  61725. * context lost for instance.
  61726. */
  61727. rebuild(): void;
  61728. /**
  61729. * Adds all the elements from the container to the scene
  61730. * @param container the container holding the elements
  61731. */
  61732. addFromContainer(container: AbstractScene): void;
  61733. /**
  61734. * Removes all the elements in the container from the scene
  61735. * @param container contains the elements to remove
  61736. * @param dispose if the removed element should be disposed (default: false)
  61737. */
  61738. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61739. /**
  61740. * Serializes the component data to the specified json object
  61741. * @param serializationObject The object to serialize to
  61742. */
  61743. serialize(serializationObject: any): void;
  61744. /**
  61745. * Disposes the component and the associated ressources.
  61746. */
  61747. dispose(): void;
  61748. private _draw;
  61749. }
  61750. }
  61751. declare module "babylonjs/LensFlares/index" {
  61752. export * from "babylonjs/LensFlares/lensFlare";
  61753. export * from "babylonjs/LensFlares/lensFlareSystem";
  61754. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61755. }
  61756. declare module "babylonjs/Shaders/depth.fragment" {
  61757. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61758. /** @hidden */
  61759. export var depthPixelShader: {
  61760. name: string;
  61761. shader: string;
  61762. };
  61763. }
  61764. declare module "babylonjs/Shaders/depth.vertex" {
  61765. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61766. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61767. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61768. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61769. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61770. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61771. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61772. /** @hidden */
  61773. export var depthVertexShader: {
  61774. name: string;
  61775. shader: string;
  61776. };
  61777. }
  61778. declare module "babylonjs/Rendering/depthRenderer" {
  61779. import { Nullable } from "babylonjs/types";
  61780. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61781. import { Scene } from "babylonjs/scene";
  61782. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61783. import { Camera } from "babylonjs/Cameras/camera";
  61784. import "babylonjs/Shaders/depth.fragment";
  61785. import "babylonjs/Shaders/depth.vertex";
  61786. /**
  61787. * This represents a depth renderer in Babylon.
  61788. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61789. */
  61790. export class DepthRenderer {
  61791. private _scene;
  61792. private _depthMap;
  61793. private _effect;
  61794. private readonly _storeNonLinearDepth;
  61795. private readonly _clearColor;
  61796. /** Get if the depth renderer is using packed depth or not */
  61797. readonly isPacked: boolean;
  61798. private _cachedDefines;
  61799. private _camera;
  61800. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61801. enabled: boolean;
  61802. /**
  61803. * Specifiess that the depth renderer will only be used within
  61804. * the camera it is created for.
  61805. * This can help forcing its rendering during the camera processing.
  61806. */
  61807. useOnlyInActiveCamera: boolean;
  61808. /** @hidden */
  61809. static _SceneComponentInitialization: (scene: Scene) => void;
  61810. /**
  61811. * Instantiates a depth renderer
  61812. * @param scene The scene the renderer belongs to
  61813. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61814. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61815. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61816. */
  61817. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61818. /**
  61819. * Creates the depth rendering effect and checks if the effect is ready.
  61820. * @param subMesh The submesh to be used to render the depth map of
  61821. * @param useInstances If multiple world instances should be used
  61822. * @returns if the depth renderer is ready to render the depth map
  61823. */
  61824. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61825. /**
  61826. * Gets the texture which the depth map will be written to.
  61827. * @returns The depth map texture
  61828. */
  61829. getDepthMap(): RenderTargetTexture;
  61830. /**
  61831. * Disposes of the depth renderer.
  61832. */
  61833. dispose(): void;
  61834. }
  61835. }
  61836. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61837. /** @hidden */
  61838. export var minmaxReduxPixelShader: {
  61839. name: string;
  61840. shader: string;
  61841. };
  61842. }
  61843. declare module "babylonjs/Misc/minMaxReducer" {
  61844. import { Nullable } from "babylonjs/types";
  61845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61846. import { Camera } from "babylonjs/Cameras/camera";
  61847. import { Observer } from "babylonjs/Misc/observable";
  61848. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61849. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61850. import { Observable } from "babylonjs/Misc/observable";
  61851. import "babylonjs/Shaders/minmaxRedux.fragment";
  61852. /**
  61853. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61854. * and maximum values from all values of the texture.
  61855. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61856. * The source values are read from the red channel of the texture.
  61857. */
  61858. export class MinMaxReducer {
  61859. /**
  61860. * Observable triggered when the computation has been performed
  61861. */
  61862. onAfterReductionPerformed: Observable<{
  61863. min: number;
  61864. max: number;
  61865. }>;
  61866. protected _camera: Camera;
  61867. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61868. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61869. protected _postProcessManager: PostProcessManager;
  61870. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61871. protected _forceFullscreenViewport: boolean;
  61872. /**
  61873. * Creates a min/max reducer
  61874. * @param camera The camera to use for the post processes
  61875. */
  61876. constructor(camera: Camera);
  61877. /**
  61878. * Gets the texture used to read the values from.
  61879. */
  61880. get sourceTexture(): Nullable<RenderTargetTexture>;
  61881. /**
  61882. * Sets the source texture to read the values from.
  61883. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61884. * because in such textures '1' value must not be taken into account to compute the maximum
  61885. * as this value is used to clear the texture.
  61886. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61887. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61888. * @param depthRedux Indicates if the texture is a depth texture or not
  61889. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61890. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61891. */
  61892. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61893. /**
  61894. * Defines the refresh rate of the computation.
  61895. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61896. */
  61897. get refreshRate(): number;
  61898. set refreshRate(value: number);
  61899. protected _activated: boolean;
  61900. /**
  61901. * Gets the activation status of the reducer
  61902. */
  61903. get activated(): boolean;
  61904. /**
  61905. * Activates the reduction computation.
  61906. * When activated, the observers registered in onAfterReductionPerformed are
  61907. * called after the compuation is performed
  61908. */
  61909. activate(): void;
  61910. /**
  61911. * Deactivates the reduction computation.
  61912. */
  61913. deactivate(): void;
  61914. /**
  61915. * Disposes the min/max reducer
  61916. * @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.
  61917. */
  61918. dispose(disposeAll?: boolean): void;
  61919. }
  61920. }
  61921. declare module "babylonjs/Misc/depthReducer" {
  61922. import { Nullable } from "babylonjs/types";
  61923. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61924. import { Camera } from "babylonjs/Cameras/camera";
  61925. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61926. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61927. /**
  61928. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61929. */
  61930. export class DepthReducer extends MinMaxReducer {
  61931. private _depthRenderer;
  61932. private _depthRendererId;
  61933. /**
  61934. * Gets the depth renderer used for the computation.
  61935. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61936. */
  61937. get depthRenderer(): Nullable<DepthRenderer>;
  61938. /**
  61939. * Creates a depth reducer
  61940. * @param camera The camera used to render the depth texture
  61941. */
  61942. constructor(camera: Camera);
  61943. /**
  61944. * Sets the depth renderer to use to generate the depth map
  61945. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61946. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61947. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61948. */
  61949. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61950. /** @hidden */
  61951. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61952. /**
  61953. * Activates the reduction computation.
  61954. * When activated, the observers registered in onAfterReductionPerformed are
  61955. * called after the compuation is performed
  61956. */
  61957. activate(): void;
  61958. /**
  61959. * Deactivates the reduction computation.
  61960. */
  61961. deactivate(): void;
  61962. /**
  61963. * Disposes the depth reducer
  61964. * @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.
  61965. */
  61966. dispose(disposeAll?: boolean): void;
  61967. }
  61968. }
  61969. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61970. import { Nullable } from "babylonjs/types";
  61971. import { Scene } from "babylonjs/scene";
  61972. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61973. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61975. import { Effect } from "babylonjs/Materials/effect";
  61976. import "babylonjs/Shaders/shadowMap.fragment";
  61977. import "babylonjs/Shaders/shadowMap.vertex";
  61978. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61979. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61980. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61981. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61982. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61983. /**
  61984. * A CSM implementation allowing casting shadows on large scenes.
  61985. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61986. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61987. */
  61988. export class CascadedShadowGenerator extends ShadowGenerator {
  61989. private static readonly frustumCornersNDCSpace;
  61990. /**
  61991. * Name of the CSM class
  61992. */
  61993. static CLASSNAME: string;
  61994. /**
  61995. * Defines the default number of cascades used by the CSM.
  61996. */
  61997. static readonly DEFAULT_CASCADES_COUNT: number;
  61998. /**
  61999. * Defines the minimum number of cascades used by the CSM.
  62000. */
  62001. static readonly MIN_CASCADES_COUNT: number;
  62002. /**
  62003. * Defines the maximum number of cascades used by the CSM.
  62004. */
  62005. static readonly MAX_CASCADES_COUNT: number;
  62006. protected _validateFilter(filter: number): number;
  62007. /**
  62008. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62009. */
  62010. penumbraDarkness: number;
  62011. private _numCascades;
  62012. /**
  62013. * Gets or set the number of cascades used by the CSM.
  62014. */
  62015. get numCascades(): number;
  62016. set numCascades(value: number);
  62017. /**
  62018. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62019. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62020. */
  62021. stabilizeCascades: boolean;
  62022. private _freezeShadowCastersBoundingInfo;
  62023. private _freezeShadowCastersBoundingInfoObservable;
  62024. /**
  62025. * Enables or disables the shadow casters bounding info computation.
  62026. * If your shadow casters don't move, you can disable this feature.
  62027. * If it is enabled, the bounding box computation is done every frame.
  62028. */
  62029. get freezeShadowCastersBoundingInfo(): boolean;
  62030. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62031. private _scbiMin;
  62032. private _scbiMax;
  62033. protected _computeShadowCastersBoundingInfo(): void;
  62034. protected _shadowCastersBoundingInfo: BoundingInfo;
  62035. /**
  62036. * Gets or sets the shadow casters bounding info.
  62037. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62038. * so that the system won't overwrite the bounds you provide
  62039. */
  62040. get shadowCastersBoundingInfo(): BoundingInfo;
  62041. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62042. protected _breaksAreDirty: boolean;
  62043. protected _minDistance: number;
  62044. protected _maxDistance: number;
  62045. /**
  62046. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62047. *
  62048. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62049. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62050. * @param min minimal distance for the breaks (default to 0.)
  62051. * @param max maximal distance for the breaks (default to 1.)
  62052. */
  62053. setMinMaxDistance(min: number, max: number): void;
  62054. /** Gets the minimal distance used in the cascade break computation */
  62055. get minDistance(): number;
  62056. /** Gets the maximal distance used in the cascade break computation */
  62057. get maxDistance(): number;
  62058. /**
  62059. * Gets the class name of that object
  62060. * @returns "CascadedShadowGenerator"
  62061. */
  62062. getClassName(): string;
  62063. private _cascadeMinExtents;
  62064. private _cascadeMaxExtents;
  62065. /**
  62066. * Gets a cascade minimum extents
  62067. * @param cascadeIndex index of the cascade
  62068. * @returns the minimum cascade extents
  62069. */
  62070. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62071. /**
  62072. * Gets a cascade maximum extents
  62073. * @param cascadeIndex index of the cascade
  62074. * @returns the maximum cascade extents
  62075. */
  62076. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62077. private _cascades;
  62078. private _currentLayer;
  62079. private _viewSpaceFrustumsZ;
  62080. private _viewMatrices;
  62081. private _projectionMatrices;
  62082. private _transformMatrices;
  62083. private _transformMatricesAsArray;
  62084. private _frustumLengths;
  62085. private _lightSizeUVCorrection;
  62086. private _depthCorrection;
  62087. private _frustumCornersWorldSpace;
  62088. private _frustumCenter;
  62089. private _shadowCameraPos;
  62090. private _shadowMaxZ;
  62091. /**
  62092. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62093. * It defaults to camera.maxZ
  62094. */
  62095. get shadowMaxZ(): number;
  62096. /**
  62097. * Sets the shadow max z distance.
  62098. */
  62099. set shadowMaxZ(value: number);
  62100. protected _debug: boolean;
  62101. /**
  62102. * Gets or sets the debug flag.
  62103. * When enabled, the cascades are materialized by different colors on the screen.
  62104. */
  62105. get debug(): boolean;
  62106. set debug(dbg: boolean);
  62107. private _depthClamp;
  62108. /**
  62109. * Gets or sets the depth clamping value.
  62110. *
  62111. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62112. * to account for the shadow casters far away.
  62113. *
  62114. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62115. */
  62116. get depthClamp(): boolean;
  62117. set depthClamp(value: boolean);
  62118. private _cascadeBlendPercentage;
  62119. /**
  62120. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62121. * It defaults to 0.1 (10% blending).
  62122. */
  62123. get cascadeBlendPercentage(): number;
  62124. set cascadeBlendPercentage(value: number);
  62125. private _lambda;
  62126. /**
  62127. * Gets or set the lambda parameter.
  62128. * This parameter is used to split the camera frustum and create the cascades.
  62129. * 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.
  62130. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62131. */
  62132. get lambda(): number;
  62133. set lambda(value: number);
  62134. /**
  62135. * Gets the view matrix corresponding to a given cascade
  62136. * @param cascadeNum cascade to retrieve the view matrix from
  62137. * @returns the cascade view matrix
  62138. */
  62139. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62140. /**
  62141. * Gets the projection matrix corresponding to a given cascade
  62142. * @param cascadeNum cascade to retrieve the projection matrix from
  62143. * @returns the cascade projection matrix
  62144. */
  62145. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62146. /**
  62147. * Gets the transformation matrix corresponding to a given cascade
  62148. * @param cascadeNum cascade to retrieve the transformation matrix from
  62149. * @returns the cascade transformation matrix
  62150. */
  62151. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62152. private _depthRenderer;
  62153. /**
  62154. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62155. *
  62156. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62157. *
  62158. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62159. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62160. * @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
  62161. */
  62162. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62163. private _depthReducer;
  62164. private _autoCalcDepthBounds;
  62165. /**
  62166. * Gets or sets the autoCalcDepthBounds property.
  62167. *
  62168. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62169. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62170. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62171. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62172. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62173. */
  62174. get autoCalcDepthBounds(): boolean;
  62175. set autoCalcDepthBounds(value: boolean);
  62176. /**
  62177. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62178. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62179. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62180. * for setting the refresh rate on the renderer yourself!
  62181. */
  62182. get autoCalcDepthBoundsRefreshRate(): number;
  62183. set autoCalcDepthBoundsRefreshRate(value: number);
  62184. /**
  62185. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62186. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62187. * you change the camera near/far planes!
  62188. */
  62189. splitFrustum(): void;
  62190. private _splitFrustum;
  62191. private _computeMatrices;
  62192. private _computeFrustumInWorldSpace;
  62193. private _computeCascadeFrustum;
  62194. /**
  62195. * Support test.
  62196. */
  62197. static get IsSupported(): boolean;
  62198. /** @hidden */
  62199. static _SceneComponentInitialization: (scene: Scene) => void;
  62200. /**
  62201. * Creates a Cascaded Shadow Generator object.
  62202. * A ShadowGenerator is the required tool to use the shadows.
  62203. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62204. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62205. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62206. * @param light The directional light object generating the shadows.
  62207. * @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.
  62208. */
  62209. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62210. protected _initializeGenerator(): void;
  62211. protected _createTargetRenderTexture(): void;
  62212. protected _initializeShadowMap(): void;
  62213. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62214. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62215. /**
  62216. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62217. * @param defines Defines of the material we want to update
  62218. * @param lightIndex Index of the light in the enabled light list of the material
  62219. */
  62220. prepareDefines(defines: any, lightIndex: number): void;
  62221. /**
  62222. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62223. * defined in the generator but impacting the effect).
  62224. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62225. * @param effect The effect we are binfing the information for
  62226. */
  62227. bindShadowLight(lightIndex: string, effect: Effect): void;
  62228. /**
  62229. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62230. * (eq to view projection * shadow projection matrices)
  62231. * @returns The transform matrix used to create the shadow map
  62232. */
  62233. getTransformMatrix(): Matrix;
  62234. /**
  62235. * Disposes the ShadowGenerator.
  62236. * Returns nothing.
  62237. */
  62238. dispose(): void;
  62239. /**
  62240. * Serializes the shadow generator setup to a json object.
  62241. * @returns The serialized JSON object
  62242. */
  62243. serialize(): any;
  62244. /**
  62245. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62246. * @param parsedShadowGenerator The JSON object to parse
  62247. * @param scene The scene to create the shadow map for
  62248. * @returns The parsed shadow generator
  62249. */
  62250. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62251. }
  62252. }
  62253. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62254. import { Scene } from "babylonjs/scene";
  62255. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62256. import { AbstractScene } from "babylonjs/abstractScene";
  62257. /**
  62258. * Defines the shadow generator component responsible to manage any shadow generators
  62259. * in a given scene.
  62260. */
  62261. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62262. /**
  62263. * The component name helpfull to identify the component in the list of scene components.
  62264. */
  62265. readonly name: string;
  62266. /**
  62267. * The scene the component belongs to.
  62268. */
  62269. scene: Scene;
  62270. /**
  62271. * Creates a new instance of the component for the given scene
  62272. * @param scene Defines the scene to register the component in
  62273. */
  62274. constructor(scene: Scene);
  62275. /**
  62276. * Registers the component in a given scene
  62277. */
  62278. register(): void;
  62279. /**
  62280. * Rebuilds the elements related to this component in case of
  62281. * context lost for instance.
  62282. */
  62283. rebuild(): void;
  62284. /**
  62285. * Serializes the component data to the specified json object
  62286. * @param serializationObject The object to serialize to
  62287. */
  62288. serialize(serializationObject: any): void;
  62289. /**
  62290. * Adds all the elements from the container to the scene
  62291. * @param container the container holding the elements
  62292. */
  62293. addFromContainer(container: AbstractScene): void;
  62294. /**
  62295. * Removes all the elements in the container from the scene
  62296. * @param container contains the elements to remove
  62297. * @param dispose if the removed element should be disposed (default: false)
  62298. */
  62299. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62300. /**
  62301. * Rebuilds the elements related to this component in case of
  62302. * context lost for instance.
  62303. */
  62304. dispose(): void;
  62305. private _gatherRenderTargets;
  62306. }
  62307. }
  62308. declare module "babylonjs/Lights/Shadows/index" {
  62309. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62310. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62311. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62312. }
  62313. declare module "babylonjs/Lights/pointLight" {
  62314. import { Scene } from "babylonjs/scene";
  62315. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62317. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62318. import { Effect } from "babylonjs/Materials/effect";
  62319. /**
  62320. * A point light is a light defined by an unique point in world space.
  62321. * The light is emitted in every direction from this point.
  62322. * A good example of a point light is a standard light bulb.
  62323. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62324. */
  62325. export class PointLight extends ShadowLight {
  62326. private _shadowAngle;
  62327. /**
  62328. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62329. * This specifies what angle the shadow will use to be created.
  62330. *
  62331. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62332. */
  62333. get shadowAngle(): number;
  62334. /**
  62335. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62336. * This specifies what angle the shadow will use to be created.
  62337. *
  62338. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62339. */
  62340. set shadowAngle(value: number);
  62341. /**
  62342. * Gets the direction if it has been set.
  62343. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62344. */
  62345. get direction(): Vector3;
  62346. /**
  62347. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62348. */
  62349. set direction(value: Vector3);
  62350. /**
  62351. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62352. * A PointLight emits the light in every direction.
  62353. * It can cast shadows.
  62354. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62355. * ```javascript
  62356. * var pointLight = new PointLight("pl", camera.position, scene);
  62357. * ```
  62358. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62359. * @param name The light friendly name
  62360. * @param position The position of the point light in the scene
  62361. * @param scene The scene the lights belongs to
  62362. */
  62363. constructor(name: string, position: Vector3, scene: Scene);
  62364. /**
  62365. * Returns the string "PointLight"
  62366. * @returns the class name
  62367. */
  62368. getClassName(): string;
  62369. /**
  62370. * Returns the integer 0.
  62371. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62372. */
  62373. getTypeID(): number;
  62374. /**
  62375. * Specifies wether or not the shadowmap should be a cube texture.
  62376. * @returns true if the shadowmap needs to be a cube texture.
  62377. */
  62378. needCube(): boolean;
  62379. /**
  62380. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62381. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62382. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62383. */
  62384. getShadowDirection(faceIndex?: number): Vector3;
  62385. /**
  62386. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62387. * - fov = PI / 2
  62388. * - aspect ratio : 1.0
  62389. * - z-near and far equal to the active camera minZ and maxZ.
  62390. * Returns the PointLight.
  62391. */
  62392. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62393. protected _buildUniformLayout(): void;
  62394. /**
  62395. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62396. * @param effect The effect to update
  62397. * @param lightIndex The index of the light in the effect to update
  62398. * @returns The point light
  62399. */
  62400. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62401. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62402. /**
  62403. * Prepares the list of defines specific to the light type.
  62404. * @param defines the list of defines
  62405. * @param lightIndex defines the index of the light for the effect
  62406. */
  62407. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62408. }
  62409. }
  62410. declare module "babylonjs/Lights/index" {
  62411. export * from "babylonjs/Lights/light";
  62412. export * from "babylonjs/Lights/shadowLight";
  62413. export * from "babylonjs/Lights/Shadows/index";
  62414. export * from "babylonjs/Lights/directionalLight";
  62415. export * from "babylonjs/Lights/hemisphericLight";
  62416. export * from "babylonjs/Lights/pointLight";
  62417. export * from "babylonjs/Lights/spotLight";
  62418. }
  62419. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62420. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62421. /**
  62422. * Header information of HDR texture files.
  62423. */
  62424. export interface HDRInfo {
  62425. /**
  62426. * The height of the texture in pixels.
  62427. */
  62428. height: number;
  62429. /**
  62430. * The width of the texture in pixels.
  62431. */
  62432. width: number;
  62433. /**
  62434. * The index of the beginning of the data in the binary file.
  62435. */
  62436. dataPosition: number;
  62437. }
  62438. /**
  62439. * This groups tools to convert HDR texture to native colors array.
  62440. */
  62441. export class HDRTools {
  62442. private static Ldexp;
  62443. private static Rgbe2float;
  62444. private static readStringLine;
  62445. /**
  62446. * Reads header information from an RGBE texture stored in a native array.
  62447. * More information on this format are available here:
  62448. * https://en.wikipedia.org/wiki/RGBE_image_format
  62449. *
  62450. * @param uint8array The binary file stored in native array.
  62451. * @return The header information.
  62452. */
  62453. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62454. /**
  62455. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62456. * This RGBE texture needs to store the information as a panorama.
  62457. *
  62458. * More information on this format are available here:
  62459. * https://en.wikipedia.org/wiki/RGBE_image_format
  62460. *
  62461. * @param buffer The binary file stored in an array buffer.
  62462. * @param size The expected size of the extracted cubemap.
  62463. * @return The Cube Map information.
  62464. */
  62465. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62466. /**
  62467. * Returns the pixels data extracted from an RGBE texture.
  62468. * This pixels will be stored left to right up to down in the R G B order in one array.
  62469. *
  62470. * More information on this format are available here:
  62471. * https://en.wikipedia.org/wiki/RGBE_image_format
  62472. *
  62473. * @param uint8array The binary file stored in an array buffer.
  62474. * @param hdrInfo The header information of the file.
  62475. * @return The pixels data in RGB right to left up to down order.
  62476. */
  62477. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62478. private static RGBE_ReadPixels_RLE;
  62479. private static RGBE_ReadPixels_NOT_RLE;
  62480. }
  62481. }
  62482. declare module "babylonjs/Materials/effectRenderer" {
  62483. import { Nullable } from "babylonjs/types";
  62484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62485. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62486. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62487. import { Viewport } from "babylonjs/Maths/math.viewport";
  62488. import { Observable } from "babylonjs/Misc/observable";
  62489. import { Effect } from "babylonjs/Materials/effect";
  62490. import "babylonjs/Shaders/postprocess.vertex";
  62491. /**
  62492. * Effect Render Options
  62493. */
  62494. export interface IEffectRendererOptions {
  62495. /**
  62496. * Defines the vertices positions.
  62497. */
  62498. positions?: number[];
  62499. /**
  62500. * Defines the indices.
  62501. */
  62502. indices?: number[];
  62503. }
  62504. /**
  62505. * Helper class to render one or more effects.
  62506. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62507. */
  62508. export class EffectRenderer {
  62509. private engine;
  62510. private static _DefaultOptions;
  62511. private _vertexBuffers;
  62512. private _indexBuffer;
  62513. private _fullscreenViewport;
  62514. /**
  62515. * Creates an effect renderer
  62516. * @param engine the engine to use for rendering
  62517. * @param options defines the options of the effect renderer
  62518. */
  62519. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62520. /**
  62521. * Sets the current viewport in normalized coordinates 0-1
  62522. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62523. */
  62524. setViewport(viewport?: Viewport): void;
  62525. /**
  62526. * Binds the embedded attributes buffer to the effect.
  62527. * @param effect Defines the effect to bind the attributes for
  62528. */
  62529. bindBuffers(effect: Effect): void;
  62530. /**
  62531. * Sets the current effect wrapper to use during draw.
  62532. * The effect needs to be ready before calling this api.
  62533. * This also sets the default full screen position attribute.
  62534. * @param effectWrapper Defines the effect to draw with
  62535. */
  62536. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62537. /**
  62538. * Restores engine states
  62539. */
  62540. restoreStates(): void;
  62541. /**
  62542. * Draws a full screen quad.
  62543. */
  62544. draw(): void;
  62545. private isRenderTargetTexture;
  62546. /**
  62547. * renders one or more effects to a specified texture
  62548. * @param effectWrapper the effect to renderer
  62549. * @param outputTexture texture to draw to, if null it will render to the screen.
  62550. */
  62551. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62552. /**
  62553. * Disposes of the effect renderer
  62554. */
  62555. dispose(): void;
  62556. }
  62557. /**
  62558. * Options to create an EffectWrapper
  62559. */
  62560. interface EffectWrapperCreationOptions {
  62561. /**
  62562. * Engine to use to create the effect
  62563. */
  62564. engine: ThinEngine;
  62565. /**
  62566. * Fragment shader for the effect
  62567. */
  62568. fragmentShader: string;
  62569. /**
  62570. * Use the shader store instead of direct source code
  62571. */
  62572. useShaderStore?: boolean;
  62573. /**
  62574. * Vertex shader for the effect
  62575. */
  62576. vertexShader?: string;
  62577. /**
  62578. * Attributes to use in the shader
  62579. */
  62580. attributeNames?: Array<string>;
  62581. /**
  62582. * Uniforms to use in the shader
  62583. */
  62584. uniformNames?: Array<string>;
  62585. /**
  62586. * Texture sampler names to use in the shader
  62587. */
  62588. samplerNames?: Array<string>;
  62589. /**
  62590. * Defines to use in the shader
  62591. */
  62592. defines?: Array<string>;
  62593. /**
  62594. * Callback when effect is compiled
  62595. */
  62596. onCompiled?: Nullable<(effect: Effect) => void>;
  62597. /**
  62598. * The friendly name of the effect displayed in Spector.
  62599. */
  62600. name?: string;
  62601. }
  62602. /**
  62603. * Wraps an effect to be used for rendering
  62604. */
  62605. export class EffectWrapper {
  62606. /**
  62607. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62608. */
  62609. onApplyObservable: Observable<{}>;
  62610. /**
  62611. * The underlying effect
  62612. */
  62613. effect: Effect;
  62614. /**
  62615. * Creates an effect to be renderer
  62616. * @param creationOptions options to create the effect
  62617. */
  62618. constructor(creationOptions: EffectWrapperCreationOptions);
  62619. /**
  62620. * Disposes of the effect wrapper
  62621. */
  62622. dispose(): void;
  62623. }
  62624. }
  62625. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62626. /** @hidden */
  62627. export var hdrFilteringVertexShader: {
  62628. name: string;
  62629. shader: string;
  62630. };
  62631. }
  62632. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62633. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62634. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62635. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62636. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62637. /** @hidden */
  62638. export var hdrFilteringPixelShader: {
  62639. name: string;
  62640. shader: string;
  62641. };
  62642. }
  62643. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62645. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62646. import { Nullable } from "babylonjs/types";
  62647. import "babylonjs/Shaders/hdrFiltering.vertex";
  62648. import "babylonjs/Shaders/hdrFiltering.fragment";
  62649. /**
  62650. * Options for texture filtering
  62651. */
  62652. interface IHDRFilteringOptions {
  62653. /**
  62654. * Scales pixel intensity for the input HDR map.
  62655. */
  62656. hdrScale?: number;
  62657. /**
  62658. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62659. */
  62660. quality?: number;
  62661. }
  62662. /**
  62663. * Filters HDR maps to get correct renderings of PBR reflections
  62664. */
  62665. export class HDRFiltering {
  62666. private _engine;
  62667. private _effectRenderer;
  62668. private _effectWrapper;
  62669. private _lodGenerationOffset;
  62670. private _lodGenerationScale;
  62671. /**
  62672. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62673. * you care about baking speed.
  62674. */
  62675. quality: number;
  62676. /**
  62677. * Scales pixel intensity for the input HDR map.
  62678. */
  62679. hdrScale: number;
  62680. /**
  62681. * Instantiates HDR filter for reflection maps
  62682. *
  62683. * @param engine Thin engine
  62684. * @param options Options
  62685. */
  62686. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62687. private _createRenderTarget;
  62688. private _prefilterInternal;
  62689. private _createEffect;
  62690. /**
  62691. * Get a value indicating if the filter is ready to be used
  62692. * @param texture Texture to filter
  62693. * @returns true if the filter is ready
  62694. */
  62695. isReady(texture: BaseTexture): boolean;
  62696. /**
  62697. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62698. * Prefiltering will be invoked at the end of next rendering pass.
  62699. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62700. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62701. * @param texture Texture to filter
  62702. * @param onFinished Callback when filtering is done
  62703. * @return Promise called when prefiltering is done
  62704. */
  62705. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62706. }
  62707. }
  62708. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62709. import { Nullable } from "babylonjs/types";
  62710. import { Scene } from "babylonjs/scene";
  62711. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62712. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62713. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62714. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62715. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62716. /**
  62717. * This represents a texture coming from an HDR input.
  62718. *
  62719. * The only supported format is currently panorama picture stored in RGBE format.
  62720. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62721. */
  62722. export class HDRCubeTexture extends BaseTexture {
  62723. private static _facesMapping;
  62724. private _generateHarmonics;
  62725. private _noMipmap;
  62726. private _prefilterOnLoad;
  62727. private _textureMatrix;
  62728. private _size;
  62729. private _onLoad;
  62730. private _onError;
  62731. /**
  62732. * The texture URL.
  62733. */
  62734. url: string;
  62735. /**
  62736. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62737. */
  62738. coordinatesMode: number;
  62739. protected _isBlocking: boolean;
  62740. /**
  62741. * Sets wether or not the texture is blocking during loading.
  62742. */
  62743. set isBlocking(value: boolean);
  62744. /**
  62745. * Gets wether or not the texture is blocking during loading.
  62746. */
  62747. get isBlocking(): boolean;
  62748. protected _rotationY: number;
  62749. /**
  62750. * Sets texture matrix rotation angle around Y axis in radians.
  62751. */
  62752. set rotationY(value: number);
  62753. /**
  62754. * Gets texture matrix rotation angle around Y axis radians.
  62755. */
  62756. get rotationY(): number;
  62757. /**
  62758. * Gets or sets the center of the bounding box associated with the cube texture
  62759. * It must define where the camera used to render the texture was set
  62760. */
  62761. boundingBoxPosition: Vector3;
  62762. private _boundingBoxSize;
  62763. /**
  62764. * Gets or sets the size of the bounding box associated with the cube texture
  62765. * When defined, the cubemap will switch to local mode
  62766. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62767. * @example https://www.babylonjs-playground.com/#RNASML
  62768. */
  62769. set boundingBoxSize(value: Vector3);
  62770. get boundingBoxSize(): Vector3;
  62771. /**
  62772. * Instantiates an HDRTexture from the following parameters.
  62773. *
  62774. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62775. * @param sceneOrEngine The scene or engine the texture will be used in
  62776. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62777. * @param noMipmap Forces to not generate the mipmap if true
  62778. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62779. * @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)
  62780. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62781. */
  62782. 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>);
  62783. /**
  62784. * Get the current class name of the texture useful for serialization or dynamic coding.
  62785. * @returns "HDRCubeTexture"
  62786. */
  62787. getClassName(): string;
  62788. /**
  62789. * Occurs when the file is raw .hdr file.
  62790. */
  62791. private loadTexture;
  62792. clone(): HDRCubeTexture;
  62793. delayLoad(): void;
  62794. /**
  62795. * Get the texture reflection matrix used to rotate/transform the reflection.
  62796. * @returns the reflection matrix
  62797. */
  62798. getReflectionTextureMatrix(): Matrix;
  62799. /**
  62800. * Set the texture reflection matrix used to rotate/transform the reflection.
  62801. * @param value Define the reflection matrix to set
  62802. */
  62803. setReflectionTextureMatrix(value: Matrix): void;
  62804. /**
  62805. * Parses a JSON representation of an HDR Texture in order to create the texture
  62806. * @param parsedTexture Define the JSON representation
  62807. * @param scene Define the scene the texture should be created in
  62808. * @param rootUrl Define the root url in case we need to load relative dependencies
  62809. * @returns the newly created texture after parsing
  62810. */
  62811. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62812. serialize(): any;
  62813. }
  62814. }
  62815. declare module "babylonjs/Physics/physicsEngine" {
  62816. import { Nullable } from "babylonjs/types";
  62817. import { Vector3 } from "babylonjs/Maths/math.vector";
  62818. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62819. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62820. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62821. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62822. /**
  62823. * Class used to control physics engine
  62824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62825. */
  62826. export class PhysicsEngine implements IPhysicsEngine {
  62827. private _physicsPlugin;
  62828. /**
  62829. * Global value used to control the smallest number supported by the simulation
  62830. */
  62831. static Epsilon: number;
  62832. private _impostors;
  62833. private _joints;
  62834. private _subTimeStep;
  62835. /**
  62836. * Gets the gravity vector used by the simulation
  62837. */
  62838. gravity: Vector3;
  62839. /**
  62840. * Factory used to create the default physics plugin.
  62841. * @returns The default physics plugin
  62842. */
  62843. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62844. /**
  62845. * Creates a new Physics Engine
  62846. * @param gravity defines the gravity vector used by the simulation
  62847. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62848. */
  62849. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62850. /**
  62851. * Sets the gravity vector used by the simulation
  62852. * @param gravity defines the gravity vector to use
  62853. */
  62854. setGravity(gravity: Vector3): void;
  62855. /**
  62856. * Set the time step of the physics engine.
  62857. * Default is 1/60.
  62858. * To slow it down, enter 1/600 for example.
  62859. * To speed it up, 1/30
  62860. * @param newTimeStep defines the new timestep to apply to this world.
  62861. */
  62862. setTimeStep(newTimeStep?: number): void;
  62863. /**
  62864. * Get the time step of the physics engine.
  62865. * @returns the current time step
  62866. */
  62867. getTimeStep(): number;
  62868. /**
  62869. * Set the sub time step of the physics engine.
  62870. * Default is 0 meaning there is no sub steps
  62871. * To increase physics resolution precision, set a small value (like 1 ms)
  62872. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62873. */
  62874. setSubTimeStep(subTimeStep?: number): void;
  62875. /**
  62876. * Get the sub time step of the physics engine.
  62877. * @returns the current sub time step
  62878. */
  62879. getSubTimeStep(): number;
  62880. /**
  62881. * Release all resources
  62882. */
  62883. dispose(): void;
  62884. /**
  62885. * Gets the name of the current physics plugin
  62886. * @returns the name of the plugin
  62887. */
  62888. getPhysicsPluginName(): string;
  62889. /**
  62890. * Adding a new impostor for the impostor tracking.
  62891. * This will be done by the impostor itself.
  62892. * @param impostor the impostor to add
  62893. */
  62894. addImpostor(impostor: PhysicsImpostor): void;
  62895. /**
  62896. * Remove an impostor from the engine.
  62897. * This impostor and its mesh will not longer be updated by the physics engine.
  62898. * @param impostor the impostor to remove
  62899. */
  62900. removeImpostor(impostor: PhysicsImpostor): void;
  62901. /**
  62902. * Add a joint to the physics engine
  62903. * @param mainImpostor defines the main impostor to which the joint is added.
  62904. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62905. * @param joint defines the joint that will connect both impostors.
  62906. */
  62907. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62908. /**
  62909. * Removes a joint from the simulation
  62910. * @param mainImpostor defines the impostor used with the joint
  62911. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62912. * @param joint defines the joint to remove
  62913. */
  62914. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62915. /**
  62916. * Called by the scene. No need to call it.
  62917. * @param delta defines the timespam between frames
  62918. */
  62919. _step(delta: number): void;
  62920. /**
  62921. * Gets the current plugin used to run the simulation
  62922. * @returns current plugin
  62923. */
  62924. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62925. /**
  62926. * Gets the list of physic impostors
  62927. * @returns an array of PhysicsImpostor
  62928. */
  62929. getImpostors(): Array<PhysicsImpostor>;
  62930. /**
  62931. * Gets the impostor for a physics enabled object
  62932. * @param object defines the object impersonated by the impostor
  62933. * @returns the PhysicsImpostor or null if not found
  62934. */
  62935. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62936. /**
  62937. * Gets the impostor for a physics body object
  62938. * @param body defines physics body used by the impostor
  62939. * @returns the PhysicsImpostor or null if not found
  62940. */
  62941. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62942. /**
  62943. * Does a raycast in the physics world
  62944. * @param from when should the ray start?
  62945. * @param to when should the ray end?
  62946. * @returns PhysicsRaycastResult
  62947. */
  62948. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62949. }
  62950. }
  62951. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62952. import { Nullable } from "babylonjs/types";
  62953. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62955. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62956. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62957. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62958. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62959. /** @hidden */
  62960. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62961. private _useDeltaForWorldStep;
  62962. world: any;
  62963. name: string;
  62964. private _physicsMaterials;
  62965. private _fixedTimeStep;
  62966. private _cannonRaycastResult;
  62967. private _raycastResult;
  62968. private _physicsBodysToRemoveAfterStep;
  62969. private _firstFrame;
  62970. BJSCANNON: any;
  62971. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62972. setGravity(gravity: Vector3): void;
  62973. setTimeStep(timeStep: number): void;
  62974. getTimeStep(): number;
  62975. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62976. private _removeMarkedPhysicsBodiesFromWorld;
  62977. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62978. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62979. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62980. private _processChildMeshes;
  62981. removePhysicsBody(impostor: PhysicsImpostor): void;
  62982. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62983. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62984. private _addMaterial;
  62985. private _checkWithEpsilon;
  62986. private _createShape;
  62987. private _createHeightmap;
  62988. private _minus90X;
  62989. private _plus90X;
  62990. private _tmpPosition;
  62991. private _tmpDeltaPosition;
  62992. private _tmpUnityRotation;
  62993. private _updatePhysicsBodyTransformation;
  62994. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62995. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62996. isSupported(): boolean;
  62997. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62998. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62999. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63000. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63001. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63002. getBodyMass(impostor: PhysicsImpostor): number;
  63003. getBodyFriction(impostor: PhysicsImpostor): number;
  63004. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63005. getBodyRestitution(impostor: PhysicsImpostor): number;
  63006. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63007. sleepBody(impostor: PhysicsImpostor): void;
  63008. wakeUpBody(impostor: PhysicsImpostor): void;
  63009. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63010. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63011. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63012. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63013. getRadius(impostor: PhysicsImpostor): number;
  63014. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63015. dispose(): void;
  63016. private _extendNamespace;
  63017. /**
  63018. * Does a raycast in the physics world
  63019. * @param from when should the ray start?
  63020. * @param to when should the ray end?
  63021. * @returns PhysicsRaycastResult
  63022. */
  63023. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63024. }
  63025. }
  63026. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63027. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63028. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63029. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63031. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63032. import { Nullable } from "babylonjs/types";
  63033. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63034. /** @hidden */
  63035. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63036. private _useDeltaForWorldStep;
  63037. world: any;
  63038. name: string;
  63039. BJSOIMO: any;
  63040. private _raycastResult;
  63041. private _fixedTimeStep;
  63042. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63043. setGravity(gravity: Vector3): void;
  63044. setTimeStep(timeStep: number): void;
  63045. getTimeStep(): number;
  63046. private _tmpImpostorsArray;
  63047. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63048. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63049. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63050. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63051. private _tmpPositionVector;
  63052. removePhysicsBody(impostor: PhysicsImpostor): void;
  63053. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63054. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63055. isSupported(): boolean;
  63056. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63057. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63058. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63059. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63060. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63061. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63062. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63063. getBodyMass(impostor: PhysicsImpostor): number;
  63064. getBodyFriction(impostor: PhysicsImpostor): number;
  63065. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63066. getBodyRestitution(impostor: PhysicsImpostor): number;
  63067. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63068. sleepBody(impostor: PhysicsImpostor): void;
  63069. wakeUpBody(impostor: PhysicsImpostor): void;
  63070. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63071. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63072. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63073. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63074. getRadius(impostor: PhysicsImpostor): number;
  63075. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63076. dispose(): void;
  63077. /**
  63078. * Does a raycast in the physics world
  63079. * @param from when should the ray start?
  63080. * @param to when should the ray end?
  63081. * @returns PhysicsRaycastResult
  63082. */
  63083. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63084. }
  63085. }
  63086. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63087. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63088. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63089. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63090. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63091. import { Nullable } from "babylonjs/types";
  63092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63093. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63094. /**
  63095. * AmmoJS Physics plugin
  63096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63097. * @see https://github.com/kripken/ammo.js/
  63098. */
  63099. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63100. private _useDeltaForWorldStep;
  63101. /**
  63102. * Reference to the Ammo library
  63103. */
  63104. bjsAMMO: any;
  63105. /**
  63106. * Created ammoJS world which physics bodies are added to
  63107. */
  63108. world: any;
  63109. /**
  63110. * Name of the plugin
  63111. */
  63112. name: string;
  63113. private _timeStep;
  63114. private _fixedTimeStep;
  63115. private _maxSteps;
  63116. private _tmpQuaternion;
  63117. private _tmpAmmoTransform;
  63118. private _tmpAmmoQuaternion;
  63119. private _tmpAmmoConcreteContactResultCallback;
  63120. private _collisionConfiguration;
  63121. private _dispatcher;
  63122. private _overlappingPairCache;
  63123. private _solver;
  63124. private _softBodySolver;
  63125. private _tmpAmmoVectorA;
  63126. private _tmpAmmoVectorB;
  63127. private _tmpAmmoVectorC;
  63128. private _tmpAmmoVectorD;
  63129. private _tmpContactCallbackResult;
  63130. private _tmpAmmoVectorRCA;
  63131. private _tmpAmmoVectorRCB;
  63132. private _raycastResult;
  63133. private static readonly DISABLE_COLLISION_FLAG;
  63134. private static readonly KINEMATIC_FLAG;
  63135. private static readonly DISABLE_DEACTIVATION_FLAG;
  63136. /**
  63137. * Initializes the ammoJS plugin
  63138. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63139. * @param ammoInjection can be used to inject your own ammo reference
  63140. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63141. */
  63142. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63143. /**
  63144. * Sets the gravity of the physics world (m/(s^2))
  63145. * @param gravity Gravity to set
  63146. */
  63147. setGravity(gravity: Vector3): void;
  63148. /**
  63149. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63150. * @param timeStep timestep to use in seconds
  63151. */
  63152. setTimeStep(timeStep: number): void;
  63153. /**
  63154. * 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)
  63155. * @param fixedTimeStep fixedTimeStep to use in seconds
  63156. */
  63157. setFixedTimeStep(fixedTimeStep: number): void;
  63158. /**
  63159. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63160. * @param maxSteps the maximum number of steps by the physics engine per frame
  63161. */
  63162. setMaxSteps(maxSteps: number): void;
  63163. /**
  63164. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63165. * @returns the current timestep in seconds
  63166. */
  63167. getTimeStep(): number;
  63168. /**
  63169. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63170. */
  63171. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63172. private _isImpostorInContact;
  63173. private _isImpostorPairInContact;
  63174. private _stepSimulation;
  63175. /**
  63176. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63177. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63178. * After the step the babylon meshes are set to the position of the physics imposters
  63179. * @param delta amount of time to step forward
  63180. * @param impostors array of imposters to update before/after the step
  63181. */
  63182. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63183. /**
  63184. * Update babylon mesh to match physics world object
  63185. * @param impostor imposter to match
  63186. */
  63187. private _afterSoftStep;
  63188. /**
  63189. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63190. * @param impostor imposter to match
  63191. */
  63192. private _ropeStep;
  63193. /**
  63194. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63195. * @param impostor imposter to match
  63196. */
  63197. private _softbodyOrClothStep;
  63198. private _tmpMatrix;
  63199. /**
  63200. * Applies an impulse on the imposter
  63201. * @param impostor imposter to apply impulse to
  63202. * @param force amount of force to be applied to the imposter
  63203. * @param contactPoint the location to apply the impulse on the imposter
  63204. */
  63205. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63206. /**
  63207. * Applies a force on the imposter
  63208. * @param impostor imposter to apply force
  63209. * @param force amount of force to be applied to the imposter
  63210. * @param contactPoint the location to apply the force on the imposter
  63211. */
  63212. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63213. /**
  63214. * Creates a physics body using the plugin
  63215. * @param impostor the imposter to create the physics body on
  63216. */
  63217. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63218. /**
  63219. * Removes the physics body from the imposter and disposes of the body's memory
  63220. * @param impostor imposter to remove the physics body from
  63221. */
  63222. removePhysicsBody(impostor: PhysicsImpostor): void;
  63223. /**
  63224. * Generates a joint
  63225. * @param impostorJoint the imposter joint to create the joint with
  63226. */
  63227. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63228. /**
  63229. * Removes a joint
  63230. * @param impostorJoint the imposter joint to remove the joint from
  63231. */
  63232. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63233. private _addMeshVerts;
  63234. /**
  63235. * Initialise the soft body vertices to match its object's (mesh) vertices
  63236. * Softbody vertices (nodes) are in world space and to match this
  63237. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63238. * @param impostor to create the softbody for
  63239. */
  63240. private _softVertexData;
  63241. /**
  63242. * Create an impostor's soft body
  63243. * @param impostor to create the softbody for
  63244. */
  63245. private _createSoftbody;
  63246. /**
  63247. * Create cloth for an impostor
  63248. * @param impostor to create the softbody for
  63249. */
  63250. private _createCloth;
  63251. /**
  63252. * Create rope for an impostor
  63253. * @param impostor to create the softbody for
  63254. */
  63255. private _createRope;
  63256. /**
  63257. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63258. * @param impostor to create the custom physics shape for
  63259. */
  63260. private _createCustom;
  63261. private _addHullVerts;
  63262. private _createShape;
  63263. /**
  63264. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63265. * @param impostor imposter containing the physics body and babylon object
  63266. */
  63267. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63268. /**
  63269. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63270. * @param impostor imposter containing the physics body and babylon object
  63271. * @param newPosition new position
  63272. * @param newRotation new rotation
  63273. */
  63274. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63275. /**
  63276. * If this plugin is supported
  63277. * @returns true if its supported
  63278. */
  63279. isSupported(): boolean;
  63280. /**
  63281. * Sets the linear velocity of the physics body
  63282. * @param impostor imposter to set the velocity on
  63283. * @param velocity velocity to set
  63284. */
  63285. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63286. /**
  63287. * Sets the angular velocity of the physics body
  63288. * @param impostor imposter to set the velocity on
  63289. * @param velocity velocity to set
  63290. */
  63291. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63292. /**
  63293. * gets the linear velocity
  63294. * @param impostor imposter to get linear velocity from
  63295. * @returns linear velocity
  63296. */
  63297. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63298. /**
  63299. * gets the angular velocity
  63300. * @param impostor imposter to get angular velocity from
  63301. * @returns angular velocity
  63302. */
  63303. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63304. /**
  63305. * Sets the mass of physics body
  63306. * @param impostor imposter to set the mass on
  63307. * @param mass mass to set
  63308. */
  63309. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63310. /**
  63311. * Gets the mass of the physics body
  63312. * @param impostor imposter to get the mass from
  63313. * @returns mass
  63314. */
  63315. getBodyMass(impostor: PhysicsImpostor): number;
  63316. /**
  63317. * Gets friction of the impostor
  63318. * @param impostor impostor to get friction from
  63319. * @returns friction value
  63320. */
  63321. getBodyFriction(impostor: PhysicsImpostor): number;
  63322. /**
  63323. * Sets friction of the impostor
  63324. * @param impostor impostor to set friction on
  63325. * @param friction friction value
  63326. */
  63327. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63328. /**
  63329. * Gets restitution of the impostor
  63330. * @param impostor impostor to get restitution from
  63331. * @returns restitution value
  63332. */
  63333. getBodyRestitution(impostor: PhysicsImpostor): number;
  63334. /**
  63335. * Sets resitution of the impostor
  63336. * @param impostor impostor to set resitution on
  63337. * @param restitution resitution value
  63338. */
  63339. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63340. /**
  63341. * Gets pressure inside the impostor
  63342. * @param impostor impostor to get pressure from
  63343. * @returns pressure value
  63344. */
  63345. getBodyPressure(impostor: PhysicsImpostor): number;
  63346. /**
  63347. * Sets pressure inside a soft body impostor
  63348. * Cloth and rope must remain 0 pressure
  63349. * @param impostor impostor to set pressure on
  63350. * @param pressure pressure value
  63351. */
  63352. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63353. /**
  63354. * Gets stiffness of the impostor
  63355. * @param impostor impostor to get stiffness from
  63356. * @returns pressure value
  63357. */
  63358. getBodyStiffness(impostor: PhysicsImpostor): number;
  63359. /**
  63360. * Sets stiffness of the impostor
  63361. * @param impostor impostor to set stiffness on
  63362. * @param stiffness stiffness value from 0 to 1
  63363. */
  63364. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63365. /**
  63366. * Gets velocityIterations of the impostor
  63367. * @param impostor impostor to get velocity iterations from
  63368. * @returns velocityIterations value
  63369. */
  63370. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63371. /**
  63372. * Sets velocityIterations of the impostor
  63373. * @param impostor impostor to set velocity iterations on
  63374. * @param velocityIterations velocityIterations value
  63375. */
  63376. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63377. /**
  63378. * Gets positionIterations of the impostor
  63379. * @param impostor impostor to get position iterations from
  63380. * @returns positionIterations value
  63381. */
  63382. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63383. /**
  63384. * Sets positionIterations of the impostor
  63385. * @param impostor impostor to set position on
  63386. * @param positionIterations positionIterations value
  63387. */
  63388. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63389. /**
  63390. * Append an anchor to a cloth object
  63391. * @param impostor is the cloth impostor to add anchor to
  63392. * @param otherImpostor is the rigid impostor to anchor to
  63393. * @param width ratio across width from 0 to 1
  63394. * @param height ratio up height from 0 to 1
  63395. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63396. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63397. */
  63398. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63399. /**
  63400. * Append an hook to a rope object
  63401. * @param impostor is the rope impostor to add hook to
  63402. * @param otherImpostor is the rigid impostor to hook to
  63403. * @param length ratio along the rope from 0 to 1
  63404. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63405. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63406. */
  63407. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63408. /**
  63409. * Sleeps the physics body and stops it from being active
  63410. * @param impostor impostor to sleep
  63411. */
  63412. sleepBody(impostor: PhysicsImpostor): void;
  63413. /**
  63414. * Activates the physics body
  63415. * @param impostor impostor to activate
  63416. */
  63417. wakeUpBody(impostor: PhysicsImpostor): void;
  63418. /**
  63419. * Updates the distance parameters of the joint
  63420. * @param joint joint to update
  63421. * @param maxDistance maximum distance of the joint
  63422. * @param minDistance minimum distance of the joint
  63423. */
  63424. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63425. /**
  63426. * Sets a motor on the joint
  63427. * @param joint joint to set motor on
  63428. * @param speed speed of the motor
  63429. * @param maxForce maximum force of the motor
  63430. * @param motorIndex index of the motor
  63431. */
  63432. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63433. /**
  63434. * Sets the motors limit
  63435. * @param joint joint to set limit on
  63436. * @param upperLimit upper limit
  63437. * @param lowerLimit lower limit
  63438. */
  63439. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63440. /**
  63441. * Syncs the position and rotation of a mesh with the impostor
  63442. * @param mesh mesh to sync
  63443. * @param impostor impostor to update the mesh with
  63444. */
  63445. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63446. /**
  63447. * Gets the radius of the impostor
  63448. * @param impostor impostor to get radius from
  63449. * @returns the radius
  63450. */
  63451. getRadius(impostor: PhysicsImpostor): number;
  63452. /**
  63453. * Gets the box size of the impostor
  63454. * @param impostor impostor to get box size from
  63455. * @param result the resulting box size
  63456. */
  63457. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63458. /**
  63459. * Disposes of the impostor
  63460. */
  63461. dispose(): void;
  63462. /**
  63463. * Does a raycast in the physics world
  63464. * @param from when should the ray start?
  63465. * @param to when should the ray end?
  63466. * @returns PhysicsRaycastResult
  63467. */
  63468. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63469. }
  63470. }
  63471. declare module "babylonjs/Probes/reflectionProbe" {
  63472. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63473. import { Vector3 } from "babylonjs/Maths/math.vector";
  63474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63475. import { Nullable } from "babylonjs/types";
  63476. import { Scene } from "babylonjs/scene";
  63477. module "babylonjs/abstractScene" {
  63478. interface AbstractScene {
  63479. /**
  63480. * The list of reflection probes added to the scene
  63481. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63482. */
  63483. reflectionProbes: Array<ReflectionProbe>;
  63484. /**
  63485. * Removes the given reflection probe from this scene.
  63486. * @param toRemove The reflection probe to remove
  63487. * @returns The index of the removed reflection probe
  63488. */
  63489. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63490. /**
  63491. * Adds the given reflection probe to this scene.
  63492. * @param newReflectionProbe The reflection probe to add
  63493. */
  63494. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63495. }
  63496. }
  63497. /**
  63498. * Class used to generate realtime reflection / refraction cube textures
  63499. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63500. */
  63501. export class ReflectionProbe {
  63502. /** defines the name of the probe */
  63503. name: string;
  63504. private _scene;
  63505. private _renderTargetTexture;
  63506. private _projectionMatrix;
  63507. private _viewMatrix;
  63508. private _target;
  63509. private _add;
  63510. private _attachedMesh;
  63511. private _invertYAxis;
  63512. /** Gets or sets probe position (center of the cube map) */
  63513. position: Vector3;
  63514. /**
  63515. * Creates a new reflection probe
  63516. * @param name defines the name of the probe
  63517. * @param size defines the texture resolution (for each face)
  63518. * @param scene defines the hosting scene
  63519. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63520. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63521. */
  63522. constructor(
  63523. /** defines the name of the probe */
  63524. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63525. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63526. get samples(): number;
  63527. set samples(value: number);
  63528. /** Gets or sets the refresh rate to use (on every frame by default) */
  63529. get refreshRate(): number;
  63530. set refreshRate(value: number);
  63531. /**
  63532. * Gets the hosting scene
  63533. * @returns a Scene
  63534. */
  63535. getScene(): Scene;
  63536. /** Gets the internal CubeTexture used to render to */
  63537. get cubeTexture(): RenderTargetTexture;
  63538. /** Gets the list of meshes to render */
  63539. get renderList(): Nullable<AbstractMesh[]>;
  63540. /**
  63541. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63542. * @param mesh defines the mesh to attach to
  63543. */
  63544. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63545. /**
  63546. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63547. * @param renderingGroupId The rendering group id corresponding to its index
  63548. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63549. */
  63550. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63551. /**
  63552. * Clean all associated resources
  63553. */
  63554. dispose(): void;
  63555. /**
  63556. * Converts the reflection probe information to a readable string for debug purpose.
  63557. * @param fullDetails Supports for multiple levels of logging within scene loading
  63558. * @returns the human readable reflection probe info
  63559. */
  63560. toString(fullDetails?: boolean): string;
  63561. /**
  63562. * Get the class name of the relfection probe.
  63563. * @returns "ReflectionProbe"
  63564. */
  63565. getClassName(): string;
  63566. /**
  63567. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63568. * @returns The JSON representation of the texture
  63569. */
  63570. serialize(): any;
  63571. /**
  63572. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63573. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63574. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63575. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63576. * @returns The parsed reflection probe if successful
  63577. */
  63578. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63579. }
  63580. }
  63581. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63582. /** @hidden */
  63583. export var _BabylonLoaderRegistered: boolean;
  63584. /**
  63585. * Helps setting up some configuration for the babylon file loader.
  63586. */
  63587. export class BabylonFileLoaderConfiguration {
  63588. /**
  63589. * The loader does not allow injecting custom physix engine into the plugins.
  63590. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63591. * So you could set this variable to your engine import to make it work.
  63592. */
  63593. static LoaderInjectedPhysicsEngine: any;
  63594. }
  63595. }
  63596. declare module "babylonjs/Loading/Plugins/index" {
  63597. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63598. }
  63599. declare module "babylonjs/Loading/index" {
  63600. export * from "babylonjs/Loading/loadingScreen";
  63601. export * from "babylonjs/Loading/Plugins/index";
  63602. export * from "babylonjs/Loading/sceneLoader";
  63603. export * from "babylonjs/Loading/sceneLoaderFlags";
  63604. }
  63605. declare module "babylonjs/Materials/Background/index" {
  63606. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63607. }
  63608. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63609. import { Scene } from "babylonjs/scene";
  63610. import { Color3 } from "babylonjs/Maths/math.color";
  63611. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63613. /**
  63614. * The Physically based simple base material of BJS.
  63615. *
  63616. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63617. * It is used as the base class for both the specGloss and metalRough conventions.
  63618. */
  63619. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63620. /**
  63621. * Number of Simultaneous lights allowed on the material.
  63622. */
  63623. maxSimultaneousLights: number;
  63624. /**
  63625. * If sets to true, disables all the lights affecting the material.
  63626. */
  63627. disableLighting: boolean;
  63628. /**
  63629. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63630. */
  63631. environmentTexture: BaseTexture;
  63632. /**
  63633. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63634. */
  63635. invertNormalMapX: boolean;
  63636. /**
  63637. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63638. */
  63639. invertNormalMapY: boolean;
  63640. /**
  63641. * Normal map used in the model.
  63642. */
  63643. normalTexture: BaseTexture;
  63644. /**
  63645. * Emissivie color used to self-illuminate the model.
  63646. */
  63647. emissiveColor: Color3;
  63648. /**
  63649. * Emissivie texture used to self-illuminate the model.
  63650. */
  63651. emissiveTexture: BaseTexture;
  63652. /**
  63653. * Occlusion Channel Strenght.
  63654. */
  63655. occlusionStrength: number;
  63656. /**
  63657. * Occlusion Texture of the material (adding extra occlusion effects).
  63658. */
  63659. occlusionTexture: BaseTexture;
  63660. /**
  63661. * Defines the alpha limits in alpha test mode.
  63662. */
  63663. alphaCutOff: number;
  63664. /**
  63665. * Gets the current double sided mode.
  63666. */
  63667. get doubleSided(): boolean;
  63668. /**
  63669. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63670. */
  63671. set doubleSided(value: boolean);
  63672. /**
  63673. * Stores the pre-calculated light information of a mesh in a texture.
  63674. */
  63675. lightmapTexture: BaseTexture;
  63676. /**
  63677. * If true, the light map contains occlusion information instead of lighting info.
  63678. */
  63679. useLightmapAsShadowmap: boolean;
  63680. /**
  63681. * Instantiates a new PBRMaterial instance.
  63682. *
  63683. * @param name The material name
  63684. * @param scene The scene the material will be use in.
  63685. */
  63686. constructor(name: string, scene: Scene);
  63687. getClassName(): string;
  63688. }
  63689. }
  63690. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63691. import { Scene } from "babylonjs/scene";
  63692. import { Color3 } from "babylonjs/Maths/math.color";
  63693. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63694. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63695. /**
  63696. * The PBR material of BJS following the metal roughness convention.
  63697. *
  63698. * This fits to the PBR convention in the GLTF definition:
  63699. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63700. */
  63701. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63702. /**
  63703. * The base color has two different interpretations depending on the value of metalness.
  63704. * When the material is a metal, the base color is the specific measured reflectance value
  63705. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63706. * of the material.
  63707. */
  63708. baseColor: Color3;
  63709. /**
  63710. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63711. * well as opacity information in the alpha channel.
  63712. */
  63713. baseTexture: BaseTexture;
  63714. /**
  63715. * Specifies the metallic scalar value of the material.
  63716. * Can also be used to scale the metalness values of the metallic texture.
  63717. */
  63718. metallic: number;
  63719. /**
  63720. * Specifies the roughness scalar value of the material.
  63721. * Can also be used to scale the roughness values of the metallic texture.
  63722. */
  63723. roughness: number;
  63724. /**
  63725. * Texture containing both the metallic value in the B channel and the
  63726. * roughness value in the G channel to keep better precision.
  63727. */
  63728. metallicRoughnessTexture: BaseTexture;
  63729. /**
  63730. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63731. *
  63732. * @param name The material name
  63733. * @param scene The scene the material will be use in.
  63734. */
  63735. constructor(name: string, scene: Scene);
  63736. /**
  63737. * Return the currrent class name of the material.
  63738. */
  63739. getClassName(): string;
  63740. /**
  63741. * Makes a duplicate of the current material.
  63742. * @param name - name to use for the new material.
  63743. */
  63744. clone(name: string): PBRMetallicRoughnessMaterial;
  63745. /**
  63746. * Serialize the material to a parsable JSON object.
  63747. */
  63748. serialize(): any;
  63749. /**
  63750. * Parses a JSON object correponding to the serialize function.
  63751. */
  63752. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63753. }
  63754. }
  63755. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63756. import { Scene } from "babylonjs/scene";
  63757. import { Color3 } from "babylonjs/Maths/math.color";
  63758. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63759. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63760. /**
  63761. * The PBR material of BJS following the specular glossiness convention.
  63762. *
  63763. * This fits to the PBR convention in the GLTF definition:
  63764. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63765. */
  63766. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63767. /**
  63768. * Specifies the diffuse color of the material.
  63769. */
  63770. diffuseColor: Color3;
  63771. /**
  63772. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63773. * channel.
  63774. */
  63775. diffuseTexture: BaseTexture;
  63776. /**
  63777. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63778. */
  63779. specularColor: Color3;
  63780. /**
  63781. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63782. */
  63783. glossiness: number;
  63784. /**
  63785. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63786. */
  63787. specularGlossinessTexture: BaseTexture;
  63788. /**
  63789. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63790. *
  63791. * @param name The material name
  63792. * @param scene The scene the material will be use in.
  63793. */
  63794. constructor(name: string, scene: Scene);
  63795. /**
  63796. * Return the currrent class name of the material.
  63797. */
  63798. getClassName(): string;
  63799. /**
  63800. * Makes a duplicate of the current material.
  63801. * @param name - name to use for the new material.
  63802. */
  63803. clone(name: string): PBRSpecularGlossinessMaterial;
  63804. /**
  63805. * Serialize the material to a parsable JSON object.
  63806. */
  63807. serialize(): any;
  63808. /**
  63809. * Parses a JSON object correponding to the serialize function.
  63810. */
  63811. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63812. }
  63813. }
  63814. declare module "babylonjs/Materials/PBR/index" {
  63815. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63816. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63817. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63818. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63819. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63820. }
  63821. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63822. import { Nullable } from "babylonjs/types";
  63823. import { Scene } from "babylonjs/scene";
  63824. import { Matrix } from "babylonjs/Maths/math.vector";
  63825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63826. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63827. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63828. /**
  63829. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63830. * It can help converting any input color in a desired output one. This can then be used to create effects
  63831. * from sepia, black and white to sixties or futuristic rendering...
  63832. *
  63833. * The only supported format is currently 3dl.
  63834. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63835. */
  63836. export class ColorGradingTexture extends BaseTexture {
  63837. /**
  63838. * The texture URL.
  63839. */
  63840. url: string;
  63841. /**
  63842. * Empty line regex stored for GC.
  63843. */
  63844. private static _noneEmptyLineRegex;
  63845. private _textureMatrix;
  63846. private _onLoad;
  63847. /**
  63848. * Instantiates a ColorGradingTexture from the following parameters.
  63849. *
  63850. * @param url The location of the color gradind data (currently only supporting 3dl)
  63851. * @param sceneOrEngine The scene or engine the texture will be used in
  63852. * @param onLoad defines a callback triggered when the texture has been loaded
  63853. */
  63854. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63855. /**
  63856. * Fires the onload event from the constructor if requested.
  63857. */
  63858. private _triggerOnLoad;
  63859. /**
  63860. * Returns the texture matrix used in most of the material.
  63861. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63862. */
  63863. getTextureMatrix(): Matrix;
  63864. /**
  63865. * Occurs when the file being loaded is a .3dl LUT file.
  63866. */
  63867. private load3dlTexture;
  63868. /**
  63869. * Starts the loading process of the texture.
  63870. */
  63871. private loadTexture;
  63872. /**
  63873. * Clones the color gradind texture.
  63874. */
  63875. clone(): ColorGradingTexture;
  63876. /**
  63877. * Called during delayed load for textures.
  63878. */
  63879. delayLoad(): void;
  63880. /**
  63881. * Parses a color grading texture serialized by Babylon.
  63882. * @param parsedTexture The texture information being parsedTexture
  63883. * @param scene The scene to load the texture in
  63884. * @param rootUrl The root url of the data assets to load
  63885. * @return A color gradind texture
  63886. */
  63887. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63888. /**
  63889. * Serializes the LUT texture to json format.
  63890. */
  63891. serialize(): any;
  63892. }
  63893. }
  63894. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63896. import { Scene } from "babylonjs/scene";
  63897. import { Nullable } from "babylonjs/types";
  63898. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63899. /**
  63900. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63901. */
  63902. export class EquiRectangularCubeTexture extends BaseTexture {
  63903. /** The six faces of the cube. */
  63904. private static _FacesMapping;
  63905. private _noMipmap;
  63906. private _onLoad;
  63907. private _onError;
  63908. /** The size of the cubemap. */
  63909. private _size;
  63910. /** The buffer of the image. */
  63911. private _buffer;
  63912. /** The width of the input image. */
  63913. private _width;
  63914. /** The height of the input image. */
  63915. private _height;
  63916. /** The URL to the image. */
  63917. url: string;
  63918. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63919. coordinatesMode: number;
  63920. /**
  63921. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63922. * @param url The location of the image
  63923. * @param scene The scene the texture will be used in
  63924. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63925. * @param noMipmap Forces to not generate the mipmap if true
  63926. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63927. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63928. * @param onLoad — defines a callback called when texture is loaded
  63929. * @param onError — defines a callback called if there is an error
  63930. */
  63931. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63932. /**
  63933. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63934. */
  63935. private loadImage;
  63936. /**
  63937. * Convert the image buffer into a cubemap and create a CubeTexture.
  63938. */
  63939. private loadTexture;
  63940. /**
  63941. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63942. * @param buffer The ArrayBuffer that should be converted.
  63943. * @returns The buffer as Float32Array.
  63944. */
  63945. private getFloat32ArrayFromArrayBuffer;
  63946. /**
  63947. * Get the current class name of the texture useful for serialization or dynamic coding.
  63948. * @returns "EquiRectangularCubeTexture"
  63949. */
  63950. getClassName(): string;
  63951. /**
  63952. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63953. * @returns A clone of the current EquiRectangularCubeTexture.
  63954. */
  63955. clone(): EquiRectangularCubeTexture;
  63956. }
  63957. }
  63958. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63959. import { Nullable } from "babylonjs/types";
  63960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63961. import { Matrix } from "babylonjs/Maths/math.vector";
  63962. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63963. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63964. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63965. import { Scene } from "babylonjs/scene";
  63966. /**
  63967. * Defines the options related to the creation of an HtmlElementTexture
  63968. */
  63969. export interface IHtmlElementTextureOptions {
  63970. /**
  63971. * Defines wether mip maps should be created or not.
  63972. */
  63973. generateMipMaps?: boolean;
  63974. /**
  63975. * Defines the sampling mode of the texture.
  63976. */
  63977. samplingMode?: number;
  63978. /**
  63979. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63980. */
  63981. engine: Nullable<ThinEngine>;
  63982. /**
  63983. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63984. */
  63985. scene: Nullable<Scene>;
  63986. }
  63987. /**
  63988. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63989. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63990. * is automatically managed.
  63991. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63992. * in your application.
  63993. *
  63994. * As the update is not automatic, you need to call them manually.
  63995. */
  63996. export class HtmlElementTexture extends BaseTexture {
  63997. /**
  63998. * The texture URL.
  63999. */
  64000. element: HTMLVideoElement | HTMLCanvasElement;
  64001. private static readonly DefaultOptions;
  64002. private _textureMatrix;
  64003. private _isVideo;
  64004. private _generateMipMaps;
  64005. private _samplingMode;
  64006. /**
  64007. * Instantiates a HtmlElementTexture from the following parameters.
  64008. *
  64009. * @param name Defines the name of the texture
  64010. * @param element Defines the video or canvas the texture is filled with
  64011. * @param options Defines the other none mandatory texture creation options
  64012. */
  64013. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64014. private _createInternalTexture;
  64015. /**
  64016. * Returns the texture matrix used in most of the material.
  64017. */
  64018. getTextureMatrix(): Matrix;
  64019. /**
  64020. * Updates the content of the texture.
  64021. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64022. */
  64023. update(invertY?: Nullable<boolean>): void;
  64024. }
  64025. }
  64026. declare module "babylonjs/Misc/tga" {
  64027. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64028. /**
  64029. * Based on jsTGALoader - Javascript loader for TGA file
  64030. * By Vincent Thibault
  64031. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64032. */
  64033. export class TGATools {
  64034. private static _TYPE_INDEXED;
  64035. private static _TYPE_RGB;
  64036. private static _TYPE_GREY;
  64037. private static _TYPE_RLE_INDEXED;
  64038. private static _TYPE_RLE_RGB;
  64039. private static _TYPE_RLE_GREY;
  64040. private static _ORIGIN_MASK;
  64041. private static _ORIGIN_SHIFT;
  64042. private static _ORIGIN_BL;
  64043. private static _ORIGIN_BR;
  64044. private static _ORIGIN_UL;
  64045. private static _ORIGIN_UR;
  64046. /**
  64047. * Gets the header of a TGA file
  64048. * @param data defines the TGA data
  64049. * @returns the header
  64050. */
  64051. static GetTGAHeader(data: Uint8Array): any;
  64052. /**
  64053. * Uploads TGA content to a Babylon Texture
  64054. * @hidden
  64055. */
  64056. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64057. /** @hidden */
  64058. 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;
  64059. /** @hidden */
  64060. 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;
  64061. /** @hidden */
  64062. 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;
  64063. /** @hidden */
  64064. 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;
  64065. /** @hidden */
  64066. 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;
  64067. /** @hidden */
  64068. 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;
  64069. }
  64070. }
  64071. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64072. import { Nullable } from "babylonjs/types";
  64073. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64074. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64075. /**
  64076. * Implementation of the TGA Texture Loader.
  64077. * @hidden
  64078. */
  64079. export class _TGATextureLoader implements IInternalTextureLoader {
  64080. /**
  64081. * Defines wether the loader supports cascade loading the different faces.
  64082. */
  64083. readonly supportCascades: boolean;
  64084. /**
  64085. * This returns if the loader support the current file information.
  64086. * @param extension defines the file extension of the file being loaded
  64087. * @returns true if the loader can load the specified file
  64088. */
  64089. canLoad(extension: string): boolean;
  64090. /**
  64091. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64092. * @param data contains the texture data
  64093. * @param texture defines the BabylonJS internal texture
  64094. * @param createPolynomials will be true if polynomials have been requested
  64095. * @param onLoad defines the callback to trigger once the texture is ready
  64096. * @param onError defines the callback to trigger in case of error
  64097. */
  64098. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64099. /**
  64100. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64101. * @param data contains the texture data
  64102. * @param texture defines the BabylonJS internal texture
  64103. * @param callback defines the method to call once ready to upload
  64104. */
  64105. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64106. }
  64107. }
  64108. declare module "babylonjs/Misc/basis" {
  64109. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64110. /**
  64111. * Info about the .basis files
  64112. */
  64113. class BasisFileInfo {
  64114. /**
  64115. * If the file has alpha
  64116. */
  64117. hasAlpha: boolean;
  64118. /**
  64119. * Info about each image of the basis file
  64120. */
  64121. images: Array<{
  64122. levels: Array<{
  64123. width: number;
  64124. height: number;
  64125. transcodedPixels: ArrayBufferView;
  64126. }>;
  64127. }>;
  64128. }
  64129. /**
  64130. * Result of transcoding a basis file
  64131. */
  64132. class TranscodeResult {
  64133. /**
  64134. * Info about the .basis file
  64135. */
  64136. fileInfo: BasisFileInfo;
  64137. /**
  64138. * Format to use when loading the file
  64139. */
  64140. format: number;
  64141. }
  64142. /**
  64143. * Configuration options for the Basis transcoder
  64144. */
  64145. export class BasisTranscodeConfiguration {
  64146. /**
  64147. * Supported compression formats used to determine the supported output format of the transcoder
  64148. */
  64149. supportedCompressionFormats?: {
  64150. /**
  64151. * etc1 compression format
  64152. */
  64153. etc1?: boolean;
  64154. /**
  64155. * s3tc compression format
  64156. */
  64157. s3tc?: boolean;
  64158. /**
  64159. * pvrtc compression format
  64160. */
  64161. pvrtc?: boolean;
  64162. /**
  64163. * etc2 compression format
  64164. */
  64165. etc2?: boolean;
  64166. };
  64167. /**
  64168. * If mipmap levels should be loaded for transcoded images (Default: true)
  64169. */
  64170. loadMipmapLevels?: boolean;
  64171. /**
  64172. * Index of a single image to load (Default: all images)
  64173. */
  64174. loadSingleImage?: number;
  64175. }
  64176. /**
  64177. * Used to load .Basis files
  64178. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64179. */
  64180. export class BasisTools {
  64181. private static _IgnoreSupportedFormats;
  64182. /**
  64183. * URL to use when loading the basis transcoder
  64184. */
  64185. static JSModuleURL: string;
  64186. /**
  64187. * URL to use when loading the wasm module for the transcoder
  64188. */
  64189. static WasmModuleURL: string;
  64190. /**
  64191. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64192. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64193. * @returns internal format corresponding to the Basis format
  64194. */
  64195. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64196. private static _WorkerPromise;
  64197. private static _Worker;
  64198. private static _actionId;
  64199. private static _CreateWorkerAsync;
  64200. /**
  64201. * Transcodes a loaded image file to compressed pixel data
  64202. * @param data image data to transcode
  64203. * @param config configuration options for the transcoding
  64204. * @returns a promise resulting in the transcoded image
  64205. */
  64206. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64207. /**
  64208. * Loads a texture from the transcode result
  64209. * @param texture texture load to
  64210. * @param transcodeResult the result of transcoding the basis file to load from
  64211. */
  64212. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64213. }
  64214. }
  64215. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64216. import { Nullable } from "babylonjs/types";
  64217. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64218. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64219. /**
  64220. * Loader for .basis file format
  64221. */
  64222. export class _BasisTextureLoader implements IInternalTextureLoader {
  64223. /**
  64224. * Defines whether the loader supports cascade loading the different faces.
  64225. */
  64226. readonly supportCascades: boolean;
  64227. /**
  64228. * This returns if the loader support the current file information.
  64229. * @param extension defines the file extension of the file being loaded
  64230. * @returns true if the loader can load the specified file
  64231. */
  64232. canLoad(extension: string): boolean;
  64233. /**
  64234. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64235. * @param data contains the texture data
  64236. * @param texture defines the BabylonJS internal texture
  64237. * @param createPolynomials will be true if polynomials have been requested
  64238. * @param onLoad defines the callback to trigger once the texture is ready
  64239. * @param onError defines the callback to trigger in case of error
  64240. */
  64241. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64242. /**
  64243. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64244. * @param data contains the texture data
  64245. * @param texture defines the BabylonJS internal texture
  64246. * @param callback defines the method to call once ready to upload
  64247. */
  64248. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64249. }
  64250. }
  64251. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64252. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64253. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64254. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64255. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64256. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64257. }
  64258. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64259. import { Vector2 } from "babylonjs/Maths/math.vector";
  64260. /**
  64261. * Defines the basic options interface of a TexturePacker Frame
  64262. */
  64263. export interface ITexturePackerFrame {
  64264. /**
  64265. * The frame ID
  64266. */
  64267. id: number;
  64268. /**
  64269. * The frames Scale
  64270. */
  64271. scale: Vector2;
  64272. /**
  64273. * The Frames offset
  64274. */
  64275. offset: Vector2;
  64276. }
  64277. /**
  64278. * This is a support class for frame Data on texture packer sets.
  64279. */
  64280. export class TexturePackerFrame implements ITexturePackerFrame {
  64281. /**
  64282. * The frame ID
  64283. */
  64284. id: number;
  64285. /**
  64286. * The frames Scale
  64287. */
  64288. scale: Vector2;
  64289. /**
  64290. * The Frames offset
  64291. */
  64292. offset: Vector2;
  64293. /**
  64294. * Initializes a texture package frame.
  64295. * @param id The numerical frame identifier
  64296. * @param scale Scalar Vector2 for UV frame
  64297. * @param offset Vector2 for the frame position in UV units.
  64298. * @returns TexturePackerFrame
  64299. */
  64300. constructor(id: number, scale: Vector2, offset: Vector2);
  64301. }
  64302. }
  64303. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64305. import { Scene } from "babylonjs/scene";
  64306. import { Nullable } from "babylonjs/types";
  64307. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64308. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64309. /**
  64310. * Defines the basic options interface of a TexturePacker
  64311. */
  64312. export interface ITexturePackerOptions {
  64313. /**
  64314. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64315. */
  64316. map?: string[];
  64317. /**
  64318. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64319. */
  64320. uvsIn?: string;
  64321. /**
  64322. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64323. */
  64324. uvsOut?: string;
  64325. /**
  64326. * number representing the layout style. Defaults to LAYOUT_STRIP
  64327. */
  64328. layout?: number;
  64329. /**
  64330. * number of columns if using custom column count layout(2). This defaults to 4.
  64331. */
  64332. colnum?: number;
  64333. /**
  64334. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64335. */
  64336. updateInputMeshes?: boolean;
  64337. /**
  64338. * boolean flag to dispose all the source textures. Defaults to true.
  64339. */
  64340. disposeSources?: boolean;
  64341. /**
  64342. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64343. */
  64344. fillBlanks?: boolean;
  64345. /**
  64346. * string value representing the context fill style color. Defaults to 'black'.
  64347. */
  64348. customFillColor?: string;
  64349. /**
  64350. * Width and Height Value of each Frame in the TexturePacker Sets
  64351. */
  64352. frameSize?: number;
  64353. /**
  64354. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64355. */
  64356. paddingRatio?: number;
  64357. /**
  64358. * Number that declares the fill method for the padding gutter.
  64359. */
  64360. paddingMode?: number;
  64361. /**
  64362. * If in SUBUV_COLOR padding mode what color to use.
  64363. */
  64364. paddingColor?: Color3 | Color4;
  64365. }
  64366. /**
  64367. * Defines the basic interface of a TexturePacker JSON File
  64368. */
  64369. export interface ITexturePackerJSON {
  64370. /**
  64371. * The frame ID
  64372. */
  64373. name: string;
  64374. /**
  64375. * The base64 channel data
  64376. */
  64377. sets: any;
  64378. /**
  64379. * The options of the Packer
  64380. */
  64381. options: ITexturePackerOptions;
  64382. /**
  64383. * The frame data of the Packer
  64384. */
  64385. frames: Array<number>;
  64386. }
  64387. /**
  64388. * This is a support class that generates a series of packed texture sets.
  64389. * @see https://doc.babylonjs.com/babylon101/materials
  64390. */
  64391. export class TexturePacker {
  64392. /** Packer Layout Constant 0 */
  64393. static readonly LAYOUT_STRIP: number;
  64394. /** Packer Layout Constant 1 */
  64395. static readonly LAYOUT_POWER2: number;
  64396. /** Packer Layout Constant 2 */
  64397. static readonly LAYOUT_COLNUM: number;
  64398. /** Packer Layout Constant 0 */
  64399. static readonly SUBUV_WRAP: number;
  64400. /** Packer Layout Constant 1 */
  64401. static readonly SUBUV_EXTEND: number;
  64402. /** Packer Layout Constant 2 */
  64403. static readonly SUBUV_COLOR: number;
  64404. /** The Name of the Texture Package */
  64405. name: string;
  64406. /** The scene scope of the TexturePacker */
  64407. scene: Scene;
  64408. /** The Meshes to target */
  64409. meshes: AbstractMesh[];
  64410. /** Arguments passed with the Constructor */
  64411. options: ITexturePackerOptions;
  64412. /** The promise that is started upon initialization */
  64413. promise: Nullable<Promise<TexturePacker | string>>;
  64414. /** The Container object for the channel sets that are generated */
  64415. sets: object;
  64416. /** The Container array for the frames that are generated */
  64417. frames: TexturePackerFrame[];
  64418. /** The expected number of textures the system is parsing. */
  64419. private _expecting;
  64420. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64421. private _paddingValue;
  64422. /**
  64423. * Initializes a texture package series from an array of meshes or a single mesh.
  64424. * @param name The name of the package
  64425. * @param meshes The target meshes to compose the package from
  64426. * @param options The arguments that texture packer should follow while building.
  64427. * @param scene The scene which the textures are scoped to.
  64428. * @returns TexturePacker
  64429. */
  64430. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64431. /**
  64432. * Starts the package process
  64433. * @param resolve The promises resolution function
  64434. * @returns TexturePacker
  64435. */
  64436. private _createFrames;
  64437. /**
  64438. * Calculates the Size of the Channel Sets
  64439. * @returns Vector2
  64440. */
  64441. private _calculateSize;
  64442. /**
  64443. * Calculates the UV data for the frames.
  64444. * @param baseSize the base frameSize
  64445. * @param padding the base frame padding
  64446. * @param dtSize size of the Dynamic Texture for that channel
  64447. * @param dtUnits is 1/dtSize
  64448. * @param update flag to update the input meshes
  64449. */
  64450. private _calculateMeshUVFrames;
  64451. /**
  64452. * Calculates the frames Offset.
  64453. * @param index of the frame
  64454. * @returns Vector2
  64455. */
  64456. private _getFrameOffset;
  64457. /**
  64458. * Updates a Mesh to the frame data
  64459. * @param mesh that is the target
  64460. * @param frameID or the frame index
  64461. */
  64462. private _updateMeshUV;
  64463. /**
  64464. * Updates a Meshes materials to use the texture packer channels
  64465. * @param m is the mesh to target
  64466. * @param force all channels on the packer to be set.
  64467. */
  64468. private _updateTextureReferences;
  64469. /**
  64470. * Public method to set a Mesh to a frame
  64471. * @param m that is the target
  64472. * @param frameID or the frame index
  64473. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64474. */
  64475. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64476. /**
  64477. * Starts the async promise to compile the texture packer.
  64478. * @returns Promise<void>
  64479. */
  64480. processAsync(): Promise<void>;
  64481. /**
  64482. * Disposes all textures associated with this packer
  64483. */
  64484. dispose(): void;
  64485. /**
  64486. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64487. * @param imageType is the image type to use.
  64488. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64489. */
  64490. download(imageType?: string, quality?: number): void;
  64491. /**
  64492. * Public method to load a texturePacker JSON file.
  64493. * @param data of the JSON file in string format.
  64494. */
  64495. updateFromJSON(data: string): void;
  64496. }
  64497. }
  64498. declare module "babylonjs/Materials/Textures/Packer/index" {
  64499. export * from "babylonjs/Materials/Textures/Packer/packer";
  64500. export * from "babylonjs/Materials/Textures/Packer/frame";
  64501. }
  64502. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64503. import { Scene } from "babylonjs/scene";
  64504. import { Texture } from "babylonjs/Materials/Textures/texture";
  64505. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64506. /**
  64507. * 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.
  64508. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64509. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64510. */
  64511. export class CustomProceduralTexture extends ProceduralTexture {
  64512. private _animate;
  64513. private _time;
  64514. private _config;
  64515. private _texturePath;
  64516. /**
  64517. * Instantiates a new Custom Procedural Texture.
  64518. * 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.
  64519. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64520. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64521. * @param name Define the name of the texture
  64522. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64523. * @param size Define the size of the texture to create
  64524. * @param scene Define the scene the texture belongs to
  64525. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64526. * @param generateMipMaps Define if the texture should creates mip maps or not
  64527. */
  64528. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64529. private _loadJson;
  64530. /**
  64531. * Is the texture ready to be used ? (rendered at least once)
  64532. * @returns true if ready, otherwise, false.
  64533. */
  64534. isReady(): boolean;
  64535. /**
  64536. * Render the texture to its associated render target.
  64537. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64538. */
  64539. render(useCameraPostProcess?: boolean): void;
  64540. /**
  64541. * Update the list of dependant textures samplers in the shader.
  64542. */
  64543. updateTextures(): void;
  64544. /**
  64545. * Update the uniform values of the procedural texture in the shader.
  64546. */
  64547. updateShaderUniforms(): void;
  64548. /**
  64549. * Define if the texture animates or not.
  64550. */
  64551. get animate(): boolean;
  64552. set animate(value: boolean);
  64553. }
  64554. }
  64555. declare module "babylonjs/Shaders/noise.fragment" {
  64556. /** @hidden */
  64557. export var noisePixelShader: {
  64558. name: string;
  64559. shader: string;
  64560. };
  64561. }
  64562. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64563. import { Nullable } from "babylonjs/types";
  64564. import { Scene } from "babylonjs/scene";
  64565. import { Texture } from "babylonjs/Materials/Textures/texture";
  64566. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64567. import "babylonjs/Shaders/noise.fragment";
  64568. /**
  64569. * Class used to generate noise procedural textures
  64570. */
  64571. export class NoiseProceduralTexture extends ProceduralTexture {
  64572. private _time;
  64573. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64574. brightness: number;
  64575. /** Defines the number of octaves to process */
  64576. octaves: number;
  64577. /** Defines the level of persistence (0.8 by default) */
  64578. persistence: number;
  64579. /** Gets or sets animation speed factor (default is 1) */
  64580. animationSpeedFactor: number;
  64581. /**
  64582. * Creates a new NoiseProceduralTexture
  64583. * @param name defines the name fo the texture
  64584. * @param size defines the size of the texture (default is 256)
  64585. * @param scene defines the hosting scene
  64586. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64587. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64588. */
  64589. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64590. private _updateShaderUniforms;
  64591. protected _getDefines(): string;
  64592. /** Generate the current state of the procedural texture */
  64593. render(useCameraPostProcess?: boolean): void;
  64594. /**
  64595. * Serializes this noise procedural texture
  64596. * @returns a serialized noise procedural texture object
  64597. */
  64598. serialize(): any;
  64599. /**
  64600. * Clone the texture.
  64601. * @returns the cloned texture
  64602. */
  64603. clone(): NoiseProceduralTexture;
  64604. /**
  64605. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64606. * @param parsedTexture defines parsed texture data
  64607. * @param scene defines the current scene
  64608. * @param rootUrl defines the root URL containing noise procedural texture information
  64609. * @returns a parsed NoiseProceduralTexture
  64610. */
  64611. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64612. }
  64613. }
  64614. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64615. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64616. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64617. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64618. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64619. }
  64620. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64621. import { Nullable } from "babylonjs/types";
  64622. import { Scene } from "babylonjs/scene";
  64623. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64624. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64625. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64626. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64627. /**
  64628. * Raw cube texture where the raw buffers are passed in
  64629. */
  64630. export class RawCubeTexture extends CubeTexture {
  64631. /**
  64632. * Creates a cube texture where the raw buffers are passed in.
  64633. * @param scene defines the scene the texture is attached to
  64634. * @param data defines the array of data to use to create each face
  64635. * @param size defines the size of the textures
  64636. * @param format defines the format of the data
  64637. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64638. * @param generateMipMaps defines if the engine should generate the mip levels
  64639. * @param invertY defines if data must be stored with Y axis inverted
  64640. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64641. * @param compression defines the compression used (null by default)
  64642. */
  64643. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64644. /**
  64645. * Updates the raw cube texture.
  64646. * @param data defines the data to store
  64647. * @param format defines the data format
  64648. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64649. * @param invertY defines if data must be stored with Y axis inverted
  64650. * @param compression defines the compression used (null by default)
  64651. * @param level defines which level of the texture to update
  64652. */
  64653. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64654. /**
  64655. * Updates a raw cube texture with RGBD encoded data.
  64656. * @param data defines the array of data [mipmap][face] to use to create each face
  64657. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64660. * @returns a promsie that resolves when the operation is complete
  64661. */
  64662. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64663. /**
  64664. * Clones the raw cube texture.
  64665. * @return a new cube texture
  64666. */
  64667. clone(): CubeTexture;
  64668. /** @hidden */
  64669. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64670. }
  64671. }
  64672. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64673. import { Scene } from "babylonjs/scene";
  64674. import { Texture } from "babylonjs/Materials/Textures/texture";
  64675. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64676. /**
  64677. * Class used to store 2D array textures containing user data
  64678. */
  64679. export class RawTexture2DArray extends Texture {
  64680. /** Gets or sets the texture format to use */
  64681. format: number;
  64682. /**
  64683. * Create a new RawTexture2DArray
  64684. * @param data defines the data of the texture
  64685. * @param width defines the width of the texture
  64686. * @param height defines the height of the texture
  64687. * @param depth defines the number of layers of the texture
  64688. * @param format defines the texture format to use
  64689. * @param scene defines the hosting scene
  64690. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64691. * @param invertY defines if texture must be stored with Y axis inverted
  64692. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64693. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64694. */
  64695. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64696. /** Gets or sets the texture format to use */
  64697. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64698. /**
  64699. * Update the texture with new data
  64700. * @param data defines the data to store in the texture
  64701. */
  64702. update(data: ArrayBufferView): void;
  64703. }
  64704. }
  64705. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64706. import { Scene } from "babylonjs/scene";
  64707. import { Texture } from "babylonjs/Materials/Textures/texture";
  64708. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64709. /**
  64710. * Class used to store 3D textures containing user data
  64711. */
  64712. export class RawTexture3D extends Texture {
  64713. /** Gets or sets the texture format to use */
  64714. format: number;
  64715. /**
  64716. * Create a new RawTexture3D
  64717. * @param data defines the data of the texture
  64718. * @param width defines the width of the texture
  64719. * @param height defines the height of the texture
  64720. * @param depth defines the depth of the texture
  64721. * @param format defines the texture format to use
  64722. * @param scene defines the hosting scene
  64723. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64724. * @param invertY defines if texture must be stored with Y axis inverted
  64725. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64726. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64727. */
  64728. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64729. /** Gets or sets the texture format to use */
  64730. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64731. /**
  64732. * Update the texture with new data
  64733. * @param data defines the data to store in the texture
  64734. */
  64735. update(data: ArrayBufferView): void;
  64736. }
  64737. }
  64738. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64739. import { Scene } from "babylonjs/scene";
  64740. import { Plane } from "babylonjs/Maths/math.plane";
  64741. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64742. /**
  64743. * Creates a refraction texture used by refraction channel of the standard material.
  64744. * It is like a mirror but to see through a material.
  64745. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64746. */
  64747. export class RefractionTexture extends RenderTargetTexture {
  64748. /**
  64749. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64750. * 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.
  64751. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64752. */
  64753. refractionPlane: Plane;
  64754. /**
  64755. * Define how deep under the surface we should see.
  64756. */
  64757. depth: number;
  64758. /**
  64759. * Creates a refraction texture used by refraction channel of the standard material.
  64760. * It is like a mirror but to see through a material.
  64761. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64762. * @param name Define the texture name
  64763. * @param size Define the size of the underlying texture
  64764. * @param scene Define the scene the refraction belongs to
  64765. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64766. */
  64767. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64768. /**
  64769. * Clone the refraction texture.
  64770. * @returns the cloned texture
  64771. */
  64772. clone(): RefractionTexture;
  64773. /**
  64774. * Serialize the texture to a JSON representation you could use in Parse later on
  64775. * @returns the serialized JSON representation
  64776. */
  64777. serialize(): any;
  64778. }
  64779. }
  64780. declare module "babylonjs/Materials/Textures/index" {
  64781. export * from "babylonjs/Materials/Textures/baseTexture";
  64782. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64783. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64784. export * from "babylonjs/Materials/Textures/cubeTexture";
  64785. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64786. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64787. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64788. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64789. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64790. export * from "babylonjs/Materials/Textures/internalTexture";
  64791. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64792. export * from "babylonjs/Materials/Textures/Loaders/index";
  64793. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64794. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64795. export * from "babylonjs/Materials/Textures/Packer/index";
  64796. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64797. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64798. export * from "babylonjs/Materials/Textures/rawTexture";
  64799. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64800. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64801. export * from "babylonjs/Materials/Textures/refractionTexture";
  64802. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64803. export * from "babylonjs/Materials/Textures/texture";
  64804. export * from "babylonjs/Materials/Textures/videoTexture";
  64805. }
  64806. declare module "babylonjs/Materials/Node/Enums/index" {
  64807. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64808. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64809. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64810. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64811. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64812. }
  64813. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64817. import { Mesh } from "babylonjs/Meshes/mesh";
  64818. import { Effect } from "babylonjs/Materials/effect";
  64819. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64820. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64821. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64822. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64823. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64824. /**
  64825. * Block used to add support for vertex skinning (bones)
  64826. */
  64827. export class BonesBlock extends NodeMaterialBlock {
  64828. /**
  64829. * Creates a new BonesBlock
  64830. * @param name defines the block name
  64831. */
  64832. constructor(name: string);
  64833. /**
  64834. * Initialize the block and prepare the context for build
  64835. * @param state defines the state that will be used for the build
  64836. */
  64837. initialize(state: NodeMaterialBuildState): void;
  64838. /**
  64839. * Gets the current class name
  64840. * @returns the class name
  64841. */
  64842. getClassName(): string;
  64843. /**
  64844. * Gets the matrix indices input component
  64845. */
  64846. get matricesIndices(): NodeMaterialConnectionPoint;
  64847. /**
  64848. * Gets the matrix weights input component
  64849. */
  64850. get matricesWeights(): NodeMaterialConnectionPoint;
  64851. /**
  64852. * Gets the extra matrix indices input component
  64853. */
  64854. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64855. /**
  64856. * Gets the extra matrix weights input component
  64857. */
  64858. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64859. /**
  64860. * Gets the world input component
  64861. */
  64862. get world(): NodeMaterialConnectionPoint;
  64863. /**
  64864. * Gets the output component
  64865. */
  64866. get output(): NodeMaterialConnectionPoint;
  64867. autoConfigure(material: NodeMaterial): void;
  64868. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64869. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64870. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64871. protected _buildBlock(state: NodeMaterialBuildState): this;
  64872. }
  64873. }
  64874. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64879. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64880. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64881. /**
  64882. * Block used to add support for instances
  64883. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64884. */
  64885. export class InstancesBlock extends NodeMaterialBlock {
  64886. /**
  64887. * Creates a new InstancesBlock
  64888. * @param name defines the block name
  64889. */
  64890. constructor(name: string);
  64891. /**
  64892. * Gets the current class name
  64893. * @returns the class name
  64894. */
  64895. getClassName(): string;
  64896. /**
  64897. * Gets the first world row input component
  64898. */
  64899. get world0(): NodeMaterialConnectionPoint;
  64900. /**
  64901. * Gets the second world row input component
  64902. */
  64903. get world1(): NodeMaterialConnectionPoint;
  64904. /**
  64905. * Gets the third world row input component
  64906. */
  64907. get world2(): NodeMaterialConnectionPoint;
  64908. /**
  64909. * Gets the forth world row input component
  64910. */
  64911. get world3(): NodeMaterialConnectionPoint;
  64912. /**
  64913. * Gets the world input component
  64914. */
  64915. get world(): NodeMaterialConnectionPoint;
  64916. /**
  64917. * Gets the output component
  64918. */
  64919. get output(): NodeMaterialConnectionPoint;
  64920. /**
  64921. * Gets the isntanceID component
  64922. */
  64923. get instanceID(): NodeMaterialConnectionPoint;
  64924. autoConfigure(material: NodeMaterial): void;
  64925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64926. protected _buildBlock(state: NodeMaterialBuildState): this;
  64927. }
  64928. }
  64929. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64934. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64935. import { Effect } from "babylonjs/Materials/effect";
  64936. import { Mesh } from "babylonjs/Meshes/mesh";
  64937. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64938. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64939. /**
  64940. * Block used to add morph targets support to vertex shader
  64941. */
  64942. export class MorphTargetsBlock extends NodeMaterialBlock {
  64943. private _repeatableContentAnchor;
  64944. /**
  64945. * Create a new MorphTargetsBlock
  64946. * @param name defines the block name
  64947. */
  64948. constructor(name: string);
  64949. /**
  64950. * Gets the current class name
  64951. * @returns the class name
  64952. */
  64953. getClassName(): string;
  64954. /**
  64955. * Gets the position input component
  64956. */
  64957. get position(): NodeMaterialConnectionPoint;
  64958. /**
  64959. * Gets the normal input component
  64960. */
  64961. get normal(): NodeMaterialConnectionPoint;
  64962. /**
  64963. * Gets the tangent input component
  64964. */
  64965. get tangent(): NodeMaterialConnectionPoint;
  64966. /**
  64967. * Gets the tangent input component
  64968. */
  64969. get uv(): NodeMaterialConnectionPoint;
  64970. /**
  64971. * Gets the position output component
  64972. */
  64973. get positionOutput(): NodeMaterialConnectionPoint;
  64974. /**
  64975. * Gets the normal output component
  64976. */
  64977. get normalOutput(): NodeMaterialConnectionPoint;
  64978. /**
  64979. * Gets the tangent output component
  64980. */
  64981. get tangentOutput(): NodeMaterialConnectionPoint;
  64982. /**
  64983. * Gets the tangent output component
  64984. */
  64985. get uvOutput(): NodeMaterialConnectionPoint;
  64986. initialize(state: NodeMaterialBuildState): void;
  64987. autoConfigure(material: NodeMaterial): void;
  64988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64989. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64990. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64991. protected _buildBlock(state: NodeMaterialBuildState): this;
  64992. }
  64993. }
  64994. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64998. import { Nullable } from "babylonjs/types";
  64999. import { Scene } from "babylonjs/scene";
  65000. import { Effect } from "babylonjs/Materials/effect";
  65001. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65002. import { Mesh } from "babylonjs/Meshes/mesh";
  65003. import { Light } from "babylonjs/Lights/light";
  65004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65005. /**
  65006. * Block used to get data information from a light
  65007. */
  65008. export class LightInformationBlock extends NodeMaterialBlock {
  65009. private _lightDataUniformName;
  65010. private _lightColorUniformName;
  65011. private _lightTypeDefineName;
  65012. /**
  65013. * Gets or sets the light associated with this block
  65014. */
  65015. light: Nullable<Light>;
  65016. /**
  65017. * Creates a new LightInformationBlock
  65018. * @param name defines the block name
  65019. */
  65020. constructor(name: string);
  65021. /**
  65022. * Gets the current class name
  65023. * @returns the class name
  65024. */
  65025. getClassName(): string;
  65026. /**
  65027. * Gets the world position input component
  65028. */
  65029. get worldPosition(): NodeMaterialConnectionPoint;
  65030. /**
  65031. * Gets the direction output component
  65032. */
  65033. get direction(): NodeMaterialConnectionPoint;
  65034. /**
  65035. * Gets the direction output component
  65036. */
  65037. get color(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the direction output component
  65040. */
  65041. get intensity(): NodeMaterialConnectionPoint;
  65042. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65044. protected _buildBlock(state: NodeMaterialBuildState): this;
  65045. serialize(): any;
  65046. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65047. }
  65048. }
  65049. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65050. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65051. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65052. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65053. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65054. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65055. }
  65056. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65061. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65062. import { Effect } from "babylonjs/Materials/effect";
  65063. import { Mesh } from "babylonjs/Meshes/mesh";
  65064. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65065. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65066. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65067. /**
  65068. * Block used to add image processing support to fragment shader
  65069. */
  65070. export class ImageProcessingBlock extends NodeMaterialBlock {
  65071. /**
  65072. * Create a new ImageProcessingBlock
  65073. * @param name defines the block name
  65074. */
  65075. constructor(name: string);
  65076. /**
  65077. * Gets the current class name
  65078. * @returns the class name
  65079. */
  65080. getClassName(): string;
  65081. /**
  65082. * Gets the color input component
  65083. */
  65084. get color(): NodeMaterialConnectionPoint;
  65085. /**
  65086. * Gets the output component
  65087. */
  65088. get output(): NodeMaterialConnectionPoint;
  65089. /**
  65090. * Initialize the block and prepare the context for build
  65091. * @param state defines the state that will be used for the build
  65092. */
  65093. initialize(state: NodeMaterialBuildState): void;
  65094. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65096. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65097. protected _buildBlock(state: NodeMaterialBuildState): this;
  65098. }
  65099. }
  65100. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65104. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65106. import { Effect } from "babylonjs/Materials/effect";
  65107. import { Mesh } from "babylonjs/Meshes/mesh";
  65108. import { Scene } from "babylonjs/scene";
  65109. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65110. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65111. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65112. /**
  65113. * Block used to pertub normals based on a normal map
  65114. */
  65115. export class PerturbNormalBlock extends NodeMaterialBlock {
  65116. private _tangentSpaceParameterName;
  65117. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65118. invertX: boolean;
  65119. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65120. invertY: boolean;
  65121. /**
  65122. * Create a new PerturbNormalBlock
  65123. * @param name defines the block name
  65124. */
  65125. constructor(name: string);
  65126. /**
  65127. * Gets the current class name
  65128. * @returns the class name
  65129. */
  65130. getClassName(): string;
  65131. /**
  65132. * Gets the world position input component
  65133. */
  65134. get worldPosition(): NodeMaterialConnectionPoint;
  65135. /**
  65136. * Gets the world normal input component
  65137. */
  65138. get worldNormal(): NodeMaterialConnectionPoint;
  65139. /**
  65140. * Gets the world tangent input component
  65141. */
  65142. get worldTangent(): NodeMaterialConnectionPoint;
  65143. /**
  65144. * Gets the uv input component
  65145. */
  65146. get uv(): NodeMaterialConnectionPoint;
  65147. /**
  65148. * Gets the normal map color input component
  65149. */
  65150. get normalMapColor(): NodeMaterialConnectionPoint;
  65151. /**
  65152. * Gets the strength input component
  65153. */
  65154. get strength(): NodeMaterialConnectionPoint;
  65155. /**
  65156. * Gets the output component
  65157. */
  65158. get output(): NodeMaterialConnectionPoint;
  65159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65161. autoConfigure(material: NodeMaterial): void;
  65162. protected _buildBlock(state: NodeMaterialBuildState): this;
  65163. protected _dumpPropertiesCode(): string;
  65164. serialize(): any;
  65165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65166. }
  65167. }
  65168. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65172. /**
  65173. * Block used to discard a pixel if a value is smaller than a cutoff
  65174. */
  65175. export class DiscardBlock extends NodeMaterialBlock {
  65176. /**
  65177. * Create a new DiscardBlock
  65178. * @param name defines the block name
  65179. */
  65180. constructor(name: string);
  65181. /**
  65182. * Gets the current class name
  65183. * @returns the class name
  65184. */
  65185. getClassName(): string;
  65186. /**
  65187. * Gets the color input component
  65188. */
  65189. get value(): NodeMaterialConnectionPoint;
  65190. /**
  65191. * Gets the cutoff input component
  65192. */
  65193. get cutoff(): NodeMaterialConnectionPoint;
  65194. protected _buildBlock(state: NodeMaterialBuildState): this;
  65195. }
  65196. }
  65197. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65201. /**
  65202. * Block used to test if the fragment shader is front facing
  65203. */
  65204. export class FrontFacingBlock extends NodeMaterialBlock {
  65205. /**
  65206. * Creates a new FrontFacingBlock
  65207. * @param name defines the block name
  65208. */
  65209. constructor(name: string);
  65210. /**
  65211. * Gets the current class name
  65212. * @returns the class name
  65213. */
  65214. getClassName(): string;
  65215. /**
  65216. * Gets the output component
  65217. */
  65218. get output(): NodeMaterialConnectionPoint;
  65219. protected _buildBlock(state: NodeMaterialBuildState): this;
  65220. }
  65221. }
  65222. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65226. /**
  65227. * Block used to get the derivative value on x and y of a given input
  65228. */
  65229. export class DerivativeBlock extends NodeMaterialBlock {
  65230. /**
  65231. * Create a new DerivativeBlock
  65232. * @param name defines the block name
  65233. */
  65234. constructor(name: string);
  65235. /**
  65236. * Gets the current class name
  65237. * @returns the class name
  65238. */
  65239. getClassName(): string;
  65240. /**
  65241. * Gets the input component
  65242. */
  65243. get input(): NodeMaterialConnectionPoint;
  65244. /**
  65245. * Gets the derivative output on x
  65246. */
  65247. get dx(): NodeMaterialConnectionPoint;
  65248. /**
  65249. * Gets the derivative output on y
  65250. */
  65251. get dy(): NodeMaterialConnectionPoint;
  65252. protected _buildBlock(state: NodeMaterialBuildState): this;
  65253. }
  65254. }
  65255. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65259. /**
  65260. * Block used to make gl_FragCoord available
  65261. */
  65262. export class FragCoordBlock extends NodeMaterialBlock {
  65263. /**
  65264. * Creates a new FragCoordBlock
  65265. * @param name defines the block name
  65266. */
  65267. constructor(name: string);
  65268. /**
  65269. * Gets the current class name
  65270. * @returns the class name
  65271. */
  65272. getClassName(): string;
  65273. /**
  65274. * Gets the xy component
  65275. */
  65276. get xy(): NodeMaterialConnectionPoint;
  65277. /**
  65278. * Gets the xyz component
  65279. */
  65280. get xyz(): NodeMaterialConnectionPoint;
  65281. /**
  65282. * Gets the xyzw component
  65283. */
  65284. get xyzw(): NodeMaterialConnectionPoint;
  65285. /**
  65286. * Gets the x component
  65287. */
  65288. get x(): NodeMaterialConnectionPoint;
  65289. /**
  65290. * Gets the y component
  65291. */
  65292. get y(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the z component
  65295. */
  65296. get z(): NodeMaterialConnectionPoint;
  65297. /**
  65298. * Gets the w component
  65299. */
  65300. get output(): NodeMaterialConnectionPoint;
  65301. protected writeOutputs(state: NodeMaterialBuildState): string;
  65302. protected _buildBlock(state: NodeMaterialBuildState): this;
  65303. }
  65304. }
  65305. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65309. import { Effect } from "babylonjs/Materials/effect";
  65310. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65311. import { Mesh } from "babylonjs/Meshes/mesh";
  65312. /**
  65313. * Block used to get the screen sizes
  65314. */
  65315. export class ScreenSizeBlock extends NodeMaterialBlock {
  65316. private _varName;
  65317. private _scene;
  65318. /**
  65319. * Creates a new ScreenSizeBlock
  65320. * @param name defines the block name
  65321. */
  65322. constructor(name: string);
  65323. /**
  65324. * Gets the current class name
  65325. * @returns the class name
  65326. */
  65327. getClassName(): string;
  65328. /**
  65329. * Gets the xy component
  65330. */
  65331. get xy(): NodeMaterialConnectionPoint;
  65332. /**
  65333. * Gets the x component
  65334. */
  65335. get x(): NodeMaterialConnectionPoint;
  65336. /**
  65337. * Gets the y component
  65338. */
  65339. get y(): NodeMaterialConnectionPoint;
  65340. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65341. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65342. protected _buildBlock(state: NodeMaterialBuildState): this;
  65343. }
  65344. }
  65345. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65346. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65347. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65348. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65349. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65350. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65351. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65352. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65353. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65354. }
  65355. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65358. import { Mesh } from "babylonjs/Meshes/mesh";
  65359. import { Effect } from "babylonjs/Materials/effect";
  65360. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65362. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65363. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65364. /**
  65365. * Block used to add support for scene fog
  65366. */
  65367. export class FogBlock extends NodeMaterialBlock {
  65368. private _fogDistanceName;
  65369. private _fogParameters;
  65370. /**
  65371. * Create a new FogBlock
  65372. * @param name defines the block name
  65373. */
  65374. constructor(name: string);
  65375. /**
  65376. * Gets the current class name
  65377. * @returns the class name
  65378. */
  65379. getClassName(): string;
  65380. /**
  65381. * Gets the world position input component
  65382. */
  65383. get worldPosition(): NodeMaterialConnectionPoint;
  65384. /**
  65385. * Gets the view input component
  65386. */
  65387. get view(): NodeMaterialConnectionPoint;
  65388. /**
  65389. * Gets the color input component
  65390. */
  65391. get input(): NodeMaterialConnectionPoint;
  65392. /**
  65393. * Gets the fog color input component
  65394. */
  65395. get fogColor(): NodeMaterialConnectionPoint;
  65396. /**
  65397. * Gets the output component
  65398. */
  65399. get output(): NodeMaterialConnectionPoint;
  65400. autoConfigure(material: NodeMaterial): void;
  65401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65403. protected _buildBlock(state: NodeMaterialBuildState): this;
  65404. }
  65405. }
  65406. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65411. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65412. import { Effect } from "babylonjs/Materials/effect";
  65413. import { Mesh } from "babylonjs/Meshes/mesh";
  65414. import { Light } from "babylonjs/Lights/light";
  65415. import { Nullable } from "babylonjs/types";
  65416. import { Scene } from "babylonjs/scene";
  65417. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65418. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65419. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65420. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65421. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65422. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65423. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65424. /**
  65425. * Block used to add light in the fragment shader
  65426. */
  65427. export class LightBlock extends NodeMaterialBlock {
  65428. private _lightId;
  65429. /**
  65430. * Gets or sets the light associated with this block
  65431. */
  65432. light: Nullable<Light>;
  65433. /**
  65434. * Create a new LightBlock
  65435. * @param name defines the block name
  65436. */
  65437. constructor(name: string);
  65438. /**
  65439. * Gets the current class name
  65440. * @returns the class name
  65441. */
  65442. getClassName(): string;
  65443. /**
  65444. * Gets the world position input component
  65445. */
  65446. get worldPosition(): NodeMaterialConnectionPoint;
  65447. /**
  65448. * Gets the world normal input component
  65449. */
  65450. get worldNormal(): NodeMaterialConnectionPoint;
  65451. /**
  65452. * Gets the camera (or eye) position component
  65453. */
  65454. get cameraPosition(): NodeMaterialConnectionPoint;
  65455. /**
  65456. * Gets the glossiness component
  65457. */
  65458. get glossiness(): NodeMaterialConnectionPoint;
  65459. /**
  65460. * Gets the glossinness power component
  65461. */
  65462. get glossPower(): NodeMaterialConnectionPoint;
  65463. /**
  65464. * Gets the diffuse color component
  65465. */
  65466. get diffuseColor(): NodeMaterialConnectionPoint;
  65467. /**
  65468. * Gets the specular color component
  65469. */
  65470. get specularColor(): NodeMaterialConnectionPoint;
  65471. /**
  65472. * Gets the diffuse output component
  65473. */
  65474. get diffuseOutput(): NodeMaterialConnectionPoint;
  65475. /**
  65476. * Gets the specular output component
  65477. */
  65478. get specularOutput(): NodeMaterialConnectionPoint;
  65479. /**
  65480. * Gets the shadow output component
  65481. */
  65482. get shadow(): NodeMaterialConnectionPoint;
  65483. autoConfigure(material: NodeMaterial): void;
  65484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65485. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65487. private _injectVertexCode;
  65488. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65489. serialize(): any;
  65490. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65491. }
  65492. }
  65493. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65494. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65495. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65496. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65497. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65498. /**
  65499. * Block used to read a reflection texture from a sampler
  65500. */
  65501. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65502. /**
  65503. * Create a new ReflectionTextureBlock
  65504. * @param name defines the block name
  65505. */
  65506. constructor(name: string);
  65507. /**
  65508. * Gets the current class name
  65509. * @returns the class name
  65510. */
  65511. getClassName(): string;
  65512. /**
  65513. * Gets the world position input component
  65514. */
  65515. get position(): NodeMaterialConnectionPoint;
  65516. /**
  65517. * Gets the world position input component
  65518. */
  65519. get worldPosition(): NodeMaterialConnectionPoint;
  65520. /**
  65521. * Gets the world normal input component
  65522. */
  65523. get worldNormal(): NodeMaterialConnectionPoint;
  65524. /**
  65525. * Gets the world input component
  65526. */
  65527. get world(): NodeMaterialConnectionPoint;
  65528. /**
  65529. * Gets the camera (or eye) position component
  65530. */
  65531. get cameraPosition(): NodeMaterialConnectionPoint;
  65532. /**
  65533. * Gets the view input component
  65534. */
  65535. get view(): NodeMaterialConnectionPoint;
  65536. /**
  65537. * Gets the rgb output component
  65538. */
  65539. get rgb(): NodeMaterialConnectionPoint;
  65540. /**
  65541. * Gets the rgba output component
  65542. */
  65543. get rgba(): NodeMaterialConnectionPoint;
  65544. /**
  65545. * Gets the r output component
  65546. */
  65547. get r(): NodeMaterialConnectionPoint;
  65548. /**
  65549. * Gets the g output component
  65550. */
  65551. get g(): NodeMaterialConnectionPoint;
  65552. /**
  65553. * Gets the b output component
  65554. */
  65555. get b(): NodeMaterialConnectionPoint;
  65556. /**
  65557. * Gets the a output component
  65558. */
  65559. get a(): NodeMaterialConnectionPoint;
  65560. autoConfigure(material: NodeMaterial): void;
  65561. protected _buildBlock(state: NodeMaterialBuildState): this;
  65562. }
  65563. }
  65564. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65565. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65566. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65567. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65568. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65569. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65570. }
  65571. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65572. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65573. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65574. }
  65575. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65577. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65579. /**
  65580. * Block used to add 2 vectors
  65581. */
  65582. export class AddBlock extends NodeMaterialBlock {
  65583. /**
  65584. * Creates a new AddBlock
  65585. * @param name defines the block name
  65586. */
  65587. constructor(name: string);
  65588. /**
  65589. * Gets the current class name
  65590. * @returns the class name
  65591. */
  65592. getClassName(): string;
  65593. /**
  65594. * Gets the left operand input component
  65595. */
  65596. get left(): NodeMaterialConnectionPoint;
  65597. /**
  65598. * Gets the right operand input component
  65599. */
  65600. get right(): NodeMaterialConnectionPoint;
  65601. /**
  65602. * Gets the output component
  65603. */
  65604. get output(): NodeMaterialConnectionPoint;
  65605. protected _buildBlock(state: NodeMaterialBuildState): this;
  65606. }
  65607. }
  65608. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65612. /**
  65613. * Block used to scale a vector by a float
  65614. */
  65615. export class ScaleBlock extends NodeMaterialBlock {
  65616. /**
  65617. * Creates a new ScaleBlock
  65618. * @param name defines the block name
  65619. */
  65620. constructor(name: string);
  65621. /**
  65622. * Gets the current class name
  65623. * @returns the class name
  65624. */
  65625. getClassName(): string;
  65626. /**
  65627. * Gets the input component
  65628. */
  65629. get input(): NodeMaterialConnectionPoint;
  65630. /**
  65631. * Gets the factor input component
  65632. */
  65633. get factor(): NodeMaterialConnectionPoint;
  65634. /**
  65635. * Gets the output component
  65636. */
  65637. get output(): NodeMaterialConnectionPoint;
  65638. protected _buildBlock(state: NodeMaterialBuildState): this;
  65639. }
  65640. }
  65641. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65645. import { Scene } from "babylonjs/scene";
  65646. /**
  65647. * Block used to clamp a float
  65648. */
  65649. export class ClampBlock extends NodeMaterialBlock {
  65650. /** Gets or sets the minimum range */
  65651. minimum: number;
  65652. /** Gets or sets the maximum range */
  65653. maximum: number;
  65654. /**
  65655. * Creates a new ClampBlock
  65656. * @param name defines the block name
  65657. */
  65658. constructor(name: string);
  65659. /**
  65660. * Gets the current class name
  65661. * @returns the class name
  65662. */
  65663. getClassName(): string;
  65664. /**
  65665. * Gets the value input component
  65666. */
  65667. get value(): NodeMaterialConnectionPoint;
  65668. /**
  65669. * Gets the output component
  65670. */
  65671. get output(): NodeMaterialConnectionPoint;
  65672. protected _buildBlock(state: NodeMaterialBuildState): this;
  65673. protected _dumpPropertiesCode(): string;
  65674. serialize(): any;
  65675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65676. }
  65677. }
  65678. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65682. /**
  65683. * Block used to apply a cross product between 2 vectors
  65684. */
  65685. export class CrossBlock extends NodeMaterialBlock {
  65686. /**
  65687. * Creates a new CrossBlock
  65688. * @param name defines the block name
  65689. */
  65690. constructor(name: string);
  65691. /**
  65692. * Gets the current class name
  65693. * @returns the class name
  65694. */
  65695. getClassName(): string;
  65696. /**
  65697. * Gets the left operand input component
  65698. */
  65699. get left(): NodeMaterialConnectionPoint;
  65700. /**
  65701. * Gets the right operand input component
  65702. */
  65703. get right(): NodeMaterialConnectionPoint;
  65704. /**
  65705. * Gets the output component
  65706. */
  65707. get output(): NodeMaterialConnectionPoint;
  65708. protected _buildBlock(state: NodeMaterialBuildState): this;
  65709. }
  65710. }
  65711. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65715. /**
  65716. * Block used to apply a dot product between 2 vectors
  65717. */
  65718. export class DotBlock extends NodeMaterialBlock {
  65719. /**
  65720. * Creates a new DotBlock
  65721. * @param name defines the block name
  65722. */
  65723. constructor(name: string);
  65724. /**
  65725. * Gets the current class name
  65726. * @returns the class name
  65727. */
  65728. getClassName(): string;
  65729. /**
  65730. * Gets the left operand input component
  65731. */
  65732. get left(): NodeMaterialConnectionPoint;
  65733. /**
  65734. * Gets the right operand input component
  65735. */
  65736. get right(): NodeMaterialConnectionPoint;
  65737. /**
  65738. * Gets the output component
  65739. */
  65740. get output(): NodeMaterialConnectionPoint;
  65741. protected _buildBlock(state: NodeMaterialBuildState): this;
  65742. }
  65743. }
  65744. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65748. /**
  65749. * Block used to normalize a vector
  65750. */
  65751. export class NormalizeBlock extends NodeMaterialBlock {
  65752. /**
  65753. * Creates a new NormalizeBlock
  65754. * @param name defines the block name
  65755. */
  65756. constructor(name: string);
  65757. /**
  65758. * Gets the current class name
  65759. * @returns the class name
  65760. */
  65761. getClassName(): string;
  65762. /**
  65763. * Gets the input component
  65764. */
  65765. get input(): NodeMaterialConnectionPoint;
  65766. /**
  65767. * Gets the output component
  65768. */
  65769. get output(): NodeMaterialConnectionPoint;
  65770. protected _buildBlock(state: NodeMaterialBuildState): this;
  65771. }
  65772. }
  65773. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65777. import { Scene } from "babylonjs/scene";
  65778. /**
  65779. * Operations supported by the Trigonometry block
  65780. */
  65781. export enum TrigonometryBlockOperations {
  65782. /** Cos */
  65783. Cos = 0,
  65784. /** Sin */
  65785. Sin = 1,
  65786. /** Abs */
  65787. Abs = 2,
  65788. /** Exp */
  65789. Exp = 3,
  65790. /** Exp2 */
  65791. Exp2 = 4,
  65792. /** Round */
  65793. Round = 5,
  65794. /** Floor */
  65795. Floor = 6,
  65796. /** Ceiling */
  65797. Ceiling = 7,
  65798. /** Square root */
  65799. Sqrt = 8,
  65800. /** Log */
  65801. Log = 9,
  65802. /** Tangent */
  65803. Tan = 10,
  65804. /** Arc tangent */
  65805. ArcTan = 11,
  65806. /** Arc cosinus */
  65807. ArcCos = 12,
  65808. /** Arc sinus */
  65809. ArcSin = 13,
  65810. /** Fraction */
  65811. Fract = 14,
  65812. /** Sign */
  65813. Sign = 15,
  65814. /** To radians (from degrees) */
  65815. Radians = 16,
  65816. /** To degrees (from radians) */
  65817. Degrees = 17
  65818. }
  65819. /**
  65820. * Block used to apply trigonometry operation to floats
  65821. */
  65822. export class TrigonometryBlock extends NodeMaterialBlock {
  65823. /**
  65824. * Gets or sets the operation applied by the block
  65825. */
  65826. operation: TrigonometryBlockOperations;
  65827. /**
  65828. * Creates a new TrigonometryBlock
  65829. * @param name defines the block name
  65830. */
  65831. constructor(name: string);
  65832. /**
  65833. * Gets the current class name
  65834. * @returns the class name
  65835. */
  65836. getClassName(): string;
  65837. /**
  65838. * Gets the input component
  65839. */
  65840. get input(): NodeMaterialConnectionPoint;
  65841. /**
  65842. * Gets the output component
  65843. */
  65844. get output(): NodeMaterialConnectionPoint;
  65845. protected _buildBlock(state: NodeMaterialBuildState): this;
  65846. serialize(): any;
  65847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65848. protected _dumpPropertiesCode(): string;
  65849. }
  65850. }
  65851. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65855. /**
  65856. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65857. */
  65858. export class ColorMergerBlock extends NodeMaterialBlock {
  65859. /**
  65860. * Create a new ColorMergerBlock
  65861. * @param name defines the block name
  65862. */
  65863. constructor(name: string);
  65864. /**
  65865. * Gets the current class name
  65866. * @returns the class name
  65867. */
  65868. getClassName(): string;
  65869. /**
  65870. * Gets the rgb component (input)
  65871. */
  65872. get rgbIn(): NodeMaterialConnectionPoint;
  65873. /**
  65874. * Gets the r component (input)
  65875. */
  65876. get r(): NodeMaterialConnectionPoint;
  65877. /**
  65878. * Gets the g component (input)
  65879. */
  65880. get g(): NodeMaterialConnectionPoint;
  65881. /**
  65882. * Gets the b component (input)
  65883. */
  65884. get b(): NodeMaterialConnectionPoint;
  65885. /**
  65886. * Gets the a component (input)
  65887. */
  65888. get a(): NodeMaterialConnectionPoint;
  65889. /**
  65890. * Gets the rgba component (output)
  65891. */
  65892. get rgba(): NodeMaterialConnectionPoint;
  65893. /**
  65894. * Gets the rgb component (output)
  65895. */
  65896. get rgbOut(): NodeMaterialConnectionPoint;
  65897. /**
  65898. * Gets the rgb component (output)
  65899. * @deprecated Please use rgbOut instead.
  65900. */
  65901. get rgb(): NodeMaterialConnectionPoint;
  65902. protected _buildBlock(state: NodeMaterialBuildState): this;
  65903. }
  65904. }
  65905. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65906. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65907. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65908. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65909. /**
  65910. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65911. */
  65912. export class VectorSplitterBlock extends NodeMaterialBlock {
  65913. /**
  65914. * Create a new VectorSplitterBlock
  65915. * @param name defines the block name
  65916. */
  65917. constructor(name: string);
  65918. /**
  65919. * Gets the current class name
  65920. * @returns the class name
  65921. */
  65922. getClassName(): string;
  65923. /**
  65924. * Gets the xyzw component (input)
  65925. */
  65926. get xyzw(): NodeMaterialConnectionPoint;
  65927. /**
  65928. * Gets the xyz component (input)
  65929. */
  65930. get xyzIn(): NodeMaterialConnectionPoint;
  65931. /**
  65932. * Gets the xy component (input)
  65933. */
  65934. get xyIn(): NodeMaterialConnectionPoint;
  65935. /**
  65936. * Gets the xyz component (output)
  65937. */
  65938. get xyzOut(): NodeMaterialConnectionPoint;
  65939. /**
  65940. * Gets the xy component (output)
  65941. */
  65942. get xyOut(): NodeMaterialConnectionPoint;
  65943. /**
  65944. * Gets the x component (output)
  65945. */
  65946. get x(): NodeMaterialConnectionPoint;
  65947. /**
  65948. * Gets the y component (output)
  65949. */
  65950. get y(): NodeMaterialConnectionPoint;
  65951. /**
  65952. * Gets the z component (output)
  65953. */
  65954. get z(): NodeMaterialConnectionPoint;
  65955. /**
  65956. * Gets the w component (output)
  65957. */
  65958. get w(): NodeMaterialConnectionPoint;
  65959. protected _inputRename(name: string): string;
  65960. protected _outputRename(name: string): string;
  65961. protected _buildBlock(state: NodeMaterialBuildState): this;
  65962. }
  65963. }
  65964. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65968. /**
  65969. * Block used to lerp between 2 values
  65970. */
  65971. export class LerpBlock extends NodeMaterialBlock {
  65972. /**
  65973. * Creates a new LerpBlock
  65974. * @param name defines the block name
  65975. */
  65976. constructor(name: string);
  65977. /**
  65978. * Gets the current class name
  65979. * @returns the class name
  65980. */
  65981. getClassName(): string;
  65982. /**
  65983. * Gets the left operand input component
  65984. */
  65985. get left(): NodeMaterialConnectionPoint;
  65986. /**
  65987. * Gets the right operand input component
  65988. */
  65989. get right(): NodeMaterialConnectionPoint;
  65990. /**
  65991. * Gets the gradient operand input component
  65992. */
  65993. get gradient(): NodeMaterialConnectionPoint;
  65994. /**
  65995. * Gets the output component
  65996. */
  65997. get output(): NodeMaterialConnectionPoint;
  65998. protected _buildBlock(state: NodeMaterialBuildState): this;
  65999. }
  66000. }
  66001. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66005. /**
  66006. * Block used to divide 2 vectors
  66007. */
  66008. export class DivideBlock extends NodeMaterialBlock {
  66009. /**
  66010. * Creates a new DivideBlock
  66011. * @param name defines the block name
  66012. */
  66013. constructor(name: string);
  66014. /**
  66015. * Gets the current class name
  66016. * @returns the class name
  66017. */
  66018. getClassName(): string;
  66019. /**
  66020. * Gets the left operand input component
  66021. */
  66022. get left(): NodeMaterialConnectionPoint;
  66023. /**
  66024. * Gets the right operand input component
  66025. */
  66026. get right(): NodeMaterialConnectionPoint;
  66027. /**
  66028. * Gets the output component
  66029. */
  66030. get output(): NodeMaterialConnectionPoint;
  66031. protected _buildBlock(state: NodeMaterialBuildState): this;
  66032. }
  66033. }
  66034. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66038. /**
  66039. * Block used to subtract 2 vectors
  66040. */
  66041. export class SubtractBlock extends NodeMaterialBlock {
  66042. /**
  66043. * Creates a new SubtractBlock
  66044. * @param name defines the block name
  66045. */
  66046. constructor(name: string);
  66047. /**
  66048. * Gets the current class name
  66049. * @returns the class name
  66050. */
  66051. getClassName(): string;
  66052. /**
  66053. * Gets the left operand input component
  66054. */
  66055. get left(): NodeMaterialConnectionPoint;
  66056. /**
  66057. * Gets the right operand input component
  66058. */
  66059. get right(): NodeMaterialConnectionPoint;
  66060. /**
  66061. * Gets the output component
  66062. */
  66063. get output(): NodeMaterialConnectionPoint;
  66064. protected _buildBlock(state: NodeMaterialBuildState): this;
  66065. }
  66066. }
  66067. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66071. /**
  66072. * Block used to step a value
  66073. */
  66074. export class StepBlock extends NodeMaterialBlock {
  66075. /**
  66076. * Creates a new StepBlock
  66077. * @param name defines the block name
  66078. */
  66079. constructor(name: string);
  66080. /**
  66081. * Gets the current class name
  66082. * @returns the class name
  66083. */
  66084. getClassName(): string;
  66085. /**
  66086. * Gets the value operand input component
  66087. */
  66088. get value(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the edge operand input component
  66091. */
  66092. get edge(): NodeMaterialConnectionPoint;
  66093. /**
  66094. * Gets the output component
  66095. */
  66096. get output(): NodeMaterialConnectionPoint;
  66097. protected _buildBlock(state: NodeMaterialBuildState): this;
  66098. }
  66099. }
  66100. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66104. /**
  66105. * Block used to get the opposite (1 - x) of a value
  66106. */
  66107. export class OneMinusBlock extends NodeMaterialBlock {
  66108. /**
  66109. * Creates a new OneMinusBlock
  66110. * @param name defines the block name
  66111. */
  66112. constructor(name: string);
  66113. /**
  66114. * Gets the current class name
  66115. * @returns the class name
  66116. */
  66117. getClassName(): string;
  66118. /**
  66119. * Gets the input component
  66120. */
  66121. get input(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the output component
  66124. */
  66125. get output(): NodeMaterialConnectionPoint;
  66126. protected _buildBlock(state: NodeMaterialBuildState): this;
  66127. }
  66128. }
  66129. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66133. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66134. /**
  66135. * Block used to get the view direction
  66136. */
  66137. export class ViewDirectionBlock extends NodeMaterialBlock {
  66138. /**
  66139. * Creates a new ViewDirectionBlock
  66140. * @param name defines the block name
  66141. */
  66142. constructor(name: string);
  66143. /**
  66144. * Gets the current class name
  66145. * @returns the class name
  66146. */
  66147. getClassName(): string;
  66148. /**
  66149. * Gets the world position component
  66150. */
  66151. get worldPosition(): NodeMaterialConnectionPoint;
  66152. /**
  66153. * Gets the camera position component
  66154. */
  66155. get cameraPosition(): NodeMaterialConnectionPoint;
  66156. /**
  66157. * Gets the output component
  66158. */
  66159. get output(): NodeMaterialConnectionPoint;
  66160. autoConfigure(material: NodeMaterial): void;
  66161. protected _buildBlock(state: NodeMaterialBuildState): this;
  66162. }
  66163. }
  66164. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66168. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66169. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66170. /**
  66171. * Block used to compute fresnel value
  66172. */
  66173. export class FresnelBlock extends NodeMaterialBlock {
  66174. /**
  66175. * Create a new FresnelBlock
  66176. * @param name defines the block name
  66177. */
  66178. constructor(name: string);
  66179. /**
  66180. * Gets the current class name
  66181. * @returns the class name
  66182. */
  66183. getClassName(): string;
  66184. /**
  66185. * Gets the world normal input component
  66186. */
  66187. get worldNormal(): NodeMaterialConnectionPoint;
  66188. /**
  66189. * Gets the view direction input component
  66190. */
  66191. get viewDirection(): NodeMaterialConnectionPoint;
  66192. /**
  66193. * Gets the bias input component
  66194. */
  66195. get bias(): NodeMaterialConnectionPoint;
  66196. /**
  66197. * Gets the camera (or eye) position component
  66198. */
  66199. get power(): NodeMaterialConnectionPoint;
  66200. /**
  66201. * Gets the fresnel output component
  66202. */
  66203. get fresnel(): NodeMaterialConnectionPoint;
  66204. autoConfigure(material: NodeMaterial): void;
  66205. protected _buildBlock(state: NodeMaterialBuildState): this;
  66206. }
  66207. }
  66208. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66212. /**
  66213. * Block used to get the max of 2 values
  66214. */
  66215. export class MaxBlock extends NodeMaterialBlock {
  66216. /**
  66217. * Creates a new MaxBlock
  66218. * @param name defines the block name
  66219. */
  66220. constructor(name: string);
  66221. /**
  66222. * Gets the current class name
  66223. * @returns the class name
  66224. */
  66225. getClassName(): string;
  66226. /**
  66227. * Gets the left operand input component
  66228. */
  66229. get left(): NodeMaterialConnectionPoint;
  66230. /**
  66231. * Gets the right operand input component
  66232. */
  66233. get right(): NodeMaterialConnectionPoint;
  66234. /**
  66235. * Gets the output component
  66236. */
  66237. get output(): NodeMaterialConnectionPoint;
  66238. protected _buildBlock(state: NodeMaterialBuildState): this;
  66239. }
  66240. }
  66241. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66245. /**
  66246. * Block used to get the min of 2 values
  66247. */
  66248. export class MinBlock extends NodeMaterialBlock {
  66249. /**
  66250. * Creates a new MinBlock
  66251. * @param name defines the block name
  66252. */
  66253. constructor(name: string);
  66254. /**
  66255. * Gets the current class name
  66256. * @returns the class name
  66257. */
  66258. getClassName(): string;
  66259. /**
  66260. * Gets the left operand input component
  66261. */
  66262. get left(): NodeMaterialConnectionPoint;
  66263. /**
  66264. * Gets the right operand input component
  66265. */
  66266. get right(): NodeMaterialConnectionPoint;
  66267. /**
  66268. * Gets the output component
  66269. */
  66270. get output(): NodeMaterialConnectionPoint;
  66271. protected _buildBlock(state: NodeMaterialBuildState): this;
  66272. }
  66273. }
  66274. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66278. /**
  66279. * Block used to get the distance between 2 values
  66280. */
  66281. export class DistanceBlock extends NodeMaterialBlock {
  66282. /**
  66283. * Creates a new DistanceBlock
  66284. * @param name defines the block name
  66285. */
  66286. constructor(name: string);
  66287. /**
  66288. * Gets the current class name
  66289. * @returns the class name
  66290. */
  66291. getClassName(): string;
  66292. /**
  66293. * Gets the left operand input component
  66294. */
  66295. get left(): NodeMaterialConnectionPoint;
  66296. /**
  66297. * Gets the right operand input component
  66298. */
  66299. get right(): NodeMaterialConnectionPoint;
  66300. /**
  66301. * Gets the output component
  66302. */
  66303. get output(): NodeMaterialConnectionPoint;
  66304. protected _buildBlock(state: NodeMaterialBuildState): this;
  66305. }
  66306. }
  66307. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66311. /**
  66312. * Block used to get the length of a vector
  66313. */
  66314. export class LengthBlock extends NodeMaterialBlock {
  66315. /**
  66316. * Creates a new LengthBlock
  66317. * @param name defines the block name
  66318. */
  66319. constructor(name: string);
  66320. /**
  66321. * Gets the current class name
  66322. * @returns the class name
  66323. */
  66324. getClassName(): string;
  66325. /**
  66326. * Gets the value input component
  66327. */
  66328. get value(): NodeMaterialConnectionPoint;
  66329. /**
  66330. * Gets the output component
  66331. */
  66332. get output(): NodeMaterialConnectionPoint;
  66333. protected _buildBlock(state: NodeMaterialBuildState): this;
  66334. }
  66335. }
  66336. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66340. /**
  66341. * Block used to get negative version of a value (i.e. x * -1)
  66342. */
  66343. export class NegateBlock extends NodeMaterialBlock {
  66344. /**
  66345. * Creates a new NegateBlock
  66346. * @param name defines the block name
  66347. */
  66348. constructor(name: string);
  66349. /**
  66350. * Gets the current class name
  66351. * @returns the class name
  66352. */
  66353. getClassName(): string;
  66354. /**
  66355. * Gets the value input component
  66356. */
  66357. get value(): NodeMaterialConnectionPoint;
  66358. /**
  66359. * Gets the output component
  66360. */
  66361. get output(): NodeMaterialConnectionPoint;
  66362. protected _buildBlock(state: NodeMaterialBuildState): this;
  66363. }
  66364. }
  66365. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66369. /**
  66370. * Block used to get the value of the first parameter raised to the power of the second
  66371. */
  66372. export class PowBlock extends NodeMaterialBlock {
  66373. /**
  66374. * Creates a new PowBlock
  66375. * @param name defines the block name
  66376. */
  66377. constructor(name: string);
  66378. /**
  66379. * Gets the current class name
  66380. * @returns the class name
  66381. */
  66382. getClassName(): string;
  66383. /**
  66384. * Gets the value operand input component
  66385. */
  66386. get value(): NodeMaterialConnectionPoint;
  66387. /**
  66388. * Gets the power operand input component
  66389. */
  66390. get power(): NodeMaterialConnectionPoint;
  66391. /**
  66392. * Gets the output component
  66393. */
  66394. get output(): NodeMaterialConnectionPoint;
  66395. protected _buildBlock(state: NodeMaterialBuildState): this;
  66396. }
  66397. }
  66398. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66402. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66403. /**
  66404. * Block used to get a random number
  66405. */
  66406. export class RandomNumberBlock extends NodeMaterialBlock {
  66407. /**
  66408. * Creates a new RandomNumberBlock
  66409. * @param name defines the block name
  66410. */
  66411. constructor(name: string);
  66412. /**
  66413. * Gets the current class name
  66414. * @returns the class name
  66415. */
  66416. getClassName(): string;
  66417. /**
  66418. * Gets the seed input component
  66419. */
  66420. get seed(): NodeMaterialConnectionPoint;
  66421. /**
  66422. * Gets the output component
  66423. */
  66424. get output(): NodeMaterialConnectionPoint;
  66425. protected _buildBlock(state: NodeMaterialBuildState): this;
  66426. }
  66427. }
  66428. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66432. /**
  66433. * Block used to compute arc tangent of 2 values
  66434. */
  66435. export class ArcTan2Block extends NodeMaterialBlock {
  66436. /**
  66437. * Creates a new ArcTan2Block
  66438. * @param name defines the block name
  66439. */
  66440. constructor(name: string);
  66441. /**
  66442. * Gets the current class name
  66443. * @returns the class name
  66444. */
  66445. getClassName(): string;
  66446. /**
  66447. * Gets the x operand input component
  66448. */
  66449. get x(): NodeMaterialConnectionPoint;
  66450. /**
  66451. * Gets the y operand input component
  66452. */
  66453. get y(): NodeMaterialConnectionPoint;
  66454. /**
  66455. * Gets the output component
  66456. */
  66457. get output(): NodeMaterialConnectionPoint;
  66458. protected _buildBlock(state: NodeMaterialBuildState): this;
  66459. }
  66460. }
  66461. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66465. /**
  66466. * Block used to smooth step a value
  66467. */
  66468. export class SmoothStepBlock extends NodeMaterialBlock {
  66469. /**
  66470. * Creates a new SmoothStepBlock
  66471. * @param name defines the block name
  66472. */
  66473. constructor(name: string);
  66474. /**
  66475. * Gets the current class name
  66476. * @returns the class name
  66477. */
  66478. getClassName(): string;
  66479. /**
  66480. * Gets the value operand input component
  66481. */
  66482. get value(): NodeMaterialConnectionPoint;
  66483. /**
  66484. * Gets the first edge operand input component
  66485. */
  66486. get edge0(): NodeMaterialConnectionPoint;
  66487. /**
  66488. * Gets the second edge operand input component
  66489. */
  66490. get edge1(): NodeMaterialConnectionPoint;
  66491. /**
  66492. * Gets the output component
  66493. */
  66494. get output(): NodeMaterialConnectionPoint;
  66495. protected _buildBlock(state: NodeMaterialBuildState): this;
  66496. }
  66497. }
  66498. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66502. /**
  66503. * Block used to get the reciprocal (1 / x) of a value
  66504. */
  66505. export class ReciprocalBlock extends NodeMaterialBlock {
  66506. /**
  66507. * Creates a new ReciprocalBlock
  66508. * @param name defines the block name
  66509. */
  66510. constructor(name: string);
  66511. /**
  66512. * Gets the current class name
  66513. * @returns the class name
  66514. */
  66515. getClassName(): string;
  66516. /**
  66517. * Gets the input component
  66518. */
  66519. get input(): NodeMaterialConnectionPoint;
  66520. /**
  66521. * Gets the output component
  66522. */
  66523. get output(): NodeMaterialConnectionPoint;
  66524. protected _buildBlock(state: NodeMaterialBuildState): this;
  66525. }
  66526. }
  66527. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66531. /**
  66532. * Block used to replace a color by another one
  66533. */
  66534. export class ReplaceColorBlock extends NodeMaterialBlock {
  66535. /**
  66536. * Creates a new ReplaceColorBlock
  66537. * @param name defines the block name
  66538. */
  66539. constructor(name: string);
  66540. /**
  66541. * Gets the current class name
  66542. * @returns the class name
  66543. */
  66544. getClassName(): string;
  66545. /**
  66546. * Gets the value input component
  66547. */
  66548. get value(): NodeMaterialConnectionPoint;
  66549. /**
  66550. * Gets the reference input component
  66551. */
  66552. get reference(): NodeMaterialConnectionPoint;
  66553. /**
  66554. * Gets the distance input component
  66555. */
  66556. get distance(): NodeMaterialConnectionPoint;
  66557. /**
  66558. * Gets the replacement input component
  66559. */
  66560. get replacement(): NodeMaterialConnectionPoint;
  66561. /**
  66562. * Gets the output component
  66563. */
  66564. get output(): NodeMaterialConnectionPoint;
  66565. protected _buildBlock(state: NodeMaterialBuildState): this;
  66566. }
  66567. }
  66568. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66572. /**
  66573. * Block used to posterize a value
  66574. * @see https://en.wikipedia.org/wiki/Posterization
  66575. */
  66576. export class PosterizeBlock extends NodeMaterialBlock {
  66577. /**
  66578. * Creates a new PosterizeBlock
  66579. * @param name defines the block name
  66580. */
  66581. constructor(name: string);
  66582. /**
  66583. * Gets the current class name
  66584. * @returns the class name
  66585. */
  66586. getClassName(): string;
  66587. /**
  66588. * Gets the value input component
  66589. */
  66590. get value(): NodeMaterialConnectionPoint;
  66591. /**
  66592. * Gets the steps input component
  66593. */
  66594. get steps(): NodeMaterialConnectionPoint;
  66595. /**
  66596. * Gets the output component
  66597. */
  66598. get output(): NodeMaterialConnectionPoint;
  66599. protected _buildBlock(state: NodeMaterialBuildState): this;
  66600. }
  66601. }
  66602. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66606. import { Scene } from "babylonjs/scene";
  66607. /**
  66608. * Operations supported by the Wave block
  66609. */
  66610. export enum WaveBlockKind {
  66611. /** SawTooth */
  66612. SawTooth = 0,
  66613. /** Square */
  66614. Square = 1,
  66615. /** Triangle */
  66616. Triangle = 2
  66617. }
  66618. /**
  66619. * Block used to apply wave operation to floats
  66620. */
  66621. export class WaveBlock extends NodeMaterialBlock {
  66622. /**
  66623. * Gets or sets the kibnd of wave to be applied by the block
  66624. */
  66625. kind: WaveBlockKind;
  66626. /**
  66627. * Creates a new WaveBlock
  66628. * @param name defines the block name
  66629. */
  66630. constructor(name: string);
  66631. /**
  66632. * Gets the current class name
  66633. * @returns the class name
  66634. */
  66635. getClassName(): string;
  66636. /**
  66637. * Gets the input component
  66638. */
  66639. get input(): NodeMaterialConnectionPoint;
  66640. /**
  66641. * Gets the output component
  66642. */
  66643. get output(): NodeMaterialConnectionPoint;
  66644. protected _buildBlock(state: NodeMaterialBuildState): this;
  66645. serialize(): any;
  66646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66647. }
  66648. }
  66649. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66653. import { Color3 } from "babylonjs/Maths/math.color";
  66654. import { Scene } from "babylonjs/scene";
  66655. /**
  66656. * Class used to store a color step for the GradientBlock
  66657. */
  66658. export class GradientBlockColorStep {
  66659. /**
  66660. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66661. */
  66662. step: number;
  66663. /**
  66664. * Gets or sets the color associated with this step
  66665. */
  66666. color: Color3;
  66667. /**
  66668. * Creates a new GradientBlockColorStep
  66669. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66670. * @param color defines the color associated with this step
  66671. */
  66672. constructor(
  66673. /**
  66674. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66675. */
  66676. step: number,
  66677. /**
  66678. * Gets or sets the color associated with this step
  66679. */
  66680. color: Color3);
  66681. }
  66682. /**
  66683. * Block used to return a color from a gradient based on an input value between 0 and 1
  66684. */
  66685. export class GradientBlock extends NodeMaterialBlock {
  66686. /**
  66687. * Gets or sets the list of color steps
  66688. */
  66689. colorSteps: GradientBlockColorStep[];
  66690. /**
  66691. * Creates a new GradientBlock
  66692. * @param name defines the block name
  66693. */
  66694. constructor(name: string);
  66695. /**
  66696. * Gets the current class name
  66697. * @returns the class name
  66698. */
  66699. getClassName(): string;
  66700. /**
  66701. * Gets the gradient input component
  66702. */
  66703. get gradient(): NodeMaterialConnectionPoint;
  66704. /**
  66705. * Gets the output component
  66706. */
  66707. get output(): NodeMaterialConnectionPoint;
  66708. private _writeColorConstant;
  66709. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66710. serialize(): any;
  66711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66712. protected _dumpPropertiesCode(): string;
  66713. }
  66714. }
  66715. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66719. /**
  66720. * Block used to normalize lerp between 2 values
  66721. */
  66722. export class NLerpBlock extends NodeMaterialBlock {
  66723. /**
  66724. * Creates a new NLerpBlock
  66725. * @param name defines the block name
  66726. */
  66727. constructor(name: string);
  66728. /**
  66729. * Gets the current class name
  66730. * @returns the class name
  66731. */
  66732. getClassName(): string;
  66733. /**
  66734. * Gets the left operand input component
  66735. */
  66736. get left(): NodeMaterialConnectionPoint;
  66737. /**
  66738. * Gets the right operand input component
  66739. */
  66740. get right(): NodeMaterialConnectionPoint;
  66741. /**
  66742. * Gets the gradient operand input component
  66743. */
  66744. get gradient(): NodeMaterialConnectionPoint;
  66745. /**
  66746. * Gets the output component
  66747. */
  66748. get output(): NodeMaterialConnectionPoint;
  66749. protected _buildBlock(state: NodeMaterialBuildState): this;
  66750. }
  66751. }
  66752. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66756. import { Scene } from "babylonjs/scene";
  66757. /**
  66758. * block used to Generate a Worley Noise 3D Noise Pattern
  66759. */
  66760. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66761. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66762. manhattanDistance: boolean;
  66763. /**
  66764. * Creates a new WorleyNoise3DBlock
  66765. * @param name defines the block name
  66766. */
  66767. constructor(name: string);
  66768. /**
  66769. * Gets the current class name
  66770. * @returns the class name
  66771. */
  66772. getClassName(): string;
  66773. /**
  66774. * Gets the seed input component
  66775. */
  66776. get seed(): NodeMaterialConnectionPoint;
  66777. /**
  66778. * Gets the jitter input component
  66779. */
  66780. get jitter(): NodeMaterialConnectionPoint;
  66781. /**
  66782. * Gets the output component
  66783. */
  66784. get output(): NodeMaterialConnectionPoint;
  66785. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66786. /**
  66787. * Exposes the properties to the UI?
  66788. */
  66789. protected _dumpPropertiesCode(): string;
  66790. /**
  66791. * Exposes the properties to the Seralize?
  66792. */
  66793. serialize(): any;
  66794. /**
  66795. * Exposes the properties to the deseralize?
  66796. */
  66797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66798. }
  66799. }
  66800. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66804. /**
  66805. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66806. */
  66807. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66808. /**
  66809. * Creates a new SimplexPerlin3DBlock
  66810. * @param name defines the block name
  66811. */
  66812. constructor(name: string);
  66813. /**
  66814. * Gets the current class name
  66815. * @returns the class name
  66816. */
  66817. getClassName(): string;
  66818. /**
  66819. * Gets the seed operand input component
  66820. */
  66821. get seed(): NodeMaterialConnectionPoint;
  66822. /**
  66823. * Gets the output component
  66824. */
  66825. get output(): NodeMaterialConnectionPoint;
  66826. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66827. }
  66828. }
  66829. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66833. /**
  66834. * Block used to blend normals
  66835. */
  66836. export class NormalBlendBlock extends NodeMaterialBlock {
  66837. /**
  66838. * Creates a new NormalBlendBlock
  66839. * @param name defines the block name
  66840. */
  66841. constructor(name: string);
  66842. /**
  66843. * Gets the current class name
  66844. * @returns the class name
  66845. */
  66846. getClassName(): string;
  66847. /**
  66848. * Gets the first input component
  66849. */
  66850. get normalMap0(): NodeMaterialConnectionPoint;
  66851. /**
  66852. * Gets the second input component
  66853. */
  66854. get normalMap1(): NodeMaterialConnectionPoint;
  66855. /**
  66856. * Gets the output component
  66857. */
  66858. get output(): NodeMaterialConnectionPoint;
  66859. protected _buildBlock(state: NodeMaterialBuildState): this;
  66860. }
  66861. }
  66862. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66866. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66867. /**
  66868. * Block used to rotate a 2d vector by a given angle
  66869. */
  66870. export class Rotate2dBlock extends NodeMaterialBlock {
  66871. /**
  66872. * Creates a new Rotate2dBlock
  66873. * @param name defines the block name
  66874. */
  66875. constructor(name: string);
  66876. /**
  66877. * Gets the current class name
  66878. * @returns the class name
  66879. */
  66880. getClassName(): string;
  66881. /**
  66882. * Gets the input vector
  66883. */
  66884. get input(): NodeMaterialConnectionPoint;
  66885. /**
  66886. * Gets the input angle
  66887. */
  66888. get angle(): NodeMaterialConnectionPoint;
  66889. /**
  66890. * Gets the output component
  66891. */
  66892. get output(): NodeMaterialConnectionPoint;
  66893. autoConfigure(material: NodeMaterial): void;
  66894. protected _buildBlock(state: NodeMaterialBuildState): this;
  66895. }
  66896. }
  66897. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66901. /**
  66902. * Block used to get the reflected vector from a direction and a normal
  66903. */
  66904. export class ReflectBlock extends NodeMaterialBlock {
  66905. /**
  66906. * Creates a new ReflectBlock
  66907. * @param name defines the block name
  66908. */
  66909. constructor(name: string);
  66910. /**
  66911. * Gets the current class name
  66912. * @returns the class name
  66913. */
  66914. getClassName(): string;
  66915. /**
  66916. * Gets the incident component
  66917. */
  66918. get incident(): NodeMaterialConnectionPoint;
  66919. /**
  66920. * Gets the normal component
  66921. */
  66922. get normal(): NodeMaterialConnectionPoint;
  66923. /**
  66924. * Gets the output component
  66925. */
  66926. get output(): NodeMaterialConnectionPoint;
  66927. protected _buildBlock(state: NodeMaterialBuildState): this;
  66928. }
  66929. }
  66930. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66934. /**
  66935. * Block used to get the refracted vector from a direction and a normal
  66936. */
  66937. export class RefractBlock extends NodeMaterialBlock {
  66938. /**
  66939. * Creates a new RefractBlock
  66940. * @param name defines the block name
  66941. */
  66942. constructor(name: string);
  66943. /**
  66944. * Gets the current class name
  66945. * @returns the class name
  66946. */
  66947. getClassName(): string;
  66948. /**
  66949. * Gets the incident component
  66950. */
  66951. get incident(): NodeMaterialConnectionPoint;
  66952. /**
  66953. * Gets the normal component
  66954. */
  66955. get normal(): NodeMaterialConnectionPoint;
  66956. /**
  66957. * Gets the index of refraction component
  66958. */
  66959. get ior(): NodeMaterialConnectionPoint;
  66960. /**
  66961. * Gets the output component
  66962. */
  66963. get output(): NodeMaterialConnectionPoint;
  66964. protected _buildBlock(state: NodeMaterialBuildState): this;
  66965. }
  66966. }
  66967. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66971. /**
  66972. * Block used to desaturate a color
  66973. */
  66974. export class DesaturateBlock extends NodeMaterialBlock {
  66975. /**
  66976. * Creates a new DesaturateBlock
  66977. * @param name defines the block name
  66978. */
  66979. constructor(name: string);
  66980. /**
  66981. * Gets the current class name
  66982. * @returns the class name
  66983. */
  66984. getClassName(): string;
  66985. /**
  66986. * Gets the color operand input component
  66987. */
  66988. get color(): NodeMaterialConnectionPoint;
  66989. /**
  66990. * Gets the level operand input component
  66991. */
  66992. get level(): NodeMaterialConnectionPoint;
  66993. /**
  66994. * Gets the output component
  66995. */
  66996. get output(): NodeMaterialConnectionPoint;
  66997. protected _buildBlock(state: NodeMaterialBuildState): this;
  66998. }
  66999. }
  67000. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67004. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67005. import { Nullable } from "babylonjs/types";
  67006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67007. import { Scene } from "babylonjs/scene";
  67008. /**
  67009. * Block used to implement the ambient occlusion module of the PBR material
  67010. */
  67011. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67012. /**
  67013. * Create a new AmbientOcclusionBlock
  67014. * @param name defines the block name
  67015. */
  67016. constructor(name: string);
  67017. /**
  67018. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67019. */
  67020. useAmbientInGrayScale: boolean;
  67021. /**
  67022. * Initialize the block and prepare the context for build
  67023. * @param state defines the state that will be used for the build
  67024. */
  67025. initialize(state: NodeMaterialBuildState): void;
  67026. /**
  67027. * Gets the current class name
  67028. * @returns the class name
  67029. */
  67030. getClassName(): string;
  67031. /**
  67032. * Gets the texture input component
  67033. */
  67034. get texture(): NodeMaterialConnectionPoint;
  67035. /**
  67036. * Gets the texture intensity component
  67037. */
  67038. get intensity(): NodeMaterialConnectionPoint;
  67039. /**
  67040. * Gets the direct light intensity input component
  67041. */
  67042. get directLightIntensity(): NodeMaterialConnectionPoint;
  67043. /**
  67044. * Gets the ambient occlusion object output component
  67045. */
  67046. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67047. /**
  67048. * Gets the main code of the block (fragment side)
  67049. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67050. * @returns the shader code
  67051. */
  67052. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67054. protected _buildBlock(state: NodeMaterialBuildState): this;
  67055. protected _dumpPropertiesCode(): string;
  67056. serialize(): any;
  67057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67058. }
  67059. }
  67060. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67063. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67064. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67066. import { Nullable } from "babylonjs/types";
  67067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67068. import { Mesh } from "babylonjs/Meshes/mesh";
  67069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67070. import { Effect } from "babylonjs/Materials/effect";
  67071. import { Scene } from "babylonjs/scene";
  67072. /**
  67073. * Block used to implement the reflection module of the PBR material
  67074. */
  67075. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67076. /** @hidden */
  67077. _defineLODReflectionAlpha: string;
  67078. /** @hidden */
  67079. _defineLinearSpecularReflection: string;
  67080. private _vEnvironmentIrradianceName;
  67081. /** @hidden */
  67082. _vReflectionMicrosurfaceInfosName: string;
  67083. /** @hidden */
  67084. _vReflectionInfosName: string;
  67085. /** @hidden */
  67086. _vReflectionFilteringInfoName: string;
  67087. private _scene;
  67088. /**
  67089. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67090. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67091. * It's less burden on the user side in the editor part.
  67092. */
  67093. /** @hidden */
  67094. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67095. /** @hidden */
  67096. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67097. /** @hidden */
  67098. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67099. /**
  67100. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67101. * diffuse part of the IBL.
  67102. */
  67103. useSphericalHarmonics: boolean;
  67104. /**
  67105. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67106. */
  67107. forceIrradianceInFragment: boolean;
  67108. /**
  67109. * Create a new ReflectionBlock
  67110. * @param name defines the block name
  67111. */
  67112. constructor(name: string);
  67113. /**
  67114. * Gets the current class name
  67115. * @returns the class name
  67116. */
  67117. getClassName(): string;
  67118. /**
  67119. * Gets the position input component
  67120. */
  67121. get position(): NodeMaterialConnectionPoint;
  67122. /**
  67123. * Gets the world position input component
  67124. */
  67125. get worldPosition(): NodeMaterialConnectionPoint;
  67126. /**
  67127. * Gets the world normal input component
  67128. */
  67129. get worldNormal(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the world input component
  67132. */
  67133. get world(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the camera (or eye) position component
  67136. */
  67137. get cameraPosition(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the view input component
  67140. */
  67141. get view(): NodeMaterialConnectionPoint;
  67142. /**
  67143. * Gets the color input component
  67144. */
  67145. get color(): NodeMaterialConnectionPoint;
  67146. /**
  67147. * Gets the reflection object output component
  67148. */
  67149. get reflection(): NodeMaterialConnectionPoint;
  67150. /**
  67151. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67152. */
  67153. get hasTexture(): boolean;
  67154. /**
  67155. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67156. */
  67157. get reflectionColor(): string;
  67158. protected _getTexture(): Nullable<BaseTexture>;
  67159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67161. /**
  67162. * Gets the code to inject in the vertex shader
  67163. * @param state current state of the node material building
  67164. * @returns the shader code
  67165. */
  67166. handleVertexSide(state: NodeMaterialBuildState): string;
  67167. /**
  67168. * Gets the main code of the block (fragment side)
  67169. * @param state current state of the node material building
  67170. * @param normalVarName name of the existing variable corresponding to the normal
  67171. * @returns the shader code
  67172. */
  67173. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67174. protected _buildBlock(state: NodeMaterialBuildState): this;
  67175. protected _dumpPropertiesCode(): string;
  67176. serialize(): any;
  67177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67178. }
  67179. }
  67180. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67181. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67182. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67184. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67186. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67187. import { Scene } from "babylonjs/scene";
  67188. import { Nullable } from "babylonjs/types";
  67189. /**
  67190. * Block used to implement the sheen module of the PBR material
  67191. */
  67192. export class SheenBlock extends NodeMaterialBlock {
  67193. /**
  67194. * Create a new SheenBlock
  67195. * @param name defines the block name
  67196. */
  67197. constructor(name: string);
  67198. /**
  67199. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67200. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67201. * making it easier to setup and tweak the effect
  67202. */
  67203. albedoScaling: boolean;
  67204. /**
  67205. * Defines if the sheen is linked to the sheen color.
  67206. */
  67207. linkSheenWithAlbedo: boolean;
  67208. /**
  67209. * Initialize the block and prepare the context for build
  67210. * @param state defines the state that will be used for the build
  67211. */
  67212. initialize(state: NodeMaterialBuildState): void;
  67213. /**
  67214. * Gets the current class name
  67215. * @returns the class name
  67216. */
  67217. getClassName(): string;
  67218. /**
  67219. * Gets the intensity input component
  67220. */
  67221. get intensity(): NodeMaterialConnectionPoint;
  67222. /**
  67223. * Gets the color input component
  67224. */
  67225. get color(): NodeMaterialConnectionPoint;
  67226. /**
  67227. * Gets the roughness input component
  67228. */
  67229. get roughness(): NodeMaterialConnectionPoint;
  67230. /**
  67231. * Gets the sheen object output component
  67232. */
  67233. get sheen(): NodeMaterialConnectionPoint;
  67234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67235. /**
  67236. * Gets the main code of the block (fragment side)
  67237. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67238. * @returns the shader code
  67239. */
  67240. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67241. protected _buildBlock(state: NodeMaterialBuildState): this;
  67242. protected _dumpPropertiesCode(): string;
  67243. serialize(): any;
  67244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67245. }
  67246. }
  67247. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67248. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67249. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67250. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67253. import { Scene } from "babylonjs/scene";
  67254. import { Nullable } from "babylonjs/types";
  67255. import { Mesh } from "babylonjs/Meshes/mesh";
  67256. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67257. import { Effect } from "babylonjs/Materials/effect";
  67258. /**
  67259. * Block used to implement the reflectivity module of the PBR material
  67260. */
  67261. export class ReflectivityBlock extends NodeMaterialBlock {
  67262. private _metallicReflectanceColor;
  67263. private _metallicF0Factor;
  67264. /** @hidden */
  67265. _vMetallicReflectanceFactorsName: string;
  67266. /**
  67267. * The property below is set by the main PBR block prior to calling methods of this class.
  67268. */
  67269. /** @hidden */
  67270. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67271. /**
  67272. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67273. */
  67274. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67275. /**
  67276. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67277. */
  67278. useMetallnessFromMetallicTextureBlue: boolean;
  67279. /**
  67280. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67281. */
  67282. useRoughnessFromMetallicTextureAlpha: boolean;
  67283. /**
  67284. * Specifies if the metallic texture contains the roughness information in its green channel.
  67285. */
  67286. useRoughnessFromMetallicTextureGreen: boolean;
  67287. /**
  67288. * Create a new ReflectivityBlock
  67289. * @param name defines the block name
  67290. */
  67291. constructor(name: string);
  67292. /**
  67293. * Initialize the block and prepare the context for build
  67294. * @param state defines the state that will be used for the build
  67295. */
  67296. initialize(state: NodeMaterialBuildState): void;
  67297. /**
  67298. * Gets the current class name
  67299. * @returns the class name
  67300. */
  67301. getClassName(): string;
  67302. /**
  67303. * Gets the metallic input component
  67304. */
  67305. get metallic(): NodeMaterialConnectionPoint;
  67306. /**
  67307. * Gets the roughness input component
  67308. */
  67309. get roughness(): NodeMaterialConnectionPoint;
  67310. /**
  67311. * Gets the texture input component
  67312. */
  67313. get texture(): NodeMaterialConnectionPoint;
  67314. /**
  67315. * Gets the reflectivity object output component
  67316. */
  67317. get reflectivity(): NodeMaterialConnectionPoint;
  67318. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67319. /**
  67320. * Gets the main code of the block (fragment side)
  67321. * @param state current state of the node material building
  67322. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67323. * @returns the shader code
  67324. */
  67325. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67327. protected _buildBlock(state: NodeMaterialBuildState): this;
  67328. protected _dumpPropertiesCode(): string;
  67329. serialize(): any;
  67330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67331. }
  67332. }
  67333. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67334. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67339. /**
  67340. * Block used to implement the anisotropy module of the PBR material
  67341. */
  67342. export class AnisotropyBlock extends NodeMaterialBlock {
  67343. /**
  67344. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67345. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67346. * It's less burden on the user side in the editor part.
  67347. */
  67348. /** @hidden */
  67349. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67350. /** @hidden */
  67351. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67352. /**
  67353. * Create a new AnisotropyBlock
  67354. * @param name defines the block name
  67355. */
  67356. constructor(name: string);
  67357. /**
  67358. * Initialize the block and prepare the context for build
  67359. * @param state defines the state that will be used for the build
  67360. */
  67361. initialize(state: NodeMaterialBuildState): void;
  67362. /**
  67363. * Gets the current class name
  67364. * @returns the class name
  67365. */
  67366. getClassName(): string;
  67367. /**
  67368. * Gets the intensity input component
  67369. */
  67370. get intensity(): NodeMaterialConnectionPoint;
  67371. /**
  67372. * Gets the direction input component
  67373. */
  67374. get direction(): NodeMaterialConnectionPoint;
  67375. /**
  67376. * Gets the texture input component
  67377. */
  67378. get texture(): NodeMaterialConnectionPoint;
  67379. /**
  67380. * Gets the uv input component
  67381. */
  67382. get uv(): NodeMaterialConnectionPoint;
  67383. /**
  67384. * Gets the worldTangent input component
  67385. */
  67386. get worldTangent(): NodeMaterialConnectionPoint;
  67387. /**
  67388. * Gets the anisotropy object output component
  67389. */
  67390. get anisotropy(): NodeMaterialConnectionPoint;
  67391. private _generateTBNSpace;
  67392. /**
  67393. * Gets the main code of the block (fragment side)
  67394. * @param state current state of the node material building
  67395. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67396. * @returns the shader code
  67397. */
  67398. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67399. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67400. protected _buildBlock(state: NodeMaterialBuildState): this;
  67401. }
  67402. }
  67403. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67407. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67409. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67410. import { Nullable } from "babylonjs/types";
  67411. import { Mesh } from "babylonjs/Meshes/mesh";
  67412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67413. import { Effect } from "babylonjs/Materials/effect";
  67414. /**
  67415. * Block used to implement the clear coat module of the PBR material
  67416. */
  67417. export class ClearCoatBlock extends NodeMaterialBlock {
  67418. private _scene;
  67419. /**
  67420. * Create a new ClearCoatBlock
  67421. * @param name defines the block name
  67422. */
  67423. constructor(name: string);
  67424. /**
  67425. * Initialize the block and prepare the context for build
  67426. * @param state defines the state that will be used for the build
  67427. */
  67428. initialize(state: NodeMaterialBuildState): void;
  67429. /**
  67430. * Gets the current class name
  67431. * @returns the class name
  67432. */
  67433. getClassName(): string;
  67434. /**
  67435. * Gets the intensity input component
  67436. */
  67437. get intensity(): NodeMaterialConnectionPoint;
  67438. /**
  67439. * Gets the roughness input component
  67440. */
  67441. get roughness(): NodeMaterialConnectionPoint;
  67442. /**
  67443. * Gets the ior input component
  67444. */
  67445. get ior(): NodeMaterialConnectionPoint;
  67446. /**
  67447. * Gets the texture input component
  67448. */
  67449. get texture(): NodeMaterialConnectionPoint;
  67450. /**
  67451. * Gets the bump texture input component
  67452. */
  67453. get bumpTexture(): NodeMaterialConnectionPoint;
  67454. /**
  67455. * Gets the uv input component
  67456. */
  67457. get uv(): NodeMaterialConnectionPoint;
  67458. /**
  67459. * Gets the tint color input component
  67460. */
  67461. get tintColor(): NodeMaterialConnectionPoint;
  67462. /**
  67463. * Gets the tint "at distance" input component
  67464. */
  67465. get tintAtDistance(): NodeMaterialConnectionPoint;
  67466. /**
  67467. * Gets the tint thickness input component
  67468. */
  67469. get tintThickness(): NodeMaterialConnectionPoint;
  67470. /**
  67471. * Gets the world tangent input component
  67472. */
  67473. get worldTangent(): NodeMaterialConnectionPoint;
  67474. /**
  67475. * Gets the clear coat object output component
  67476. */
  67477. get clearcoat(): NodeMaterialConnectionPoint;
  67478. autoConfigure(material: NodeMaterial): void;
  67479. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67480. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67481. private _generateTBNSpace;
  67482. /**
  67483. * Gets the main code of the block (fragment side)
  67484. * @param state current state of the node material building
  67485. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67486. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67487. * @param worldPosVarName name of the variable holding the world position
  67488. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67489. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67490. * @param worldNormalVarName name of the variable holding the world normal
  67491. * @returns the shader code
  67492. */
  67493. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67494. protected _buildBlock(state: NodeMaterialBuildState): this;
  67495. }
  67496. }
  67497. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67501. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67503. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67504. import { Nullable } from "babylonjs/types";
  67505. /**
  67506. * Block used to implement the sub surface module of the PBR material
  67507. */
  67508. export class SubSurfaceBlock extends NodeMaterialBlock {
  67509. /**
  67510. * Create a new SubSurfaceBlock
  67511. * @param name defines the block name
  67512. */
  67513. constructor(name: string);
  67514. /**
  67515. * Stores the intensity of the different subsurface effects in the thickness texture.
  67516. * * the green channel is the translucency intensity.
  67517. * * the blue channel is the scattering intensity.
  67518. * * the alpha channel is the refraction intensity.
  67519. */
  67520. useMaskFromThicknessTexture: boolean;
  67521. /**
  67522. * Initialize the block and prepare the context for build
  67523. * @param state defines the state that will be used for the build
  67524. */
  67525. initialize(state: NodeMaterialBuildState): void;
  67526. /**
  67527. * Gets the current class name
  67528. * @returns the class name
  67529. */
  67530. getClassName(): string;
  67531. /**
  67532. * Gets the min thickness input component
  67533. */
  67534. get minThickness(): NodeMaterialConnectionPoint;
  67535. /**
  67536. * Gets the max thickness input component
  67537. */
  67538. get maxThickness(): NodeMaterialConnectionPoint;
  67539. /**
  67540. * Gets the thickness texture component
  67541. */
  67542. get thicknessTexture(): NodeMaterialConnectionPoint;
  67543. /**
  67544. * Gets the tint color input component
  67545. */
  67546. get tintColor(): NodeMaterialConnectionPoint;
  67547. /**
  67548. * Gets the translucency intensity input component
  67549. */
  67550. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67551. /**
  67552. * Gets the translucency diffusion distance input component
  67553. */
  67554. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67555. /**
  67556. * Gets the refraction object parameters
  67557. */
  67558. get refraction(): NodeMaterialConnectionPoint;
  67559. /**
  67560. * Gets the sub surface object output component
  67561. */
  67562. get subsurface(): NodeMaterialConnectionPoint;
  67563. autoConfigure(material: NodeMaterial): void;
  67564. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67565. /**
  67566. * Gets the main code of the block (fragment side)
  67567. * @param state current state of the node material building
  67568. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67569. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67570. * @param worldPosVarName name of the variable holding the world position
  67571. * @returns the shader code
  67572. */
  67573. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67574. protected _buildBlock(state: NodeMaterialBuildState): this;
  67575. }
  67576. }
  67577. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67581. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67582. import { Light } from "babylonjs/Lights/light";
  67583. import { Nullable } from "babylonjs/types";
  67584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67585. import { Effect } from "babylonjs/Materials/effect";
  67586. import { Mesh } from "babylonjs/Meshes/mesh";
  67587. import { Scene } from "babylonjs/scene";
  67588. /**
  67589. * Block used to implement the PBR metallic/roughness model
  67590. */
  67591. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67592. /**
  67593. * Gets or sets the light associated with this block
  67594. */
  67595. light: Nullable<Light>;
  67596. private _lightId;
  67597. private _scene;
  67598. private _environmentBRDFTexture;
  67599. private _environmentBrdfSamplerName;
  67600. private _vNormalWName;
  67601. private _invertNormalName;
  67602. /**
  67603. * Create a new ReflectionBlock
  67604. * @param name defines the block name
  67605. */
  67606. constructor(name: string);
  67607. /**
  67608. * Intensity of the direct lights e.g. the four lights available in your scene.
  67609. * This impacts both the direct diffuse and specular highlights.
  67610. */
  67611. directIntensity: number;
  67612. /**
  67613. * Intensity of the environment e.g. how much the environment will light the object
  67614. * either through harmonics for rough material or through the refelction for shiny ones.
  67615. */
  67616. environmentIntensity: number;
  67617. /**
  67618. * This is a special control allowing the reduction of the specular highlights coming from the
  67619. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67620. */
  67621. specularIntensity: number;
  67622. /**
  67623. * Defines the falloff type used in this material.
  67624. * It by default is Physical.
  67625. */
  67626. lightFalloff: number;
  67627. /**
  67628. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67629. */
  67630. useAlphaFromAlbedoTexture: boolean;
  67631. /**
  67632. * Specifies that alpha test should be used
  67633. */
  67634. useAlphaTest: boolean;
  67635. /**
  67636. * Defines the alpha limits in alpha test mode.
  67637. */
  67638. alphaTestCutoff: number;
  67639. /**
  67640. * Specifies that alpha blending should be used
  67641. */
  67642. useAlphaBlending: boolean;
  67643. /**
  67644. * Defines if the alpha value should be determined via the rgb values.
  67645. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67646. */
  67647. opacityRGB: boolean;
  67648. /**
  67649. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67650. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67651. */
  67652. useRadianceOverAlpha: boolean;
  67653. /**
  67654. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67655. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67656. */
  67657. useSpecularOverAlpha: boolean;
  67658. /**
  67659. * Enables specular anti aliasing in the PBR shader.
  67660. * It will both interacts on the Geometry for analytical and IBL lighting.
  67661. * It also prefilter the roughness map based on the bump values.
  67662. */
  67663. enableSpecularAntiAliasing: boolean;
  67664. /**
  67665. * Enables realtime filtering on the texture.
  67666. */
  67667. realTimeFiltering: boolean;
  67668. /**
  67669. * Quality switch for realtime filtering
  67670. */
  67671. realTimeFilteringQuality: number;
  67672. /**
  67673. * Defines if the material uses energy conservation.
  67674. */
  67675. useEnergyConservation: boolean;
  67676. /**
  67677. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67678. * too much the area relying on ambient texture to define their ambient occlusion.
  67679. */
  67680. useRadianceOcclusion: boolean;
  67681. /**
  67682. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67683. * makes the reflect vector face the model (under horizon).
  67684. */
  67685. useHorizonOcclusion: boolean;
  67686. /**
  67687. * If set to true, no lighting calculations will be applied.
  67688. */
  67689. unlit: boolean;
  67690. /**
  67691. * Force normal to face away from face.
  67692. */
  67693. forceNormalForward: boolean;
  67694. /**
  67695. * Defines the material debug mode.
  67696. * It helps seeing only some components of the material while troubleshooting.
  67697. */
  67698. debugMode: number;
  67699. /**
  67700. * Specify from where on screen the debug mode should start.
  67701. * The value goes from -1 (full screen) to 1 (not visible)
  67702. * It helps with side by side comparison against the final render
  67703. * This defaults to 0
  67704. */
  67705. debugLimit: number;
  67706. /**
  67707. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67708. * You can use the factor to better multiply the final value.
  67709. */
  67710. debugFactor: number;
  67711. /**
  67712. * Initialize the block and prepare the context for build
  67713. * @param state defines the state that will be used for the build
  67714. */
  67715. initialize(state: NodeMaterialBuildState): void;
  67716. /**
  67717. * Gets the current class name
  67718. * @returns the class name
  67719. */
  67720. getClassName(): string;
  67721. /**
  67722. * Gets the world position input component
  67723. */
  67724. get worldPosition(): NodeMaterialConnectionPoint;
  67725. /**
  67726. * Gets the world normal input component
  67727. */
  67728. get worldNormal(): NodeMaterialConnectionPoint;
  67729. /**
  67730. * Gets the perturbed normal input component
  67731. */
  67732. get perturbedNormal(): NodeMaterialConnectionPoint;
  67733. /**
  67734. * Gets the camera position input component
  67735. */
  67736. get cameraPosition(): NodeMaterialConnectionPoint;
  67737. /**
  67738. * Gets the base color input component
  67739. */
  67740. get baseColor(): NodeMaterialConnectionPoint;
  67741. /**
  67742. * Gets the opacity texture input component
  67743. */
  67744. get opacityTexture(): NodeMaterialConnectionPoint;
  67745. /**
  67746. * Gets the ambient color input component
  67747. */
  67748. get ambientColor(): NodeMaterialConnectionPoint;
  67749. /**
  67750. * Gets the reflectivity object parameters
  67751. */
  67752. get reflectivity(): NodeMaterialConnectionPoint;
  67753. /**
  67754. * Gets the ambient occlusion object parameters
  67755. */
  67756. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67757. /**
  67758. * Gets the reflection object parameters
  67759. */
  67760. get reflection(): NodeMaterialConnectionPoint;
  67761. /**
  67762. * Gets the sheen object parameters
  67763. */
  67764. get sheen(): NodeMaterialConnectionPoint;
  67765. /**
  67766. * Gets the clear coat object parameters
  67767. */
  67768. get clearcoat(): NodeMaterialConnectionPoint;
  67769. /**
  67770. * Gets the sub surface object parameters
  67771. */
  67772. get subsurface(): NodeMaterialConnectionPoint;
  67773. /**
  67774. * Gets the anisotropy object parameters
  67775. */
  67776. get anisotropy(): NodeMaterialConnectionPoint;
  67777. /**
  67778. * Gets the ambient output component
  67779. */
  67780. get ambient(): NodeMaterialConnectionPoint;
  67781. /**
  67782. * Gets the diffuse output component
  67783. */
  67784. get diffuse(): NodeMaterialConnectionPoint;
  67785. /**
  67786. * Gets the specular output component
  67787. */
  67788. get specular(): NodeMaterialConnectionPoint;
  67789. /**
  67790. * Gets the sheen output component
  67791. */
  67792. get sheenDir(): NodeMaterialConnectionPoint;
  67793. /**
  67794. * Gets the clear coat output component
  67795. */
  67796. get clearcoatDir(): NodeMaterialConnectionPoint;
  67797. /**
  67798. * Gets the indirect diffuse output component
  67799. */
  67800. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67801. /**
  67802. * Gets the indirect specular output component
  67803. */
  67804. get specularIndirect(): NodeMaterialConnectionPoint;
  67805. /**
  67806. * Gets the indirect sheen output component
  67807. */
  67808. get sheenIndirect(): NodeMaterialConnectionPoint;
  67809. /**
  67810. * Gets the indirect clear coat output component
  67811. */
  67812. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67813. /**
  67814. * Gets the refraction output component
  67815. */
  67816. get refraction(): NodeMaterialConnectionPoint;
  67817. /**
  67818. * Gets the global lighting output component
  67819. */
  67820. get lighting(): NodeMaterialConnectionPoint;
  67821. /**
  67822. * Gets the shadow output component
  67823. */
  67824. get shadow(): NodeMaterialConnectionPoint;
  67825. /**
  67826. * Gets the alpha output component
  67827. */
  67828. get alpha(): NodeMaterialConnectionPoint;
  67829. autoConfigure(material: NodeMaterial): void;
  67830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67831. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67832. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67833. private _injectVertexCode;
  67834. /**
  67835. * Gets the code corresponding to the albedo/opacity module
  67836. * @returns the shader code
  67837. */
  67838. getAlbedoOpacityCode(): string;
  67839. protected _buildBlock(state: NodeMaterialBuildState): this;
  67840. protected _dumpPropertiesCode(): string;
  67841. serialize(): any;
  67842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67843. }
  67844. }
  67845. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67846. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67847. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67848. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67849. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67850. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67851. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67852. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67853. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67854. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67855. }
  67856. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67857. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67858. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67859. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67860. }
  67861. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67862. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67863. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67864. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67865. /**
  67866. * Block used to compute value of one parameter modulo another
  67867. */
  67868. export class ModBlock extends NodeMaterialBlock {
  67869. /**
  67870. * Creates a new ModBlock
  67871. * @param name defines the block name
  67872. */
  67873. constructor(name: string);
  67874. /**
  67875. * Gets the current class name
  67876. * @returns the class name
  67877. */
  67878. getClassName(): string;
  67879. /**
  67880. * Gets the left operand input component
  67881. */
  67882. get left(): NodeMaterialConnectionPoint;
  67883. /**
  67884. * Gets the right operand input component
  67885. */
  67886. get right(): NodeMaterialConnectionPoint;
  67887. /**
  67888. * Gets the output component
  67889. */
  67890. get output(): NodeMaterialConnectionPoint;
  67891. protected _buildBlock(state: NodeMaterialBuildState): this;
  67892. }
  67893. }
  67894. declare module "babylonjs/Materials/Node/Blocks/index" {
  67895. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67896. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67897. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67898. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67899. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67900. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67901. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67902. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67903. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67904. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67905. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67906. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67907. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67908. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67909. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67910. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67911. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67912. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67913. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67914. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67915. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67916. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67917. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67918. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67919. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67920. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67921. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67922. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67923. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67924. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67925. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67926. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67927. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67928. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67929. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67930. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67931. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67932. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67933. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67934. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67935. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67936. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67937. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67938. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67939. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67940. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67941. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67942. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67943. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67944. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67945. }
  67946. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67947. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67948. }
  67949. declare module "babylonjs/Materials/Node/index" {
  67950. export * from "babylonjs/Materials/Node/Enums/index";
  67951. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67952. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67953. export * from "babylonjs/Materials/Node/nodeMaterial";
  67954. export * from "babylonjs/Materials/Node/Blocks/index";
  67955. export * from "babylonjs/Materials/Node/Optimizers/index";
  67956. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67957. }
  67958. declare module "babylonjs/Materials/index" {
  67959. export * from "babylonjs/Materials/Background/index";
  67960. export * from "babylonjs/Materials/colorCurves";
  67961. export * from "babylonjs/Materials/iEffectFallbacks";
  67962. export * from "babylonjs/Materials/effectFallbacks";
  67963. export * from "babylonjs/Materials/effect";
  67964. export * from "babylonjs/Materials/fresnelParameters";
  67965. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67966. export * from "babylonjs/Materials/material";
  67967. export * from "babylonjs/Materials/materialDefines";
  67968. export * from "babylonjs/Materials/materialHelper";
  67969. export * from "babylonjs/Materials/multiMaterial";
  67970. export * from "babylonjs/Materials/PBR/index";
  67971. export * from "babylonjs/Materials/pushMaterial";
  67972. export * from "babylonjs/Materials/shaderMaterial";
  67973. export * from "babylonjs/Materials/standardMaterial";
  67974. export * from "babylonjs/Materials/Textures/index";
  67975. export * from "babylonjs/Materials/uniformBuffer";
  67976. export * from "babylonjs/Materials/materialFlags";
  67977. export * from "babylonjs/Materials/Node/index";
  67978. export * from "babylonjs/Materials/effectRenderer";
  67979. export * from "babylonjs/Materials/shadowDepthWrapper";
  67980. }
  67981. declare module "babylonjs/Maths/index" {
  67982. export * from "babylonjs/Maths/math.scalar";
  67983. export * from "babylonjs/Maths/math";
  67984. export * from "babylonjs/Maths/sphericalPolynomial";
  67985. }
  67986. declare module "babylonjs/Misc/workerPool" {
  67987. import { IDisposable } from "babylonjs/scene";
  67988. /**
  67989. * Helper class to push actions to a pool of workers.
  67990. */
  67991. export class WorkerPool implements IDisposable {
  67992. private _workerInfos;
  67993. private _pendingActions;
  67994. /**
  67995. * Constructor
  67996. * @param workers Array of workers to use for actions
  67997. */
  67998. constructor(workers: Array<Worker>);
  67999. /**
  68000. * Terminates all workers and clears any pending actions.
  68001. */
  68002. dispose(): void;
  68003. /**
  68004. * Pushes an action to the worker pool. If all the workers are active, the action will be
  68005. * pended until a worker has completed its action.
  68006. * @param action The action to perform. Call onComplete when the action is complete.
  68007. */
  68008. push(action: (worker: Worker, onComplete: () => void) => void): void;
  68009. private _execute;
  68010. }
  68011. }
  68012. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68013. import { IDisposable } from "babylonjs/scene";
  68014. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68015. /**
  68016. * Configuration for Draco compression
  68017. */
  68018. export interface IDracoCompressionConfiguration {
  68019. /**
  68020. * Configuration for the decoder.
  68021. */
  68022. decoder: {
  68023. /**
  68024. * The url to the WebAssembly module.
  68025. */
  68026. wasmUrl?: string;
  68027. /**
  68028. * The url to the WebAssembly binary.
  68029. */
  68030. wasmBinaryUrl?: string;
  68031. /**
  68032. * The url to the fallback JavaScript module.
  68033. */
  68034. fallbackUrl?: string;
  68035. };
  68036. }
  68037. /**
  68038. * Draco compression (https://google.github.io/draco/)
  68039. *
  68040. * This class wraps the Draco module.
  68041. *
  68042. * **Encoder**
  68043. *
  68044. * The encoder is not currently implemented.
  68045. *
  68046. * **Decoder**
  68047. *
  68048. * 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.
  68049. *
  68050. * To update the configuration, use the following code:
  68051. * ```javascript
  68052. * DracoCompression.Configuration = {
  68053. * decoder: {
  68054. * wasmUrl: "<url to the WebAssembly library>",
  68055. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68056. * fallbackUrl: "<url to the fallback JavaScript library>",
  68057. * }
  68058. * };
  68059. * ```
  68060. *
  68061. * 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.
  68062. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68063. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68064. *
  68065. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68066. * ```javascript
  68067. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68068. * ```
  68069. *
  68070. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68071. */
  68072. export class DracoCompression implements IDisposable {
  68073. private _workerPoolPromise?;
  68074. private _decoderModulePromise?;
  68075. /**
  68076. * The configuration. Defaults to the following urls:
  68077. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68078. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68079. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68080. */
  68081. static Configuration: IDracoCompressionConfiguration;
  68082. /**
  68083. * Returns true if the decoder configuration is available.
  68084. */
  68085. static get DecoderAvailable(): boolean;
  68086. /**
  68087. * Default number of workers to create when creating the draco compression object.
  68088. */
  68089. static DefaultNumWorkers: number;
  68090. private static GetDefaultNumWorkers;
  68091. private static _Default;
  68092. /**
  68093. * Default instance for the draco compression object.
  68094. */
  68095. static get Default(): DracoCompression;
  68096. /**
  68097. * Constructor
  68098. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68099. */
  68100. constructor(numWorkers?: number);
  68101. /**
  68102. * Stop all async operations and release resources.
  68103. */
  68104. dispose(): void;
  68105. /**
  68106. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68107. * @returns a promise that resolves when ready
  68108. */
  68109. whenReadyAsync(): Promise<void>;
  68110. /**
  68111. * Decode Draco compressed mesh data to vertex data.
  68112. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68113. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68114. * @returns A promise that resolves with the decoded vertex data
  68115. */
  68116. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68117. [kind: string]: number;
  68118. }): Promise<VertexData>;
  68119. }
  68120. }
  68121. declare module "babylonjs/Meshes/Compression/index" {
  68122. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68123. }
  68124. declare module "babylonjs/Meshes/csg" {
  68125. import { Nullable } from "babylonjs/types";
  68126. import { Scene } from "babylonjs/scene";
  68127. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68128. import { Mesh } from "babylonjs/Meshes/mesh";
  68129. import { Material } from "babylonjs/Materials/material";
  68130. /**
  68131. * Class for building Constructive Solid Geometry
  68132. */
  68133. export class CSG {
  68134. private polygons;
  68135. /**
  68136. * The world matrix
  68137. */
  68138. matrix: Matrix;
  68139. /**
  68140. * Stores the position
  68141. */
  68142. position: Vector3;
  68143. /**
  68144. * Stores the rotation
  68145. */
  68146. rotation: Vector3;
  68147. /**
  68148. * Stores the rotation quaternion
  68149. */
  68150. rotationQuaternion: Nullable<Quaternion>;
  68151. /**
  68152. * Stores the scaling vector
  68153. */
  68154. scaling: Vector3;
  68155. /**
  68156. * Convert the Mesh to CSG
  68157. * @param mesh The Mesh to convert to CSG
  68158. * @returns A new CSG from the Mesh
  68159. */
  68160. static FromMesh(mesh: Mesh): CSG;
  68161. /**
  68162. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68163. * @param polygons Polygons used to construct a CSG solid
  68164. */
  68165. private static FromPolygons;
  68166. /**
  68167. * Clones, or makes a deep copy, of the CSG
  68168. * @returns A new CSG
  68169. */
  68170. clone(): CSG;
  68171. /**
  68172. * Unions this CSG with another CSG
  68173. * @param csg The CSG to union against this CSG
  68174. * @returns The unioned CSG
  68175. */
  68176. union(csg: CSG): CSG;
  68177. /**
  68178. * Unions this CSG with another CSG in place
  68179. * @param csg The CSG to union against this CSG
  68180. */
  68181. unionInPlace(csg: CSG): void;
  68182. /**
  68183. * Subtracts this CSG with another CSG
  68184. * @param csg The CSG to subtract against this CSG
  68185. * @returns A new CSG
  68186. */
  68187. subtract(csg: CSG): CSG;
  68188. /**
  68189. * Subtracts this CSG with another CSG in place
  68190. * @param csg The CSG to subtact against this CSG
  68191. */
  68192. subtractInPlace(csg: CSG): void;
  68193. /**
  68194. * Intersect this CSG with another CSG
  68195. * @param csg The CSG to intersect against this CSG
  68196. * @returns A new CSG
  68197. */
  68198. intersect(csg: CSG): CSG;
  68199. /**
  68200. * Intersects this CSG with another CSG in place
  68201. * @param csg The CSG to intersect against this CSG
  68202. */
  68203. intersectInPlace(csg: CSG): void;
  68204. /**
  68205. * Return a new CSG solid with solid and empty space switched. This solid is
  68206. * not modified.
  68207. * @returns A new CSG solid with solid and empty space switched
  68208. */
  68209. inverse(): CSG;
  68210. /**
  68211. * Inverses the CSG in place
  68212. */
  68213. inverseInPlace(): void;
  68214. /**
  68215. * This is used to keep meshes transformations so they can be restored
  68216. * when we build back a Babylon Mesh
  68217. * NB : All CSG operations are performed in world coordinates
  68218. * @param csg The CSG to copy the transform attributes from
  68219. * @returns This CSG
  68220. */
  68221. copyTransformAttributes(csg: CSG): CSG;
  68222. /**
  68223. * Build Raw mesh from CSG
  68224. * Coordinates here are in world space
  68225. * @param name The name of the mesh geometry
  68226. * @param scene The Scene
  68227. * @param keepSubMeshes Specifies if the submeshes should be kept
  68228. * @returns A new Mesh
  68229. */
  68230. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68231. /**
  68232. * Build Mesh from CSG taking material and transforms into account
  68233. * @param name The name of the Mesh
  68234. * @param material The material of the Mesh
  68235. * @param scene The Scene
  68236. * @param keepSubMeshes Specifies if submeshes should be kept
  68237. * @returns The new Mesh
  68238. */
  68239. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68240. }
  68241. }
  68242. declare module "babylonjs/Meshes/trailMesh" {
  68243. import { Mesh } from "babylonjs/Meshes/mesh";
  68244. import { Scene } from "babylonjs/scene";
  68245. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68246. /**
  68247. * Class used to create a trail following a mesh
  68248. */
  68249. export class TrailMesh extends Mesh {
  68250. private _generator;
  68251. private _autoStart;
  68252. private _running;
  68253. private _diameter;
  68254. private _length;
  68255. private _sectionPolygonPointsCount;
  68256. private _sectionVectors;
  68257. private _sectionNormalVectors;
  68258. private _beforeRenderObserver;
  68259. /**
  68260. * @constructor
  68261. * @param name The value used by scene.getMeshByName() to do a lookup.
  68262. * @param generator The mesh or transform node to generate a trail.
  68263. * @param scene The scene to add this mesh to.
  68264. * @param diameter Diameter of trailing mesh. Default is 1.
  68265. * @param length Length of trailing mesh. Default is 60.
  68266. * @param autoStart Automatically start trailing mesh. Default true.
  68267. */
  68268. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68269. /**
  68270. * "TrailMesh"
  68271. * @returns "TrailMesh"
  68272. */
  68273. getClassName(): string;
  68274. private _createMesh;
  68275. /**
  68276. * Start trailing mesh.
  68277. */
  68278. start(): void;
  68279. /**
  68280. * Stop trailing mesh.
  68281. */
  68282. stop(): void;
  68283. /**
  68284. * Update trailing mesh geometry.
  68285. */
  68286. update(): void;
  68287. /**
  68288. * Returns a new TrailMesh object.
  68289. * @param name is a string, the name given to the new mesh
  68290. * @param newGenerator use new generator object for cloned trail mesh
  68291. * @returns a new mesh
  68292. */
  68293. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68294. /**
  68295. * Serializes this trail mesh
  68296. * @param serializationObject object to write serialization to
  68297. */
  68298. serialize(serializationObject: any): void;
  68299. /**
  68300. * Parses a serialized trail mesh
  68301. * @param parsedMesh the serialized mesh
  68302. * @param scene the scene to create the trail mesh in
  68303. * @returns the created trail mesh
  68304. */
  68305. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68306. }
  68307. }
  68308. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68309. import { Nullable } from "babylonjs/types";
  68310. import { Scene } from "babylonjs/scene";
  68311. import { Vector4 } from "babylonjs/Maths/math.vector";
  68312. import { Color4 } from "babylonjs/Maths/math.color";
  68313. import { Mesh } from "babylonjs/Meshes/mesh";
  68314. /**
  68315. * Class containing static functions to help procedurally build meshes
  68316. */
  68317. export class TiledBoxBuilder {
  68318. /**
  68319. * Creates a box mesh
  68320. * 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)
  68321. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68325. * @param name defines the name of the mesh
  68326. * @param options defines the options used to create the mesh
  68327. * @param scene defines the hosting scene
  68328. * @returns the box mesh
  68329. */
  68330. static CreateTiledBox(name: string, options: {
  68331. pattern?: number;
  68332. width?: number;
  68333. height?: number;
  68334. depth?: number;
  68335. tileSize?: number;
  68336. tileWidth?: number;
  68337. tileHeight?: number;
  68338. alignHorizontal?: number;
  68339. alignVertical?: number;
  68340. faceUV?: Vector4[];
  68341. faceColors?: Color4[];
  68342. sideOrientation?: number;
  68343. updatable?: boolean;
  68344. }, scene?: Nullable<Scene>): Mesh;
  68345. }
  68346. }
  68347. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68348. import { Vector4 } from "babylonjs/Maths/math.vector";
  68349. import { Mesh } from "babylonjs/Meshes/mesh";
  68350. /**
  68351. * Class containing static functions to help procedurally build meshes
  68352. */
  68353. export class TorusKnotBuilder {
  68354. /**
  68355. * Creates a torus knot mesh
  68356. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68357. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68358. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68359. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68363. * @param name defines the name of the mesh
  68364. * @param options defines the options used to create the mesh
  68365. * @param scene defines the hosting scene
  68366. * @returns the torus knot mesh
  68367. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68368. */
  68369. static CreateTorusKnot(name: string, options: {
  68370. radius?: number;
  68371. tube?: number;
  68372. radialSegments?: number;
  68373. tubularSegments?: number;
  68374. p?: number;
  68375. q?: number;
  68376. updatable?: boolean;
  68377. sideOrientation?: number;
  68378. frontUVs?: Vector4;
  68379. backUVs?: Vector4;
  68380. }, scene: any): Mesh;
  68381. }
  68382. }
  68383. declare module "babylonjs/Meshes/polygonMesh" {
  68384. import { Scene } from "babylonjs/scene";
  68385. import { Vector2 } from "babylonjs/Maths/math.vector";
  68386. import { Mesh } from "babylonjs/Meshes/mesh";
  68387. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68388. import { Path2 } from "babylonjs/Maths/math.path";
  68389. /**
  68390. * Polygon
  68391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68392. */
  68393. export class Polygon {
  68394. /**
  68395. * Creates a rectangle
  68396. * @param xmin bottom X coord
  68397. * @param ymin bottom Y coord
  68398. * @param xmax top X coord
  68399. * @param ymax top Y coord
  68400. * @returns points that make the resulting rectation
  68401. */
  68402. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68403. /**
  68404. * Creates a circle
  68405. * @param radius radius of circle
  68406. * @param cx scale in x
  68407. * @param cy scale in y
  68408. * @param numberOfSides number of sides that make up the circle
  68409. * @returns points that make the resulting circle
  68410. */
  68411. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68412. /**
  68413. * Creates a polygon from input string
  68414. * @param input Input polygon data
  68415. * @returns the parsed points
  68416. */
  68417. static Parse(input: string): Vector2[];
  68418. /**
  68419. * Starts building a polygon from x and y coordinates
  68420. * @param x x coordinate
  68421. * @param y y coordinate
  68422. * @returns the started path2
  68423. */
  68424. static StartingAt(x: number, y: number): Path2;
  68425. }
  68426. /**
  68427. * Builds a polygon
  68428. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68429. */
  68430. export class PolygonMeshBuilder {
  68431. private _points;
  68432. private _outlinepoints;
  68433. private _holes;
  68434. private _name;
  68435. private _scene;
  68436. private _epoints;
  68437. private _eholes;
  68438. private _addToepoint;
  68439. /**
  68440. * Babylon reference to the earcut plugin.
  68441. */
  68442. bjsEarcut: any;
  68443. /**
  68444. * Creates a PolygonMeshBuilder
  68445. * @param name name of the builder
  68446. * @param contours Path of the polygon
  68447. * @param scene scene to add to when creating the mesh
  68448. * @param earcutInjection can be used to inject your own earcut reference
  68449. */
  68450. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68451. /**
  68452. * Adds a whole within the polygon
  68453. * @param hole Array of points defining the hole
  68454. * @returns this
  68455. */
  68456. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68457. /**
  68458. * Creates the polygon
  68459. * @param updatable If the mesh should be updatable
  68460. * @param depth The depth of the mesh created
  68461. * @returns the created mesh
  68462. */
  68463. build(updatable?: boolean, depth?: number): Mesh;
  68464. /**
  68465. * Creates the polygon
  68466. * @param depth The depth of the mesh created
  68467. * @returns the created VertexData
  68468. */
  68469. buildVertexData(depth?: number): VertexData;
  68470. /**
  68471. * Adds a side to the polygon
  68472. * @param positions points that make the polygon
  68473. * @param normals normals of the polygon
  68474. * @param uvs uvs of the polygon
  68475. * @param indices indices of the polygon
  68476. * @param bounds bounds of the polygon
  68477. * @param points points of the polygon
  68478. * @param depth depth of the polygon
  68479. * @param flip flip of the polygon
  68480. */
  68481. private addSide;
  68482. }
  68483. }
  68484. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68485. import { Scene } from "babylonjs/scene";
  68486. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68487. import { Color4 } from "babylonjs/Maths/math.color";
  68488. import { Mesh } from "babylonjs/Meshes/mesh";
  68489. import { Nullable } from "babylonjs/types";
  68490. /**
  68491. * Class containing static functions to help procedurally build meshes
  68492. */
  68493. export class PolygonBuilder {
  68494. /**
  68495. * Creates a polygon mesh
  68496. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68497. * * 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
  68498. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68501. * * Remember you can only change the shape positions, not their number when updating a polygon
  68502. * @param name defines the name of the mesh
  68503. * @param options defines the options used to create the mesh
  68504. * @param scene defines the hosting scene
  68505. * @param earcutInjection can be used to inject your own earcut reference
  68506. * @returns the polygon mesh
  68507. */
  68508. static CreatePolygon(name: string, options: {
  68509. shape: Vector3[];
  68510. holes?: Vector3[][];
  68511. depth?: number;
  68512. faceUV?: Vector4[];
  68513. faceColors?: Color4[];
  68514. updatable?: boolean;
  68515. sideOrientation?: number;
  68516. frontUVs?: Vector4;
  68517. backUVs?: Vector4;
  68518. wrap?: boolean;
  68519. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68520. /**
  68521. * Creates an extruded polygon mesh, with depth in the Y direction.
  68522. * * 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)
  68523. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68524. * @param name defines the name of the mesh
  68525. * @param options defines the options used to create the mesh
  68526. * @param scene defines the hosting scene
  68527. * @param earcutInjection can be used to inject your own earcut reference
  68528. * @returns the polygon mesh
  68529. */
  68530. static ExtrudePolygon(name: string, options: {
  68531. shape: Vector3[];
  68532. holes?: Vector3[][];
  68533. depth?: number;
  68534. faceUV?: Vector4[];
  68535. faceColors?: Color4[];
  68536. updatable?: boolean;
  68537. sideOrientation?: number;
  68538. frontUVs?: Vector4;
  68539. backUVs?: Vector4;
  68540. wrap?: boolean;
  68541. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68542. }
  68543. }
  68544. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68545. import { Scene } from "babylonjs/scene";
  68546. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68547. import { Mesh } from "babylonjs/Meshes/mesh";
  68548. import { Nullable } from "babylonjs/types";
  68549. /**
  68550. * Class containing static functions to help procedurally build meshes
  68551. */
  68552. export class LatheBuilder {
  68553. /**
  68554. * Creates lathe mesh.
  68555. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68556. * * 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
  68557. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68558. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68559. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68560. * * 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
  68561. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68562. * * 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
  68563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68565. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68567. * @param name defines the name of the mesh
  68568. * @param options defines the options used to create the mesh
  68569. * @param scene defines the hosting scene
  68570. * @returns the lathe mesh
  68571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68572. */
  68573. static CreateLathe(name: string, options: {
  68574. shape: Vector3[];
  68575. radius?: number;
  68576. tessellation?: number;
  68577. clip?: number;
  68578. arc?: number;
  68579. closed?: boolean;
  68580. updatable?: boolean;
  68581. sideOrientation?: number;
  68582. frontUVs?: Vector4;
  68583. backUVs?: Vector4;
  68584. cap?: number;
  68585. invertUV?: boolean;
  68586. }, scene?: Nullable<Scene>): Mesh;
  68587. }
  68588. }
  68589. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68590. import { Nullable } from "babylonjs/types";
  68591. import { Scene } from "babylonjs/scene";
  68592. import { Vector4 } from "babylonjs/Maths/math.vector";
  68593. import { Mesh } from "babylonjs/Meshes/mesh";
  68594. /**
  68595. * Class containing static functions to help procedurally build meshes
  68596. */
  68597. export class TiledPlaneBuilder {
  68598. /**
  68599. * Creates a tiled plane mesh
  68600. * * The parameter `pattern` will, depending on value, do nothing or
  68601. * * * flip (reflect about central vertical) alternate tiles across and up
  68602. * * * flip every tile on alternate rows
  68603. * * * rotate (180 degs) alternate tiles across and up
  68604. * * * rotate every tile on alternate rows
  68605. * * * flip and rotate alternate tiles across and up
  68606. * * * flip and rotate every tile on alternate rows
  68607. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68608. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68610. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68611. * * 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)
  68612. * * 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)
  68613. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68614. * @param name defines the name of the mesh
  68615. * @param options defines the options used to create the mesh
  68616. * @param scene defines the hosting scene
  68617. * @returns the box mesh
  68618. */
  68619. static CreateTiledPlane(name: string, options: {
  68620. pattern?: number;
  68621. tileSize?: number;
  68622. tileWidth?: number;
  68623. tileHeight?: number;
  68624. size?: number;
  68625. width?: number;
  68626. height?: number;
  68627. alignHorizontal?: number;
  68628. alignVertical?: number;
  68629. sideOrientation?: number;
  68630. frontUVs?: Vector4;
  68631. backUVs?: Vector4;
  68632. updatable?: boolean;
  68633. }, scene?: Nullable<Scene>): Mesh;
  68634. }
  68635. }
  68636. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68637. import { Nullable } from "babylonjs/types";
  68638. import { Scene } from "babylonjs/scene";
  68639. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68640. import { Mesh } from "babylonjs/Meshes/mesh";
  68641. /**
  68642. * Class containing static functions to help procedurally build meshes
  68643. */
  68644. export class TubeBuilder {
  68645. /**
  68646. * Creates a tube mesh.
  68647. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68648. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68649. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68650. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68651. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68652. * * 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)
  68653. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68654. * * 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
  68655. * * 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
  68656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68660. * @param name defines the name of the mesh
  68661. * @param options defines the options used to create the mesh
  68662. * @param scene defines the hosting scene
  68663. * @returns the tube mesh
  68664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68665. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68666. */
  68667. static CreateTube(name: string, options: {
  68668. path: Vector3[];
  68669. radius?: number;
  68670. tessellation?: number;
  68671. radiusFunction?: {
  68672. (i: number, distance: number): number;
  68673. };
  68674. cap?: number;
  68675. arc?: number;
  68676. updatable?: boolean;
  68677. sideOrientation?: number;
  68678. frontUVs?: Vector4;
  68679. backUVs?: Vector4;
  68680. instance?: Mesh;
  68681. invertUV?: boolean;
  68682. }, scene?: Nullable<Scene>): Mesh;
  68683. }
  68684. }
  68685. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68686. import { Scene } from "babylonjs/scene";
  68687. import { Vector4 } from "babylonjs/Maths/math.vector";
  68688. import { Mesh } from "babylonjs/Meshes/mesh";
  68689. import { Nullable } from "babylonjs/types";
  68690. /**
  68691. * Class containing static functions to help procedurally build meshes
  68692. */
  68693. export class IcoSphereBuilder {
  68694. /**
  68695. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68696. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68697. * * 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`)
  68698. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68699. * * 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
  68700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68703. * @param name defines the name of the mesh
  68704. * @param options defines the options used to create the mesh
  68705. * @param scene defines the hosting scene
  68706. * @returns the icosahedron mesh
  68707. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68708. */
  68709. static CreateIcoSphere(name: string, options: {
  68710. radius?: number;
  68711. radiusX?: number;
  68712. radiusY?: number;
  68713. radiusZ?: number;
  68714. flat?: boolean;
  68715. subdivisions?: number;
  68716. sideOrientation?: number;
  68717. frontUVs?: Vector4;
  68718. backUVs?: Vector4;
  68719. updatable?: boolean;
  68720. }, scene?: Nullable<Scene>): Mesh;
  68721. }
  68722. }
  68723. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68724. import { Vector3 } from "babylonjs/Maths/math.vector";
  68725. import { Mesh } from "babylonjs/Meshes/mesh";
  68726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68727. /**
  68728. * Class containing static functions to help procedurally build meshes
  68729. */
  68730. export class DecalBuilder {
  68731. /**
  68732. * Creates a decal mesh.
  68733. * 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
  68734. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68735. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68736. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68737. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68738. * @param name defines the name of the mesh
  68739. * @param sourceMesh defines the mesh where the decal must be applied
  68740. * @param options defines the options used to create the mesh
  68741. * @param scene defines the hosting scene
  68742. * @returns the decal mesh
  68743. * @see https://doc.babylonjs.com/how_to/decals
  68744. */
  68745. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68746. position?: Vector3;
  68747. normal?: Vector3;
  68748. size?: Vector3;
  68749. angle?: number;
  68750. }): Mesh;
  68751. }
  68752. }
  68753. declare module "babylonjs/Meshes/meshBuilder" {
  68754. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68755. import { Nullable } from "babylonjs/types";
  68756. import { Scene } from "babylonjs/scene";
  68757. import { Mesh } from "babylonjs/Meshes/mesh";
  68758. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68759. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68761. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68762. import { Plane } from "babylonjs/Maths/math.plane";
  68763. /**
  68764. * Class containing static functions to help procedurally build meshes
  68765. */
  68766. export class MeshBuilder {
  68767. /**
  68768. * Creates a box mesh
  68769. * * The parameter `size` sets the size (float) of each box side (default 1)
  68770. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68771. * * 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)
  68772. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68776. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68777. * @param name defines the name of the mesh
  68778. * @param options defines the options used to create the mesh
  68779. * @param scene defines the hosting scene
  68780. * @returns the box mesh
  68781. */
  68782. static CreateBox(name: string, options: {
  68783. size?: number;
  68784. width?: number;
  68785. height?: number;
  68786. depth?: number;
  68787. faceUV?: Vector4[];
  68788. faceColors?: Color4[];
  68789. sideOrientation?: number;
  68790. frontUVs?: Vector4;
  68791. backUVs?: Vector4;
  68792. wrap?: boolean;
  68793. topBaseAt?: number;
  68794. bottomBaseAt?: number;
  68795. updatable?: boolean;
  68796. }, scene?: Nullable<Scene>): Mesh;
  68797. /**
  68798. * Creates a tiled box mesh
  68799. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68801. * @param name defines the name of the mesh
  68802. * @param options defines the options used to create the mesh
  68803. * @param scene defines the hosting scene
  68804. * @returns the tiled box mesh
  68805. */
  68806. static CreateTiledBox(name: string, options: {
  68807. pattern?: number;
  68808. size?: number;
  68809. width?: number;
  68810. height?: number;
  68811. depth: number;
  68812. tileSize?: number;
  68813. tileWidth?: number;
  68814. tileHeight?: number;
  68815. faceUV?: Vector4[];
  68816. faceColors?: Color4[];
  68817. alignHorizontal?: number;
  68818. alignVertical?: number;
  68819. sideOrientation?: number;
  68820. updatable?: boolean;
  68821. }, scene?: Nullable<Scene>): Mesh;
  68822. /**
  68823. * Creates a sphere mesh
  68824. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68825. * * 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`)
  68826. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68827. * * 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
  68828. * * 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)
  68829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68832. * @param name defines the name of the mesh
  68833. * @param options defines the options used to create the mesh
  68834. * @param scene defines the hosting scene
  68835. * @returns the sphere mesh
  68836. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68837. */
  68838. static CreateSphere(name: string, options: {
  68839. segments?: number;
  68840. diameter?: number;
  68841. diameterX?: number;
  68842. diameterY?: number;
  68843. diameterZ?: number;
  68844. arc?: number;
  68845. slice?: number;
  68846. sideOrientation?: number;
  68847. frontUVs?: Vector4;
  68848. backUVs?: Vector4;
  68849. updatable?: boolean;
  68850. }, scene?: Nullable<Scene>): Mesh;
  68851. /**
  68852. * Creates a plane polygonal mesh. By default, this is a disc
  68853. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68854. * * 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
  68855. * * 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
  68856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68859. * @param name defines the name of the mesh
  68860. * @param options defines the options used to create the mesh
  68861. * @param scene defines the hosting scene
  68862. * @returns the plane polygonal mesh
  68863. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68864. */
  68865. static CreateDisc(name: string, options: {
  68866. radius?: number;
  68867. tessellation?: number;
  68868. arc?: number;
  68869. updatable?: boolean;
  68870. sideOrientation?: number;
  68871. frontUVs?: Vector4;
  68872. backUVs?: Vector4;
  68873. }, scene?: Nullable<Scene>): Mesh;
  68874. /**
  68875. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68876. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68877. * * 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`)
  68878. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68879. * * 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
  68880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68883. * @param name defines the name of the mesh
  68884. * @param options defines the options used to create the mesh
  68885. * @param scene defines the hosting scene
  68886. * @returns the icosahedron mesh
  68887. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68888. */
  68889. static CreateIcoSphere(name: string, options: {
  68890. radius?: number;
  68891. radiusX?: number;
  68892. radiusY?: number;
  68893. radiusZ?: number;
  68894. flat?: boolean;
  68895. subdivisions?: number;
  68896. sideOrientation?: number;
  68897. frontUVs?: Vector4;
  68898. backUVs?: Vector4;
  68899. updatable?: boolean;
  68900. }, scene?: Nullable<Scene>): Mesh;
  68901. /**
  68902. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68903. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68904. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68905. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68906. * * 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
  68907. * * 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
  68908. * * 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
  68909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68911. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68912. * * 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
  68913. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68914. * * 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
  68915. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68917. * @param name defines the name of the mesh
  68918. * @param options defines the options used to create the mesh
  68919. * @param scene defines the hosting scene
  68920. * @returns the ribbon mesh
  68921. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68923. */
  68924. static CreateRibbon(name: string, options: {
  68925. pathArray: Vector3[][];
  68926. closeArray?: boolean;
  68927. closePath?: boolean;
  68928. offset?: number;
  68929. updatable?: boolean;
  68930. sideOrientation?: number;
  68931. frontUVs?: Vector4;
  68932. backUVs?: Vector4;
  68933. instance?: Mesh;
  68934. invertUV?: boolean;
  68935. uvs?: Vector2[];
  68936. colors?: Color4[];
  68937. }, scene?: Nullable<Scene>): Mesh;
  68938. /**
  68939. * Creates a cylinder or a cone mesh
  68940. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68941. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68942. * * 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.
  68943. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68944. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68945. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68946. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68947. * * 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).
  68948. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68949. * * 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).
  68950. * * 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
  68951. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68952. * * 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
  68953. * * 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.
  68954. * * If `enclose` is false, a ring surface is one element.
  68955. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68956. * * 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
  68957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68960. * @param name defines the name of the mesh
  68961. * @param options defines the options used to create the mesh
  68962. * @param scene defines the hosting scene
  68963. * @returns the cylinder mesh
  68964. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68965. */
  68966. static CreateCylinder(name: string, options: {
  68967. height?: number;
  68968. diameterTop?: number;
  68969. diameterBottom?: number;
  68970. diameter?: number;
  68971. tessellation?: number;
  68972. subdivisions?: number;
  68973. arc?: number;
  68974. faceColors?: Color4[];
  68975. faceUV?: Vector4[];
  68976. updatable?: boolean;
  68977. hasRings?: boolean;
  68978. enclose?: boolean;
  68979. cap?: number;
  68980. sideOrientation?: number;
  68981. frontUVs?: Vector4;
  68982. backUVs?: Vector4;
  68983. }, scene?: Nullable<Scene>): Mesh;
  68984. /**
  68985. * Creates a torus mesh
  68986. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68987. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68988. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68992. * @param name defines the name of the mesh
  68993. * @param options defines the options used to create the mesh
  68994. * @param scene defines the hosting scene
  68995. * @returns the torus mesh
  68996. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68997. */
  68998. static CreateTorus(name: string, options: {
  68999. diameter?: number;
  69000. thickness?: number;
  69001. tessellation?: number;
  69002. updatable?: boolean;
  69003. sideOrientation?: number;
  69004. frontUVs?: Vector4;
  69005. backUVs?: Vector4;
  69006. }, scene?: Nullable<Scene>): Mesh;
  69007. /**
  69008. * Creates a torus knot mesh
  69009. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69010. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69011. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69012. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69016. * @param name defines the name of the mesh
  69017. * @param options defines the options used to create the mesh
  69018. * @param scene defines the hosting scene
  69019. * @returns the torus knot mesh
  69020. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69021. */
  69022. static CreateTorusKnot(name: string, options: {
  69023. radius?: number;
  69024. tube?: number;
  69025. radialSegments?: number;
  69026. tubularSegments?: number;
  69027. p?: number;
  69028. q?: number;
  69029. updatable?: boolean;
  69030. sideOrientation?: number;
  69031. frontUVs?: Vector4;
  69032. backUVs?: Vector4;
  69033. }, scene?: Nullable<Scene>): Mesh;
  69034. /**
  69035. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69036. * * 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
  69037. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69038. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69039. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69040. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69041. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69042. * * 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
  69043. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69046. * @param name defines the name of the new line system
  69047. * @param options defines the options used to create the line system
  69048. * @param scene defines the hosting scene
  69049. * @returns a new line system mesh
  69050. */
  69051. static CreateLineSystem(name: string, options: {
  69052. lines: Vector3[][];
  69053. updatable?: boolean;
  69054. instance?: Nullable<LinesMesh>;
  69055. colors?: Nullable<Color4[][]>;
  69056. useVertexAlpha?: boolean;
  69057. }, scene: Nullable<Scene>): LinesMesh;
  69058. /**
  69059. * Creates a line mesh
  69060. * 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
  69061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69062. * * The parameter `points` is an array successive Vector3
  69063. * * 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
  69064. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69065. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69066. * * When updating an instance, remember that only point positions can change, not the number of points
  69067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69069. * @param name defines the name of the new line system
  69070. * @param options defines the options used to create the line system
  69071. * @param scene defines the hosting scene
  69072. * @returns a new line mesh
  69073. */
  69074. static CreateLines(name: string, options: {
  69075. points: Vector3[];
  69076. updatable?: boolean;
  69077. instance?: Nullable<LinesMesh>;
  69078. colors?: Color4[];
  69079. useVertexAlpha?: boolean;
  69080. }, scene?: Nullable<Scene>): LinesMesh;
  69081. /**
  69082. * Creates a dashed line mesh
  69083. * * 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
  69084. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69085. * * The parameter `points` is an array successive Vector3
  69086. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69087. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69088. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69089. * * 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
  69090. * * When updating an instance, remember that only point positions can change, not the number of points
  69091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69092. * @param name defines the name of the mesh
  69093. * @param options defines the options used to create the mesh
  69094. * @param scene defines the hosting scene
  69095. * @returns the dashed line mesh
  69096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69097. */
  69098. static CreateDashedLines(name: string, options: {
  69099. points: Vector3[];
  69100. dashSize?: number;
  69101. gapSize?: number;
  69102. dashNb?: number;
  69103. updatable?: boolean;
  69104. instance?: LinesMesh;
  69105. }, scene?: Nullable<Scene>): LinesMesh;
  69106. /**
  69107. * 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.
  69108. * * 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.
  69109. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69110. * * 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.
  69111. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69112. * * 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
  69113. * * 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
  69114. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69117. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69119. * @param name defines the name of the mesh
  69120. * @param options defines the options used to create the mesh
  69121. * @param scene defines the hosting scene
  69122. * @returns the extruded shape mesh
  69123. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69125. */
  69126. static ExtrudeShape(name: string, options: {
  69127. shape: Vector3[];
  69128. path: Vector3[];
  69129. scale?: number;
  69130. rotation?: number;
  69131. cap?: number;
  69132. updatable?: boolean;
  69133. sideOrientation?: number;
  69134. frontUVs?: Vector4;
  69135. backUVs?: Vector4;
  69136. instance?: Mesh;
  69137. invertUV?: boolean;
  69138. }, scene?: Nullable<Scene>): Mesh;
  69139. /**
  69140. * Creates an custom extruded shape mesh.
  69141. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69142. * * 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.
  69143. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69144. * * 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
  69145. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69146. * * 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
  69147. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69148. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69149. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69150. * * 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
  69151. * * 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
  69152. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69157. * @param name defines the name of the mesh
  69158. * @param options defines the options used to create the mesh
  69159. * @param scene defines the hosting scene
  69160. * @returns the custom extruded shape mesh
  69161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69162. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69163. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69164. */
  69165. static ExtrudeShapeCustom(name: string, options: {
  69166. shape: Vector3[];
  69167. path: Vector3[];
  69168. scaleFunction?: any;
  69169. rotationFunction?: any;
  69170. ribbonCloseArray?: boolean;
  69171. ribbonClosePath?: boolean;
  69172. cap?: number;
  69173. updatable?: boolean;
  69174. sideOrientation?: number;
  69175. frontUVs?: Vector4;
  69176. backUVs?: Vector4;
  69177. instance?: Mesh;
  69178. invertUV?: boolean;
  69179. }, scene?: Nullable<Scene>): Mesh;
  69180. /**
  69181. * Creates lathe mesh.
  69182. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69183. * * 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
  69184. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69185. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69186. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69187. * * 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
  69188. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69189. * * 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
  69190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69194. * @param name defines the name of the mesh
  69195. * @param options defines the options used to create the mesh
  69196. * @param scene defines the hosting scene
  69197. * @returns the lathe mesh
  69198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69199. */
  69200. static CreateLathe(name: string, options: {
  69201. shape: Vector3[];
  69202. radius?: number;
  69203. tessellation?: number;
  69204. clip?: number;
  69205. arc?: number;
  69206. closed?: boolean;
  69207. updatable?: boolean;
  69208. sideOrientation?: number;
  69209. frontUVs?: Vector4;
  69210. backUVs?: Vector4;
  69211. cap?: number;
  69212. invertUV?: boolean;
  69213. }, scene?: Nullable<Scene>): Mesh;
  69214. /**
  69215. * Creates a tiled plane mesh
  69216. * * You can set a limited pattern arrangement with the tiles
  69217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69220. * @param name defines the name of the mesh
  69221. * @param options defines the options used to create the mesh
  69222. * @param scene defines the hosting scene
  69223. * @returns the plane mesh
  69224. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69225. */
  69226. static CreateTiledPlane(name: string, options: {
  69227. pattern?: number;
  69228. tileSize?: number;
  69229. tileWidth?: number;
  69230. tileHeight?: number;
  69231. size?: number;
  69232. width?: number;
  69233. height?: number;
  69234. alignHorizontal?: number;
  69235. alignVertical?: number;
  69236. sideOrientation?: number;
  69237. frontUVs?: Vector4;
  69238. backUVs?: Vector4;
  69239. updatable?: boolean;
  69240. }, scene?: Nullable<Scene>): Mesh;
  69241. /**
  69242. * Creates a plane mesh
  69243. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69244. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69245. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69249. * @param name defines the name of the mesh
  69250. * @param options defines the options used to create the mesh
  69251. * @param scene defines the hosting scene
  69252. * @returns the plane mesh
  69253. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69254. */
  69255. static CreatePlane(name: string, options: {
  69256. size?: number;
  69257. width?: number;
  69258. height?: number;
  69259. sideOrientation?: number;
  69260. frontUVs?: Vector4;
  69261. backUVs?: Vector4;
  69262. updatable?: boolean;
  69263. sourcePlane?: Plane;
  69264. }, scene?: Nullable<Scene>): Mesh;
  69265. /**
  69266. * Creates a ground mesh
  69267. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69268. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69270. * @param name defines the name of the mesh
  69271. * @param options defines the options used to create the mesh
  69272. * @param scene defines the hosting scene
  69273. * @returns the ground mesh
  69274. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69275. */
  69276. static CreateGround(name: string, options: {
  69277. width?: number;
  69278. height?: number;
  69279. subdivisions?: number;
  69280. subdivisionsX?: number;
  69281. subdivisionsY?: number;
  69282. updatable?: boolean;
  69283. }, scene?: Nullable<Scene>): Mesh;
  69284. /**
  69285. * Creates a tiled ground mesh
  69286. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69287. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69288. * * 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
  69289. * * 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
  69290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69291. * @param name defines the name of the mesh
  69292. * @param options defines the options used to create the mesh
  69293. * @param scene defines the hosting scene
  69294. * @returns the tiled ground mesh
  69295. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69296. */
  69297. static CreateTiledGround(name: string, options: {
  69298. xmin: number;
  69299. zmin: number;
  69300. xmax: number;
  69301. zmax: number;
  69302. subdivisions?: {
  69303. w: number;
  69304. h: number;
  69305. };
  69306. precision?: {
  69307. w: number;
  69308. h: number;
  69309. };
  69310. updatable?: boolean;
  69311. }, scene?: Nullable<Scene>): Mesh;
  69312. /**
  69313. * Creates a ground mesh from a height map
  69314. * * The parameter `url` sets the URL of the height map image resource.
  69315. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69316. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69317. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69318. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69319. * * 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.
  69320. * * 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).
  69321. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69323. * @param name defines the name of the mesh
  69324. * @param url defines the url to the height map
  69325. * @param options defines the options used to create the mesh
  69326. * @param scene defines the hosting scene
  69327. * @returns the ground mesh
  69328. * @see https://doc.babylonjs.com/babylon101/height_map
  69329. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69330. */
  69331. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69332. width?: number;
  69333. height?: number;
  69334. subdivisions?: number;
  69335. minHeight?: number;
  69336. maxHeight?: number;
  69337. colorFilter?: Color3;
  69338. alphaFilter?: number;
  69339. updatable?: boolean;
  69340. onReady?: (mesh: GroundMesh) => void;
  69341. }, scene?: Nullable<Scene>): GroundMesh;
  69342. /**
  69343. * Creates a polygon mesh
  69344. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69345. * * 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
  69346. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69349. * * Remember you can only change the shape positions, not their number when updating a polygon
  69350. * @param name defines the name of the mesh
  69351. * @param options defines the options used to create the mesh
  69352. * @param scene defines the hosting scene
  69353. * @param earcutInjection can be used to inject your own earcut reference
  69354. * @returns the polygon mesh
  69355. */
  69356. static CreatePolygon(name: string, options: {
  69357. shape: Vector3[];
  69358. holes?: Vector3[][];
  69359. depth?: number;
  69360. faceUV?: Vector4[];
  69361. faceColors?: Color4[];
  69362. updatable?: boolean;
  69363. sideOrientation?: number;
  69364. frontUVs?: Vector4;
  69365. backUVs?: Vector4;
  69366. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69367. /**
  69368. * Creates an extruded polygon mesh, with depth in the Y direction.
  69369. * * 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)
  69370. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69371. * @param name defines the name of the mesh
  69372. * @param options defines the options used to create the mesh
  69373. * @param scene defines the hosting scene
  69374. * @param earcutInjection can be used to inject your own earcut reference
  69375. * @returns the polygon mesh
  69376. */
  69377. static ExtrudePolygon(name: string, options: {
  69378. shape: Vector3[];
  69379. holes?: Vector3[][];
  69380. depth?: number;
  69381. faceUV?: Vector4[];
  69382. faceColors?: Color4[];
  69383. updatable?: boolean;
  69384. sideOrientation?: number;
  69385. frontUVs?: Vector4;
  69386. backUVs?: Vector4;
  69387. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69388. /**
  69389. * Creates a tube mesh.
  69390. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69391. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69392. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69393. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69394. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69395. * * 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)
  69396. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69397. * * 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
  69398. * * 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
  69399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69403. * @param name defines the name of the mesh
  69404. * @param options defines the options used to create the mesh
  69405. * @param scene defines the hosting scene
  69406. * @returns the tube mesh
  69407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69408. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69409. */
  69410. static CreateTube(name: string, options: {
  69411. path: Vector3[];
  69412. radius?: number;
  69413. tessellation?: number;
  69414. radiusFunction?: {
  69415. (i: number, distance: number): number;
  69416. };
  69417. cap?: number;
  69418. arc?: number;
  69419. updatable?: boolean;
  69420. sideOrientation?: number;
  69421. frontUVs?: Vector4;
  69422. backUVs?: Vector4;
  69423. instance?: Mesh;
  69424. invertUV?: boolean;
  69425. }, scene?: Nullable<Scene>): Mesh;
  69426. /**
  69427. * Creates a polyhedron mesh
  69428. * * 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
  69429. * * The parameter `size` (positive float, default 1) sets the polygon size
  69430. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69431. * * 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`
  69432. * * 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
  69433. * * 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)`)
  69434. * * 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
  69435. * * 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
  69436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69439. * @param name defines the name of the mesh
  69440. * @param options defines the options used to create the mesh
  69441. * @param scene defines the hosting scene
  69442. * @returns the polyhedron mesh
  69443. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69444. */
  69445. static CreatePolyhedron(name: string, options: {
  69446. type?: number;
  69447. size?: number;
  69448. sizeX?: number;
  69449. sizeY?: number;
  69450. sizeZ?: number;
  69451. custom?: any;
  69452. faceUV?: Vector4[];
  69453. faceColors?: Color4[];
  69454. flat?: boolean;
  69455. updatable?: boolean;
  69456. sideOrientation?: number;
  69457. frontUVs?: Vector4;
  69458. backUVs?: Vector4;
  69459. }, scene?: Nullable<Scene>): Mesh;
  69460. /**
  69461. * Creates a decal mesh.
  69462. * 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
  69463. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69464. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69465. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69466. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69467. * @param name defines the name of the mesh
  69468. * @param sourceMesh defines the mesh where the decal must be applied
  69469. * @param options defines the options used to create the mesh
  69470. * @param scene defines the hosting scene
  69471. * @returns the decal mesh
  69472. * @see https://doc.babylonjs.com/how_to/decals
  69473. */
  69474. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69475. position?: Vector3;
  69476. normal?: Vector3;
  69477. size?: Vector3;
  69478. angle?: number;
  69479. }): Mesh;
  69480. }
  69481. }
  69482. declare module "babylonjs/Meshes/meshSimplification" {
  69483. import { Mesh } from "babylonjs/Meshes/mesh";
  69484. /**
  69485. * A simplifier interface for future simplification implementations
  69486. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69487. */
  69488. export interface ISimplifier {
  69489. /**
  69490. * Simplification of a given mesh according to the given settings.
  69491. * Since this requires computation, it is assumed that the function runs async.
  69492. * @param settings The settings of the simplification, including quality and distance
  69493. * @param successCallback A callback that will be called after the mesh was simplified.
  69494. * @param errorCallback in case of an error, this callback will be called. optional.
  69495. */
  69496. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69497. }
  69498. /**
  69499. * Expected simplification settings.
  69500. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69501. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69502. */
  69503. export interface ISimplificationSettings {
  69504. /**
  69505. * Gets or sets the expected quality
  69506. */
  69507. quality: number;
  69508. /**
  69509. * Gets or sets the distance when this optimized version should be used
  69510. */
  69511. distance: number;
  69512. /**
  69513. * Gets an already optimized mesh
  69514. */
  69515. optimizeMesh?: boolean;
  69516. }
  69517. /**
  69518. * Class used to specify simplification options
  69519. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69520. */
  69521. export class SimplificationSettings implements ISimplificationSettings {
  69522. /** expected quality */
  69523. quality: number;
  69524. /** distance when this optimized version should be used */
  69525. distance: number;
  69526. /** already optimized mesh */
  69527. optimizeMesh?: boolean | undefined;
  69528. /**
  69529. * Creates a SimplificationSettings
  69530. * @param quality expected quality
  69531. * @param distance distance when this optimized version should be used
  69532. * @param optimizeMesh already optimized mesh
  69533. */
  69534. constructor(
  69535. /** expected quality */
  69536. quality: number,
  69537. /** distance when this optimized version should be used */
  69538. distance: number,
  69539. /** already optimized mesh */
  69540. optimizeMesh?: boolean | undefined);
  69541. }
  69542. /**
  69543. * Interface used to define a simplification task
  69544. */
  69545. export interface ISimplificationTask {
  69546. /**
  69547. * Array of settings
  69548. */
  69549. settings: Array<ISimplificationSettings>;
  69550. /**
  69551. * Simplification type
  69552. */
  69553. simplificationType: SimplificationType;
  69554. /**
  69555. * Mesh to simplify
  69556. */
  69557. mesh: Mesh;
  69558. /**
  69559. * Callback called on success
  69560. */
  69561. successCallback?: () => void;
  69562. /**
  69563. * Defines if parallel processing can be used
  69564. */
  69565. parallelProcessing: boolean;
  69566. }
  69567. /**
  69568. * Queue used to order the simplification tasks
  69569. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69570. */
  69571. export class SimplificationQueue {
  69572. private _simplificationArray;
  69573. /**
  69574. * Gets a boolean indicating that the process is still running
  69575. */
  69576. running: boolean;
  69577. /**
  69578. * Creates a new queue
  69579. */
  69580. constructor();
  69581. /**
  69582. * Adds a new simplification task
  69583. * @param task defines a task to add
  69584. */
  69585. addTask(task: ISimplificationTask): void;
  69586. /**
  69587. * Execute next task
  69588. */
  69589. executeNext(): void;
  69590. /**
  69591. * Execute a simplification task
  69592. * @param task defines the task to run
  69593. */
  69594. runSimplification(task: ISimplificationTask): void;
  69595. private getSimplifier;
  69596. }
  69597. /**
  69598. * The implemented types of simplification
  69599. * At the moment only Quadratic Error Decimation is implemented
  69600. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69601. */
  69602. export enum SimplificationType {
  69603. /** Quadratic error decimation */
  69604. QUADRATIC = 0
  69605. }
  69606. /**
  69607. * An implementation of the Quadratic Error simplification algorithm.
  69608. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69609. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69610. * @author RaananW
  69611. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69612. */
  69613. export class QuadraticErrorSimplification implements ISimplifier {
  69614. private _mesh;
  69615. private triangles;
  69616. private vertices;
  69617. private references;
  69618. private _reconstructedMesh;
  69619. /** Gets or sets the number pf sync interations */
  69620. syncIterations: number;
  69621. /** Gets or sets the aggressiveness of the simplifier */
  69622. aggressiveness: number;
  69623. /** Gets or sets the number of allowed iterations for decimation */
  69624. decimationIterations: number;
  69625. /** Gets or sets the espilon to use for bounding box computation */
  69626. boundingBoxEpsilon: number;
  69627. /**
  69628. * Creates a new QuadraticErrorSimplification
  69629. * @param _mesh defines the target mesh
  69630. */
  69631. constructor(_mesh: Mesh);
  69632. /**
  69633. * Simplification of a given mesh according to the given settings.
  69634. * Since this requires computation, it is assumed that the function runs async.
  69635. * @param settings The settings of the simplification, including quality and distance
  69636. * @param successCallback A callback that will be called after the mesh was simplified.
  69637. */
  69638. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69639. private runDecimation;
  69640. private initWithMesh;
  69641. private init;
  69642. private reconstructMesh;
  69643. private initDecimatedMesh;
  69644. private isFlipped;
  69645. private updateTriangles;
  69646. private identifyBorder;
  69647. private updateMesh;
  69648. private vertexError;
  69649. private calculateError;
  69650. }
  69651. }
  69652. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69653. import { Scene } from "babylonjs/scene";
  69654. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69655. import { ISceneComponent } from "babylonjs/sceneComponent";
  69656. module "babylonjs/scene" {
  69657. interface Scene {
  69658. /** @hidden (Backing field) */
  69659. _simplificationQueue: SimplificationQueue;
  69660. /**
  69661. * Gets or sets the simplification queue attached to the scene
  69662. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69663. */
  69664. simplificationQueue: SimplificationQueue;
  69665. }
  69666. }
  69667. module "babylonjs/Meshes/mesh" {
  69668. interface Mesh {
  69669. /**
  69670. * Simplify the mesh according to the given array of settings.
  69671. * Function will return immediately and will simplify async
  69672. * @param settings a collection of simplification settings
  69673. * @param parallelProcessing should all levels calculate parallel or one after the other
  69674. * @param simplificationType the type of simplification to run
  69675. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69676. * @returns the current mesh
  69677. */
  69678. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69679. }
  69680. }
  69681. /**
  69682. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69683. * created in a scene
  69684. */
  69685. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69686. /**
  69687. * The component name helpfull to identify the component in the list of scene components.
  69688. */
  69689. readonly name: string;
  69690. /**
  69691. * The scene the component belongs to.
  69692. */
  69693. scene: Scene;
  69694. /**
  69695. * Creates a new instance of the component for the given scene
  69696. * @param scene Defines the scene to register the component in
  69697. */
  69698. constructor(scene: Scene);
  69699. /**
  69700. * Registers the component in a given scene
  69701. */
  69702. register(): void;
  69703. /**
  69704. * Rebuilds the elements related to this component in case of
  69705. * context lost for instance.
  69706. */
  69707. rebuild(): void;
  69708. /**
  69709. * Disposes the component and the associated ressources
  69710. */
  69711. dispose(): void;
  69712. private _beforeCameraUpdate;
  69713. }
  69714. }
  69715. declare module "babylonjs/Meshes/Builders/index" {
  69716. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69717. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69718. export * from "babylonjs/Meshes/Builders/discBuilder";
  69719. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69720. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69721. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69722. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69723. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69724. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69725. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69726. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69727. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69728. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69729. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69730. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69731. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69732. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69733. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69734. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69735. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69736. }
  69737. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69738. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69739. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69740. import { Matrix } from "babylonjs/Maths/math.vector";
  69741. module "babylonjs/Meshes/mesh" {
  69742. interface Mesh {
  69743. /**
  69744. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  69745. */
  69746. thinInstanceEnablePicking: boolean;
  69747. /**
  69748. * Creates a new thin instance
  69749. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69750. * @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
  69751. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69752. */
  69753. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69754. /**
  69755. * Adds the transformation (matrix) of the current mesh as a thin instance
  69756. * @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
  69757. * @returns the thin instance index number
  69758. */
  69759. thinInstanceAddSelf(refresh: boolean): number;
  69760. /**
  69761. * Registers a custom attribute to be used with thin instances
  69762. * @param kind name of the attribute
  69763. * @param stride size in floats of the attribute
  69764. */
  69765. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69766. /**
  69767. * Sets the matrix of a thin instance
  69768. * @param index index of the thin instance
  69769. * @param matrix matrix to set
  69770. * @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
  69771. */
  69772. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69773. /**
  69774. * Sets the value of a custom attribute for a thin instance
  69775. * @param kind name of the attribute
  69776. * @param index index of the thin instance
  69777. * @param value value to set
  69778. * @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
  69779. */
  69780. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69781. /**
  69782. * 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.
  69783. */
  69784. thinInstanceCount: number;
  69785. /**
  69786. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69787. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69788. * @param buffer buffer to set
  69789. * @param stride size in floats of each value of the buffer
  69790. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69791. */
  69792. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69793. /**
  69794. * Gets the list of world matrices
  69795. * @return an array containing all the world matrices from the thin instances
  69796. */
  69797. thinInstanceGetWorldMatrices(): Matrix[];
  69798. /**
  69799. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69800. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69801. */
  69802. thinInstanceBufferUpdated(kind: string): void;
  69803. /**
  69804. * Refreshes the bounding info, taking into account all the thin instances defined
  69805. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69806. */
  69807. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69808. /** @hidden */
  69809. _thinInstanceInitializeUserStorage(): void;
  69810. /** @hidden */
  69811. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69812. /** @hidden */
  69813. _userThinInstanceBuffersStorage: {
  69814. data: {
  69815. [key: string]: Float32Array;
  69816. };
  69817. sizes: {
  69818. [key: string]: number;
  69819. };
  69820. vertexBuffers: {
  69821. [key: string]: Nullable<VertexBuffer>;
  69822. };
  69823. strides: {
  69824. [key: string]: number;
  69825. };
  69826. };
  69827. }
  69828. }
  69829. }
  69830. declare module "babylonjs/Meshes/index" {
  69831. export * from "babylonjs/Meshes/abstractMesh";
  69832. export * from "babylonjs/Meshes/buffer";
  69833. export * from "babylonjs/Meshes/Compression/index";
  69834. export * from "babylonjs/Meshes/csg";
  69835. export * from "babylonjs/Meshes/geometry";
  69836. export * from "babylonjs/Meshes/groundMesh";
  69837. export * from "babylonjs/Meshes/trailMesh";
  69838. export * from "babylonjs/Meshes/instancedMesh";
  69839. export * from "babylonjs/Meshes/linesMesh";
  69840. export * from "babylonjs/Meshes/mesh";
  69841. export * from "babylonjs/Meshes/mesh.vertexData";
  69842. export * from "babylonjs/Meshes/meshBuilder";
  69843. export * from "babylonjs/Meshes/meshSimplification";
  69844. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69845. export * from "babylonjs/Meshes/polygonMesh";
  69846. export * from "babylonjs/Meshes/subMesh";
  69847. export * from "babylonjs/Meshes/meshLODLevel";
  69848. export * from "babylonjs/Meshes/transformNode";
  69849. export * from "babylonjs/Meshes/Builders/index";
  69850. export * from "babylonjs/Meshes/dataBuffer";
  69851. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69852. import "babylonjs/Meshes/thinInstanceMesh";
  69853. export * from "babylonjs/Meshes/thinInstanceMesh";
  69854. }
  69855. declare module "babylonjs/Morph/index" {
  69856. export * from "babylonjs/Morph/morphTarget";
  69857. export * from "babylonjs/Morph/morphTargetManager";
  69858. }
  69859. declare module "babylonjs/Navigation/INavigationEngine" {
  69860. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69861. import { Vector3 } from "babylonjs/Maths/math";
  69862. import { Mesh } from "babylonjs/Meshes/mesh";
  69863. import { Scene } from "babylonjs/scene";
  69864. /**
  69865. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69866. */
  69867. export interface INavigationEnginePlugin {
  69868. /**
  69869. * plugin name
  69870. */
  69871. name: string;
  69872. /**
  69873. * Creates a navigation mesh
  69874. * @param meshes array of all the geometry used to compute the navigatio mesh
  69875. * @param parameters bunch of parameters used to filter geometry
  69876. */
  69877. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69878. /**
  69879. * Create a navigation mesh debug mesh
  69880. * @param scene is where the mesh will be added
  69881. * @returns debug display mesh
  69882. */
  69883. createDebugNavMesh(scene: Scene): Mesh;
  69884. /**
  69885. * Get a navigation mesh constrained position, closest to the parameter position
  69886. * @param position world position
  69887. * @returns the closest point to position constrained by the navigation mesh
  69888. */
  69889. getClosestPoint(position: Vector3): Vector3;
  69890. /**
  69891. * Get a navigation mesh constrained position, closest to the parameter position
  69892. * @param position world position
  69893. * @param result output the closest point to position constrained by the navigation mesh
  69894. */
  69895. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69896. /**
  69897. * Get a navigation mesh constrained position, within a particular radius
  69898. * @param position world position
  69899. * @param maxRadius the maximum distance to the constrained world position
  69900. * @returns the closest point to position constrained by the navigation mesh
  69901. */
  69902. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69903. /**
  69904. * Get a navigation mesh constrained position, within a particular radius
  69905. * @param position world position
  69906. * @param maxRadius the maximum distance to the constrained world position
  69907. * @param result output the closest point to position constrained by the navigation mesh
  69908. */
  69909. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69910. /**
  69911. * Compute the final position from a segment made of destination-position
  69912. * @param position world position
  69913. * @param destination world position
  69914. * @returns the resulting point along the navmesh
  69915. */
  69916. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69917. /**
  69918. * Compute the final position from a segment made of destination-position
  69919. * @param position world position
  69920. * @param destination world position
  69921. * @param result output the resulting point along the navmesh
  69922. */
  69923. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69924. /**
  69925. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69926. * @param start world position
  69927. * @param end world position
  69928. * @returns array containing world position composing the path
  69929. */
  69930. computePath(start: Vector3, end: Vector3): Vector3[];
  69931. /**
  69932. * If this plugin is supported
  69933. * @returns true if plugin is supported
  69934. */
  69935. isSupported(): boolean;
  69936. /**
  69937. * Create a new Crowd so you can add agents
  69938. * @param maxAgents the maximum agent count in the crowd
  69939. * @param maxAgentRadius the maximum radius an agent can have
  69940. * @param scene to attach the crowd to
  69941. * @returns the crowd you can add agents to
  69942. */
  69943. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69944. /**
  69945. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69946. * The queries will try to find a solution within those bounds
  69947. * default is (1,1,1)
  69948. * @param extent x,y,z value that define the extent around the queries point of reference
  69949. */
  69950. setDefaultQueryExtent(extent: Vector3): void;
  69951. /**
  69952. * Get the Bounding box extent specified by setDefaultQueryExtent
  69953. * @returns the box extent values
  69954. */
  69955. getDefaultQueryExtent(): Vector3;
  69956. /**
  69957. * build the navmesh from a previously saved state using getNavmeshData
  69958. * @param data the Uint8Array returned by getNavmeshData
  69959. */
  69960. buildFromNavmeshData(data: Uint8Array): void;
  69961. /**
  69962. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69963. * @returns data the Uint8Array that can be saved and reused
  69964. */
  69965. getNavmeshData(): Uint8Array;
  69966. /**
  69967. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69968. * @param result output the box extent values
  69969. */
  69970. getDefaultQueryExtentToRef(result: Vector3): void;
  69971. /**
  69972. * Release all resources
  69973. */
  69974. dispose(): void;
  69975. }
  69976. /**
  69977. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69978. */
  69979. export interface ICrowd {
  69980. /**
  69981. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69982. * You can attach anything to that node. The node position is updated in the scene update tick.
  69983. * @param pos world position that will be constrained by the navigation mesh
  69984. * @param parameters agent parameters
  69985. * @param transform hooked to the agent that will be update by the scene
  69986. * @returns agent index
  69987. */
  69988. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69989. /**
  69990. * Returns the agent position in world space
  69991. * @param index agent index returned by addAgent
  69992. * @returns world space position
  69993. */
  69994. getAgentPosition(index: number): Vector3;
  69995. /**
  69996. * Gets the agent position result in world space
  69997. * @param index agent index returned by addAgent
  69998. * @param result output world space position
  69999. */
  70000. getAgentPositionToRef(index: number, result: Vector3): void;
  70001. /**
  70002. * Gets the agent velocity in world space
  70003. * @param index agent index returned by addAgent
  70004. * @returns world space velocity
  70005. */
  70006. getAgentVelocity(index: number): Vector3;
  70007. /**
  70008. * Gets the agent velocity result in world space
  70009. * @param index agent index returned by addAgent
  70010. * @param result output world space velocity
  70011. */
  70012. getAgentVelocityToRef(index: number, result: Vector3): void;
  70013. /**
  70014. * remove a particular agent previously created
  70015. * @param index agent index returned by addAgent
  70016. */
  70017. removeAgent(index: number): void;
  70018. /**
  70019. * get the list of all agents attached to this crowd
  70020. * @returns list of agent indices
  70021. */
  70022. getAgents(): number[];
  70023. /**
  70024. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70025. * @param deltaTime in seconds
  70026. */
  70027. update(deltaTime: number): void;
  70028. /**
  70029. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70030. * @param index agent index returned by addAgent
  70031. * @param destination targeted world position
  70032. */
  70033. agentGoto(index: number, destination: Vector3): void;
  70034. /**
  70035. * Teleport the agent to a new position
  70036. * @param index agent index returned by addAgent
  70037. * @param destination targeted world position
  70038. */
  70039. agentTeleport(index: number, destination: Vector3): void;
  70040. /**
  70041. * Update agent parameters
  70042. * @param index agent index returned by addAgent
  70043. * @param parameters agent parameters
  70044. */
  70045. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70046. /**
  70047. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70048. * The queries will try to find a solution within those bounds
  70049. * default is (1,1,1)
  70050. * @param extent x,y,z value that define the extent around the queries point of reference
  70051. */
  70052. setDefaultQueryExtent(extent: Vector3): void;
  70053. /**
  70054. * Get the Bounding box extent specified by setDefaultQueryExtent
  70055. * @returns the box extent values
  70056. */
  70057. getDefaultQueryExtent(): Vector3;
  70058. /**
  70059. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70060. * @param result output the box extent values
  70061. */
  70062. getDefaultQueryExtentToRef(result: Vector3): void;
  70063. /**
  70064. * Release all resources
  70065. */
  70066. dispose(): void;
  70067. }
  70068. /**
  70069. * Configures an agent
  70070. */
  70071. export interface IAgentParameters {
  70072. /**
  70073. * Agent radius. [Limit: >= 0]
  70074. */
  70075. radius: number;
  70076. /**
  70077. * Agent height. [Limit: > 0]
  70078. */
  70079. height: number;
  70080. /**
  70081. * Maximum allowed acceleration. [Limit: >= 0]
  70082. */
  70083. maxAcceleration: number;
  70084. /**
  70085. * Maximum allowed speed. [Limit: >= 0]
  70086. */
  70087. maxSpeed: number;
  70088. /**
  70089. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70090. */
  70091. collisionQueryRange: number;
  70092. /**
  70093. * The path visibility optimization range. [Limit: > 0]
  70094. */
  70095. pathOptimizationRange: number;
  70096. /**
  70097. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70098. */
  70099. separationWeight: number;
  70100. }
  70101. /**
  70102. * Configures the navigation mesh creation
  70103. */
  70104. export interface INavMeshParameters {
  70105. /**
  70106. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70107. */
  70108. cs: number;
  70109. /**
  70110. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70111. */
  70112. ch: number;
  70113. /**
  70114. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70115. */
  70116. walkableSlopeAngle: number;
  70117. /**
  70118. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70119. * be considered walkable. [Limit: >= 3] [Units: vx]
  70120. */
  70121. walkableHeight: number;
  70122. /**
  70123. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70124. */
  70125. walkableClimb: number;
  70126. /**
  70127. * The distance to erode/shrink the walkable area of the heightfield away from
  70128. * obstructions. [Limit: >=0] [Units: vx]
  70129. */
  70130. walkableRadius: number;
  70131. /**
  70132. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70133. */
  70134. maxEdgeLen: number;
  70135. /**
  70136. * The maximum distance a simplfied contour's border edges should deviate
  70137. * the original raw contour. [Limit: >=0] [Units: vx]
  70138. */
  70139. maxSimplificationError: number;
  70140. /**
  70141. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70142. */
  70143. minRegionArea: number;
  70144. /**
  70145. * Any regions with a span count smaller than this value will, if possible,
  70146. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70147. */
  70148. mergeRegionArea: number;
  70149. /**
  70150. * The maximum number of vertices allowed for polygons generated during the
  70151. * contour to polygon conversion process. [Limit: >= 3]
  70152. */
  70153. maxVertsPerPoly: number;
  70154. /**
  70155. * Sets the sampling distance to use when generating the detail mesh.
  70156. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70157. */
  70158. detailSampleDist: number;
  70159. /**
  70160. * The maximum distance the detail mesh surface should deviate from heightfield
  70161. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70162. */
  70163. detailSampleMaxError: number;
  70164. }
  70165. }
  70166. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70167. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70168. import { Mesh } from "babylonjs/Meshes/mesh";
  70169. import { Scene } from "babylonjs/scene";
  70170. import { Vector3 } from "babylonjs/Maths/math";
  70171. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70172. /**
  70173. * RecastJS navigation plugin
  70174. */
  70175. export class RecastJSPlugin implements INavigationEnginePlugin {
  70176. /**
  70177. * Reference to the Recast library
  70178. */
  70179. bjsRECAST: any;
  70180. /**
  70181. * plugin name
  70182. */
  70183. name: string;
  70184. /**
  70185. * the first navmesh created. We might extend this to support multiple navmeshes
  70186. */
  70187. navMesh: any;
  70188. /**
  70189. * Initializes the recastJS plugin
  70190. * @param recastInjection can be used to inject your own recast reference
  70191. */
  70192. constructor(recastInjection?: any);
  70193. /**
  70194. * Creates a navigation mesh
  70195. * @param meshes array of all the geometry used to compute the navigatio mesh
  70196. * @param parameters bunch of parameters used to filter geometry
  70197. */
  70198. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70199. /**
  70200. * Create a navigation mesh debug mesh
  70201. * @param scene is where the mesh will be added
  70202. * @returns debug display mesh
  70203. */
  70204. createDebugNavMesh(scene: Scene): Mesh;
  70205. /**
  70206. * Get a navigation mesh constrained position, closest to the parameter position
  70207. * @param position world position
  70208. * @returns the closest point to position constrained by the navigation mesh
  70209. */
  70210. getClosestPoint(position: Vector3): Vector3;
  70211. /**
  70212. * Get a navigation mesh constrained position, closest to the parameter position
  70213. * @param position world position
  70214. * @param result output the closest point to position constrained by the navigation mesh
  70215. */
  70216. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70217. /**
  70218. * Get a navigation mesh constrained position, within a particular radius
  70219. * @param position world position
  70220. * @param maxRadius the maximum distance to the constrained world position
  70221. * @returns the closest point to position constrained by the navigation mesh
  70222. */
  70223. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70224. /**
  70225. * Get a navigation mesh constrained position, within a particular radius
  70226. * @param position world position
  70227. * @param maxRadius the maximum distance to the constrained world position
  70228. * @param result output the closest point to position constrained by the navigation mesh
  70229. */
  70230. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70231. /**
  70232. * Compute the final position from a segment made of destination-position
  70233. * @param position world position
  70234. * @param destination world position
  70235. * @returns the resulting point along the navmesh
  70236. */
  70237. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70238. /**
  70239. * Compute the final position from a segment made of destination-position
  70240. * @param position world position
  70241. * @param destination world position
  70242. * @param result output the resulting point along the navmesh
  70243. */
  70244. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70245. /**
  70246. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70247. * @param start world position
  70248. * @param end world position
  70249. * @returns array containing world position composing the path
  70250. */
  70251. computePath(start: Vector3, end: Vector3): Vector3[];
  70252. /**
  70253. * Create a new Crowd so you can add agents
  70254. * @param maxAgents the maximum agent count in the crowd
  70255. * @param maxAgentRadius the maximum radius an agent can have
  70256. * @param scene to attach the crowd to
  70257. * @returns the crowd you can add agents to
  70258. */
  70259. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70260. /**
  70261. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70262. * The queries will try to find a solution within those bounds
  70263. * default is (1,1,1)
  70264. * @param extent x,y,z value that define the extent around the queries point of reference
  70265. */
  70266. setDefaultQueryExtent(extent: Vector3): void;
  70267. /**
  70268. * Get the Bounding box extent specified by setDefaultQueryExtent
  70269. * @returns the box extent values
  70270. */
  70271. getDefaultQueryExtent(): Vector3;
  70272. /**
  70273. * build the navmesh from a previously saved state using getNavmeshData
  70274. * @param data the Uint8Array returned by getNavmeshData
  70275. */
  70276. buildFromNavmeshData(data: Uint8Array): void;
  70277. /**
  70278. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70279. * @returns data the Uint8Array that can be saved and reused
  70280. */
  70281. getNavmeshData(): Uint8Array;
  70282. /**
  70283. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70284. * @param result output the box extent values
  70285. */
  70286. getDefaultQueryExtentToRef(result: Vector3): void;
  70287. /**
  70288. * Disposes
  70289. */
  70290. dispose(): void;
  70291. /**
  70292. * If this plugin is supported
  70293. * @returns true if plugin is supported
  70294. */
  70295. isSupported(): boolean;
  70296. }
  70297. /**
  70298. * Recast detour crowd implementation
  70299. */
  70300. export class RecastJSCrowd implements ICrowd {
  70301. /**
  70302. * Recast/detour plugin
  70303. */
  70304. bjsRECASTPlugin: RecastJSPlugin;
  70305. /**
  70306. * Link to the detour crowd
  70307. */
  70308. recastCrowd: any;
  70309. /**
  70310. * One transform per agent
  70311. */
  70312. transforms: TransformNode[];
  70313. /**
  70314. * All agents created
  70315. */
  70316. agents: number[];
  70317. /**
  70318. * Link to the scene is kept to unregister the crowd from the scene
  70319. */
  70320. private _scene;
  70321. /**
  70322. * Observer for crowd updates
  70323. */
  70324. private _onBeforeAnimationsObserver;
  70325. /**
  70326. * Constructor
  70327. * @param plugin recastJS plugin
  70328. * @param maxAgents the maximum agent count in the crowd
  70329. * @param maxAgentRadius the maximum radius an agent can have
  70330. * @param scene to attach the crowd to
  70331. * @returns the crowd you can add agents to
  70332. */
  70333. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70334. /**
  70335. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70336. * You can attach anything to that node. The node position is updated in the scene update tick.
  70337. * @param pos world position that will be constrained by the navigation mesh
  70338. * @param parameters agent parameters
  70339. * @param transform hooked to the agent that will be update by the scene
  70340. * @returns agent index
  70341. */
  70342. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70343. /**
  70344. * Returns the agent position in world space
  70345. * @param index agent index returned by addAgent
  70346. * @returns world space position
  70347. */
  70348. getAgentPosition(index: number): Vector3;
  70349. /**
  70350. * Returns the agent position result in world space
  70351. * @param index agent index returned by addAgent
  70352. * @param result output world space position
  70353. */
  70354. getAgentPositionToRef(index: number, result: Vector3): void;
  70355. /**
  70356. * Returns the agent velocity in world space
  70357. * @param index agent index returned by addAgent
  70358. * @returns world space velocity
  70359. */
  70360. getAgentVelocity(index: number): Vector3;
  70361. /**
  70362. * Returns the agent velocity result in world space
  70363. * @param index agent index returned by addAgent
  70364. * @param result output world space velocity
  70365. */
  70366. getAgentVelocityToRef(index: number, result: Vector3): void;
  70367. /**
  70368. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70369. * @param index agent index returned by addAgent
  70370. * @param destination targeted world position
  70371. */
  70372. agentGoto(index: number, destination: Vector3): void;
  70373. /**
  70374. * Teleport the agent to a new position
  70375. * @param index agent index returned by addAgent
  70376. * @param destination targeted world position
  70377. */
  70378. agentTeleport(index: number, destination: Vector3): void;
  70379. /**
  70380. * Update agent parameters
  70381. * @param index agent index returned by addAgent
  70382. * @param parameters agent parameters
  70383. */
  70384. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70385. /**
  70386. * remove a particular agent previously created
  70387. * @param index agent index returned by addAgent
  70388. */
  70389. removeAgent(index: number): void;
  70390. /**
  70391. * get the list of all agents attached to this crowd
  70392. * @returns list of agent indices
  70393. */
  70394. getAgents(): number[];
  70395. /**
  70396. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70397. * @param deltaTime in seconds
  70398. */
  70399. update(deltaTime: number): void;
  70400. /**
  70401. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70402. * The queries will try to find a solution within those bounds
  70403. * default is (1,1,1)
  70404. * @param extent x,y,z value that define the extent around the queries point of reference
  70405. */
  70406. setDefaultQueryExtent(extent: Vector3): void;
  70407. /**
  70408. * Get the Bounding box extent specified by setDefaultQueryExtent
  70409. * @returns the box extent values
  70410. */
  70411. getDefaultQueryExtent(): Vector3;
  70412. /**
  70413. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70414. * @param result output the box extent values
  70415. */
  70416. getDefaultQueryExtentToRef(result: Vector3): void;
  70417. /**
  70418. * Release all resources
  70419. */
  70420. dispose(): void;
  70421. }
  70422. }
  70423. declare module "babylonjs/Navigation/Plugins/index" {
  70424. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70425. }
  70426. declare module "babylonjs/Navigation/index" {
  70427. export * from "babylonjs/Navigation/INavigationEngine";
  70428. export * from "babylonjs/Navigation/Plugins/index";
  70429. }
  70430. declare module "babylonjs/Offline/database" {
  70431. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70432. /**
  70433. * Class used to enable access to IndexedDB
  70434. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70435. */
  70436. export class Database implements IOfflineProvider {
  70437. private _callbackManifestChecked;
  70438. private _currentSceneUrl;
  70439. private _db;
  70440. private _enableSceneOffline;
  70441. private _enableTexturesOffline;
  70442. private _manifestVersionFound;
  70443. private _mustUpdateRessources;
  70444. private _hasReachedQuota;
  70445. private _isSupported;
  70446. private _idbFactory;
  70447. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70448. private static IsUASupportingBlobStorage;
  70449. /**
  70450. * Gets a boolean indicating if Database storate is enabled (off by default)
  70451. */
  70452. static IDBStorageEnabled: boolean;
  70453. /**
  70454. * Gets a boolean indicating if scene must be saved in the database
  70455. */
  70456. get enableSceneOffline(): boolean;
  70457. /**
  70458. * Gets a boolean indicating if textures must be saved in the database
  70459. */
  70460. get enableTexturesOffline(): boolean;
  70461. /**
  70462. * Creates a new Database
  70463. * @param urlToScene defines the url to load the scene
  70464. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70465. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70466. */
  70467. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70468. private static _ParseURL;
  70469. private static _ReturnFullUrlLocation;
  70470. private _checkManifestFile;
  70471. /**
  70472. * Open the database and make it available
  70473. * @param successCallback defines the callback to call on success
  70474. * @param errorCallback defines the callback to call on error
  70475. */
  70476. open(successCallback: () => void, errorCallback: () => void): void;
  70477. /**
  70478. * Loads an image from the database
  70479. * @param url defines the url to load from
  70480. * @param image defines the target DOM image
  70481. */
  70482. loadImage(url: string, image: HTMLImageElement): void;
  70483. private _loadImageFromDBAsync;
  70484. private _saveImageIntoDBAsync;
  70485. private _checkVersionFromDB;
  70486. private _loadVersionFromDBAsync;
  70487. private _saveVersionIntoDBAsync;
  70488. /**
  70489. * Loads a file from database
  70490. * @param url defines the URL to load from
  70491. * @param sceneLoaded defines a callback to call on success
  70492. * @param progressCallBack defines a callback to call when progress changed
  70493. * @param errorCallback defines a callback to call on error
  70494. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70495. */
  70496. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70497. private _loadFileAsync;
  70498. private _saveFileAsync;
  70499. /**
  70500. * Validates if xhr data is correct
  70501. * @param xhr defines the request to validate
  70502. * @param dataType defines the expected data type
  70503. * @returns true if data is correct
  70504. */
  70505. private static _ValidateXHRData;
  70506. }
  70507. }
  70508. declare module "babylonjs/Offline/index" {
  70509. export * from "babylonjs/Offline/database";
  70510. export * from "babylonjs/Offline/IOfflineProvider";
  70511. }
  70512. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70513. /** @hidden */
  70514. export var gpuUpdateParticlesPixelShader: {
  70515. name: string;
  70516. shader: string;
  70517. };
  70518. }
  70519. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70520. /** @hidden */
  70521. export var gpuUpdateParticlesVertexShader: {
  70522. name: string;
  70523. shader: string;
  70524. };
  70525. }
  70526. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70527. /** @hidden */
  70528. export var clipPlaneFragmentDeclaration2: {
  70529. name: string;
  70530. shader: string;
  70531. };
  70532. }
  70533. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70534. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70535. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70536. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70537. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70538. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70539. /** @hidden */
  70540. export var gpuRenderParticlesPixelShader: {
  70541. name: string;
  70542. shader: string;
  70543. };
  70544. }
  70545. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70546. /** @hidden */
  70547. export var clipPlaneVertexDeclaration2: {
  70548. name: string;
  70549. shader: string;
  70550. };
  70551. }
  70552. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70553. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70554. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70555. /** @hidden */
  70556. export var gpuRenderParticlesVertexShader: {
  70557. name: string;
  70558. shader: string;
  70559. };
  70560. }
  70561. declare module "babylonjs/Particles/gpuParticleSystem" {
  70562. import { Nullable } from "babylonjs/types";
  70563. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70564. import { Observable } from "babylonjs/Misc/observable";
  70565. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70566. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70567. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70568. import { Scene, IDisposable } from "babylonjs/scene";
  70569. import { Effect } from "babylonjs/Materials/effect";
  70570. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70571. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70572. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70573. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70574. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70575. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70576. /**
  70577. * This represents a GPU particle system in Babylon
  70578. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70579. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70580. */
  70581. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70582. /**
  70583. * The layer mask we are rendering the particles through.
  70584. */
  70585. layerMask: number;
  70586. private _capacity;
  70587. private _activeCount;
  70588. private _currentActiveCount;
  70589. private _accumulatedCount;
  70590. private _renderEffect;
  70591. private _updateEffect;
  70592. private _buffer0;
  70593. private _buffer1;
  70594. private _spriteBuffer;
  70595. private _updateVAO;
  70596. private _renderVAO;
  70597. private _targetIndex;
  70598. private _sourceBuffer;
  70599. private _targetBuffer;
  70600. private _engine;
  70601. private _currentRenderId;
  70602. private _started;
  70603. private _stopped;
  70604. private _timeDelta;
  70605. private _randomTexture;
  70606. private _randomTexture2;
  70607. private _attributesStrideSize;
  70608. private _updateEffectOptions;
  70609. private _randomTextureSize;
  70610. private _actualFrame;
  70611. private _customEffect;
  70612. private readonly _rawTextureWidth;
  70613. /**
  70614. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70615. */
  70616. static get IsSupported(): boolean;
  70617. /**
  70618. * An event triggered when the system is disposed.
  70619. */
  70620. onDisposeObservable: Observable<IParticleSystem>;
  70621. /**
  70622. * Gets the maximum number of particles active at the same time.
  70623. * @returns The max number of active particles.
  70624. */
  70625. getCapacity(): number;
  70626. /**
  70627. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70628. * to override the particles.
  70629. */
  70630. forceDepthWrite: boolean;
  70631. /**
  70632. * Gets or set the number of active particles
  70633. */
  70634. get activeParticleCount(): number;
  70635. set activeParticleCount(value: number);
  70636. private _preWarmDone;
  70637. /**
  70638. * Specifies if the particles are updated in emitter local space or world space.
  70639. */
  70640. isLocal: boolean;
  70641. /**
  70642. * Is this system ready to be used/rendered
  70643. * @return true if the system is ready
  70644. */
  70645. isReady(): boolean;
  70646. /**
  70647. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70648. * @returns True if it has been started, otherwise false.
  70649. */
  70650. isStarted(): boolean;
  70651. /**
  70652. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70653. * @returns True if it has been stopped, otherwise false.
  70654. */
  70655. isStopped(): boolean;
  70656. /**
  70657. * Gets a boolean indicating that the system is stopping
  70658. * @returns true if the system is currently stopping
  70659. */
  70660. isStopping(): boolean;
  70661. /**
  70662. * Gets the number of particles active at the same time.
  70663. * @returns The number of active particles.
  70664. */
  70665. getActiveCount(): number;
  70666. /**
  70667. * Starts the particle system and begins to emit
  70668. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70669. */
  70670. start(delay?: number): void;
  70671. /**
  70672. * Stops the particle system.
  70673. */
  70674. stop(): void;
  70675. /**
  70676. * Remove all active particles
  70677. */
  70678. reset(): void;
  70679. /**
  70680. * Returns the string "GPUParticleSystem"
  70681. * @returns a string containing the class name
  70682. */
  70683. getClassName(): string;
  70684. /**
  70685. * Gets the custom effect used to render the particles
  70686. * @param blendMode Blend mode for which the effect should be retrieved
  70687. * @returns The effect
  70688. */
  70689. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70690. /**
  70691. * Sets the custom effect used to render the particles
  70692. * @param effect The effect to set
  70693. * @param blendMode Blend mode for which the effect should be set
  70694. */
  70695. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70696. /** @hidden */
  70697. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70698. /**
  70699. * Observable that will be called just before the particles are drawn
  70700. */
  70701. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70702. /**
  70703. * Gets the name of the particle vertex shader
  70704. */
  70705. get vertexShaderName(): string;
  70706. private _colorGradientsTexture;
  70707. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70708. /**
  70709. * Adds a new color gradient
  70710. * @param gradient defines the gradient to use (between 0 and 1)
  70711. * @param color1 defines the color to affect to the specified gradient
  70712. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70713. * @returns the current particle system
  70714. */
  70715. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70716. private _refreshColorGradient;
  70717. /** Force the system to rebuild all gradients that need to be resync */
  70718. forceRefreshGradients(): void;
  70719. /**
  70720. * Remove a specific color gradient
  70721. * @param gradient defines the gradient to remove
  70722. * @returns the current particle system
  70723. */
  70724. removeColorGradient(gradient: number): GPUParticleSystem;
  70725. private _angularSpeedGradientsTexture;
  70726. private _sizeGradientsTexture;
  70727. private _velocityGradientsTexture;
  70728. private _limitVelocityGradientsTexture;
  70729. private _dragGradientsTexture;
  70730. private _addFactorGradient;
  70731. /**
  70732. * Adds a new size gradient
  70733. * @param gradient defines the gradient to use (between 0 and 1)
  70734. * @param factor defines the size factor to affect to the specified gradient
  70735. * @returns the current particle system
  70736. */
  70737. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70738. /**
  70739. * Remove a specific size gradient
  70740. * @param gradient defines the gradient to remove
  70741. * @returns the current particle system
  70742. */
  70743. removeSizeGradient(gradient: number): GPUParticleSystem;
  70744. private _refreshFactorGradient;
  70745. /**
  70746. * Adds a new angular speed gradient
  70747. * @param gradient defines the gradient to use (between 0 and 1)
  70748. * @param factor defines the angular speed to affect to the specified gradient
  70749. * @returns the current particle system
  70750. */
  70751. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70752. /**
  70753. * Remove a specific angular speed gradient
  70754. * @param gradient defines the gradient to remove
  70755. * @returns the current particle system
  70756. */
  70757. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70758. /**
  70759. * Adds a new velocity gradient
  70760. * @param gradient defines the gradient to use (between 0 and 1)
  70761. * @param factor defines the velocity to affect to the specified gradient
  70762. * @returns the current particle system
  70763. */
  70764. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70765. /**
  70766. * Remove a specific velocity gradient
  70767. * @param gradient defines the gradient to remove
  70768. * @returns the current particle system
  70769. */
  70770. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70771. /**
  70772. * Adds a new limit velocity gradient
  70773. * @param gradient defines the gradient to use (between 0 and 1)
  70774. * @param factor defines the limit velocity value to affect to the specified gradient
  70775. * @returns the current particle system
  70776. */
  70777. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70778. /**
  70779. * Remove a specific limit velocity gradient
  70780. * @param gradient defines the gradient to remove
  70781. * @returns the current particle system
  70782. */
  70783. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70784. /**
  70785. * Adds a new drag gradient
  70786. * @param gradient defines the gradient to use (between 0 and 1)
  70787. * @param factor defines the drag value to affect to the specified gradient
  70788. * @returns the current particle system
  70789. */
  70790. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70791. /**
  70792. * Remove a specific drag gradient
  70793. * @param gradient defines the gradient to remove
  70794. * @returns the current particle system
  70795. */
  70796. removeDragGradient(gradient: number): GPUParticleSystem;
  70797. /**
  70798. * Not supported by GPUParticleSystem
  70799. * @param gradient defines the gradient to use (between 0 and 1)
  70800. * @param factor defines the emit rate value to affect to the specified gradient
  70801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70802. * @returns the current particle system
  70803. */
  70804. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70805. /**
  70806. * Not supported by GPUParticleSystem
  70807. * @param gradient defines the gradient to remove
  70808. * @returns the current particle system
  70809. */
  70810. removeEmitRateGradient(gradient: number): IParticleSystem;
  70811. /**
  70812. * Not supported by GPUParticleSystem
  70813. * @param gradient defines the gradient to use (between 0 and 1)
  70814. * @param factor defines the start size value to affect to the specified gradient
  70815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70816. * @returns the current particle system
  70817. */
  70818. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70819. /**
  70820. * Not supported by GPUParticleSystem
  70821. * @param gradient defines the gradient to remove
  70822. * @returns the current particle system
  70823. */
  70824. removeStartSizeGradient(gradient: number): IParticleSystem;
  70825. /**
  70826. * Not supported by GPUParticleSystem
  70827. * @param gradient defines the gradient to use (between 0 and 1)
  70828. * @param min defines the color remap minimal range
  70829. * @param max defines the color remap maximal range
  70830. * @returns the current particle system
  70831. */
  70832. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70833. /**
  70834. * Not supported by GPUParticleSystem
  70835. * @param gradient defines the gradient to remove
  70836. * @returns the current particle system
  70837. */
  70838. removeColorRemapGradient(): IParticleSystem;
  70839. /**
  70840. * Not supported by GPUParticleSystem
  70841. * @param gradient defines the gradient to use (between 0 and 1)
  70842. * @param min defines the alpha remap minimal range
  70843. * @param max defines the alpha remap maximal range
  70844. * @returns the current particle system
  70845. */
  70846. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70847. /**
  70848. * Not supported by GPUParticleSystem
  70849. * @param gradient defines the gradient to remove
  70850. * @returns the current particle system
  70851. */
  70852. removeAlphaRemapGradient(): IParticleSystem;
  70853. /**
  70854. * Not supported by GPUParticleSystem
  70855. * @param gradient defines the gradient to use (between 0 and 1)
  70856. * @param color defines the color to affect to the specified gradient
  70857. * @returns the current particle system
  70858. */
  70859. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70860. /**
  70861. * Not supported by GPUParticleSystem
  70862. * @param gradient defines the gradient to remove
  70863. * @returns the current particle system
  70864. */
  70865. removeRampGradient(): IParticleSystem;
  70866. /**
  70867. * Not supported by GPUParticleSystem
  70868. * @returns the list of ramp gradients
  70869. */
  70870. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70871. /**
  70872. * Not supported by GPUParticleSystem
  70873. * Gets or sets a boolean indicating that ramp gradients must be used
  70874. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70875. */
  70876. get useRampGradients(): boolean;
  70877. set useRampGradients(value: boolean);
  70878. /**
  70879. * Not supported by GPUParticleSystem
  70880. * @param gradient defines the gradient to use (between 0 and 1)
  70881. * @param factor defines the life time factor to affect to the specified gradient
  70882. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70883. * @returns the current particle system
  70884. */
  70885. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70886. /**
  70887. * Not supported by GPUParticleSystem
  70888. * @param gradient defines the gradient to remove
  70889. * @returns the current particle system
  70890. */
  70891. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70892. /**
  70893. * Instantiates a GPU particle system.
  70894. * 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.
  70895. * @param name The name of the particle system
  70896. * @param options The options used to create the system
  70897. * @param scene The scene the particle system belongs to
  70898. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70899. * @param customEffect a custom effect used to change the way particles are rendered by default
  70900. */
  70901. constructor(name: string, options: Partial<{
  70902. capacity: number;
  70903. randomTextureSize: number;
  70904. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70905. protected _reset(): void;
  70906. private _createUpdateVAO;
  70907. private _createRenderVAO;
  70908. private _initialize;
  70909. /** @hidden */
  70910. _recreateUpdateEffect(): void;
  70911. private _getEffect;
  70912. /**
  70913. * Fill the defines array according to the current settings of the particle system
  70914. * @param defines Array to be updated
  70915. * @param blendMode blend mode to take into account when updating the array
  70916. */
  70917. fillDefines(defines: Array<string>, blendMode?: number): void;
  70918. /**
  70919. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70920. * @param uniforms Uniforms array to fill
  70921. * @param attributes Attributes array to fill
  70922. * @param samplers Samplers array to fill
  70923. */
  70924. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70925. /** @hidden */
  70926. _recreateRenderEffect(): Effect;
  70927. /**
  70928. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70929. * @param preWarm defines if we are in the pre-warmimg phase
  70930. */
  70931. animate(preWarm?: boolean): void;
  70932. private _createFactorGradientTexture;
  70933. private _createSizeGradientTexture;
  70934. private _createAngularSpeedGradientTexture;
  70935. private _createVelocityGradientTexture;
  70936. private _createLimitVelocityGradientTexture;
  70937. private _createDragGradientTexture;
  70938. private _createColorGradientTexture;
  70939. /**
  70940. * Renders the particle system in its current state
  70941. * @param preWarm defines if the system should only update the particles but not render them
  70942. * @returns the current number of particles
  70943. */
  70944. render(preWarm?: boolean): number;
  70945. /**
  70946. * Rebuilds the particle system
  70947. */
  70948. rebuild(): void;
  70949. private _releaseBuffers;
  70950. private _releaseVAOs;
  70951. /**
  70952. * Disposes the particle system and free the associated resources
  70953. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70954. */
  70955. dispose(disposeTexture?: boolean): void;
  70956. /**
  70957. * Clones the particle system.
  70958. * @param name The name of the cloned object
  70959. * @param newEmitter The new emitter to use
  70960. * @returns the cloned particle system
  70961. */
  70962. clone(name: string, newEmitter: any): GPUParticleSystem;
  70963. /**
  70964. * Serializes the particle system to a JSON object
  70965. * @param serializeTexture defines if the texture must be serialized as well
  70966. * @returns the JSON object
  70967. */
  70968. serialize(serializeTexture?: boolean): any;
  70969. /**
  70970. * Parses a JSON object to create a GPU particle system.
  70971. * @param parsedParticleSystem The JSON object to parse
  70972. * @param scene The scene to create the particle system in
  70973. * @param rootUrl The root url to use to load external dependencies like texture
  70974. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70975. * @returns the parsed GPU particle system
  70976. */
  70977. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70978. }
  70979. }
  70980. declare module "babylonjs/Particles/particleSystemSet" {
  70981. import { Nullable } from "babylonjs/types";
  70982. import { Color3 } from "babylonjs/Maths/math.color";
  70983. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70985. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70986. import { Scene, IDisposable } from "babylonjs/scene";
  70987. /**
  70988. * Represents a set of particle systems working together to create a specific effect
  70989. */
  70990. export class ParticleSystemSet implements IDisposable {
  70991. /**
  70992. * Gets or sets base Assets URL
  70993. */
  70994. static BaseAssetsUrl: string;
  70995. private _emitterCreationOptions;
  70996. private _emitterNode;
  70997. /**
  70998. * Gets the particle system list
  70999. */
  71000. systems: IParticleSystem[];
  71001. /**
  71002. * Gets the emitter node used with this set
  71003. */
  71004. get emitterNode(): Nullable<TransformNode>;
  71005. /**
  71006. * Creates a new emitter mesh as a sphere
  71007. * @param options defines the options used to create the sphere
  71008. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71009. * @param scene defines the hosting scene
  71010. */
  71011. setEmitterAsSphere(options: {
  71012. diameter: number;
  71013. segments: number;
  71014. color: Color3;
  71015. }, renderingGroupId: number, scene: Scene): void;
  71016. /**
  71017. * Starts all particle systems of the set
  71018. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71019. */
  71020. start(emitter?: AbstractMesh): void;
  71021. /**
  71022. * Release all associated resources
  71023. */
  71024. dispose(): void;
  71025. /**
  71026. * Serialize the set into a JSON compatible object
  71027. * @param serializeTexture defines if the texture must be serialized as well
  71028. * @returns a JSON compatible representation of the set
  71029. */
  71030. serialize(serializeTexture?: boolean): any;
  71031. /**
  71032. * Parse a new ParticleSystemSet from a serialized source
  71033. * @param data defines a JSON compatible representation of the set
  71034. * @param scene defines the hosting scene
  71035. * @param gpu defines if we want GPU particles or CPU particles
  71036. * @returns a new ParticleSystemSet
  71037. */
  71038. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71039. }
  71040. }
  71041. declare module "babylonjs/Particles/particleHelper" {
  71042. import { Nullable } from "babylonjs/types";
  71043. import { Scene } from "babylonjs/scene";
  71044. import { Vector3 } from "babylonjs/Maths/math.vector";
  71045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71046. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71047. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71048. /**
  71049. * This class is made for on one-liner static method to help creating particle system set.
  71050. */
  71051. export class ParticleHelper {
  71052. /**
  71053. * Gets or sets base Assets URL
  71054. */
  71055. static BaseAssetsUrl: string;
  71056. /** Define the Url to load snippets */
  71057. static SnippetUrl: string;
  71058. /**
  71059. * Create a default particle system that you can tweak
  71060. * @param emitter defines the emitter to use
  71061. * @param capacity defines the system capacity (default is 500 particles)
  71062. * @param scene defines the hosting scene
  71063. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71064. * @returns the new Particle system
  71065. */
  71066. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71067. /**
  71068. * This is the main static method (one-liner) of this helper to create different particle systems
  71069. * @param type This string represents the type to the particle system to create
  71070. * @param scene The scene where the particle system should live
  71071. * @param gpu If the system will use gpu
  71072. * @returns the ParticleSystemSet created
  71073. */
  71074. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71075. /**
  71076. * Static function used to export a particle system to a ParticleSystemSet variable.
  71077. * Please note that the emitter shape is not exported
  71078. * @param systems defines the particle systems to export
  71079. * @returns the created particle system set
  71080. */
  71081. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71082. /**
  71083. * Creates a particle system from a snippet saved in a remote file
  71084. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71085. * @param url defines the url to load from
  71086. * @param scene defines the hosting scene
  71087. * @param gpu If the system will use gpu
  71088. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71089. * @returns a promise that will resolve to the new particle system
  71090. */
  71091. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71092. /**
  71093. * Creates a particle system from a snippet saved by the particle system editor
  71094. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71095. * @param scene defines the hosting scene
  71096. * @param gpu If the system will use gpu
  71097. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71098. * @returns a promise that will resolve to the new particle system
  71099. */
  71100. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71101. }
  71102. }
  71103. declare module "babylonjs/Particles/particleSystemComponent" {
  71104. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71105. import { Effect } from "babylonjs/Materials/effect";
  71106. import "babylonjs/Shaders/particles.vertex";
  71107. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71108. module "babylonjs/Engines/engine" {
  71109. interface Engine {
  71110. /**
  71111. * Create an effect to use with particle systems.
  71112. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71113. * the particle system for which you want to create a custom effect in the last parameter
  71114. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71115. * @param uniformsNames defines a list of attribute names
  71116. * @param samplers defines an array of string used to represent textures
  71117. * @param defines defines the string containing the defines to use to compile the shaders
  71118. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71119. * @param onCompiled defines a function to call when the effect creation is successful
  71120. * @param onError defines a function to call when the effect creation has failed
  71121. * @param particleSystem the particle system you want to create the effect for
  71122. * @returns the new Effect
  71123. */
  71124. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71125. }
  71126. }
  71127. module "babylonjs/Meshes/mesh" {
  71128. interface Mesh {
  71129. /**
  71130. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71131. * @returns an array of IParticleSystem
  71132. */
  71133. getEmittedParticleSystems(): IParticleSystem[];
  71134. /**
  71135. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71136. * @returns an array of IParticleSystem
  71137. */
  71138. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71139. }
  71140. }
  71141. }
  71142. declare module "babylonjs/Particles/pointsCloudSystem" {
  71143. import { Color4 } from "babylonjs/Maths/math";
  71144. import { Mesh } from "babylonjs/Meshes/mesh";
  71145. import { Scene, IDisposable } from "babylonjs/scene";
  71146. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71147. /** Defines the 4 color options */
  71148. export enum PointColor {
  71149. /** color value */
  71150. Color = 2,
  71151. /** uv value */
  71152. UV = 1,
  71153. /** random value */
  71154. Random = 0,
  71155. /** stated value */
  71156. Stated = 3
  71157. }
  71158. /**
  71159. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71160. * 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.
  71161. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71162. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71163. *
  71164. * Full documentation here : TO BE ENTERED
  71165. */
  71166. export class PointsCloudSystem implements IDisposable {
  71167. /**
  71168. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71169. * Example : var p = SPS.particles[i];
  71170. */
  71171. particles: CloudPoint[];
  71172. /**
  71173. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71174. */
  71175. nbParticles: number;
  71176. /**
  71177. * This a counter for your own usage. It's not set by any SPS functions.
  71178. */
  71179. counter: number;
  71180. /**
  71181. * The PCS name. This name is also given to the underlying mesh.
  71182. */
  71183. name: string;
  71184. /**
  71185. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71186. */
  71187. mesh: Mesh;
  71188. /**
  71189. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71190. * Please read :
  71191. */
  71192. vars: any;
  71193. /**
  71194. * @hidden
  71195. */
  71196. _size: number;
  71197. private _scene;
  71198. private _promises;
  71199. private _positions;
  71200. private _indices;
  71201. private _normals;
  71202. private _colors;
  71203. private _uvs;
  71204. private _indices32;
  71205. private _positions32;
  71206. private _colors32;
  71207. private _uvs32;
  71208. private _updatable;
  71209. private _isVisibilityBoxLocked;
  71210. private _alwaysVisible;
  71211. private _groups;
  71212. private _groupCounter;
  71213. private _computeParticleColor;
  71214. private _computeParticleTexture;
  71215. private _computeParticleRotation;
  71216. private _computeBoundingBox;
  71217. private _isReady;
  71218. /**
  71219. * Creates a PCS (Points Cloud System) object
  71220. * @param name (String) is the PCS name, this will be the underlying mesh name
  71221. * @param pointSize (number) is the size for each point
  71222. * @param scene (Scene) is the scene in which the PCS is added
  71223. * @param options defines the options of the PCS e.g.
  71224. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71225. */
  71226. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71227. updatable?: boolean;
  71228. });
  71229. /**
  71230. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71231. * If no points were added to the PCS, the returned mesh is just a single point.
  71232. * @returns a promise for the created mesh
  71233. */
  71234. buildMeshAsync(): Promise<Mesh>;
  71235. /**
  71236. * @hidden
  71237. */
  71238. private _buildMesh;
  71239. private _addParticle;
  71240. private _randomUnitVector;
  71241. private _getColorIndicesForCoord;
  71242. private _setPointsColorOrUV;
  71243. private _colorFromTexture;
  71244. private _calculateDensity;
  71245. /**
  71246. * Adds points to the PCS in random positions within a unit sphere
  71247. * @param nb (positive integer) the number of particles to be created from this model
  71248. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71249. * @returns the number of groups in the system
  71250. */
  71251. addPoints(nb: number, pointFunction?: any): number;
  71252. /**
  71253. * Adds points to the PCS from the surface of the model shape
  71254. * @param mesh is any Mesh object that will be used as a surface model for the points
  71255. * @param nb (positive integer) the number of particles to be created from this model
  71256. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71257. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71258. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71259. * @returns the number of groups in the system
  71260. */
  71261. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71262. /**
  71263. * Adds points to the PCS inside the model shape
  71264. * @param mesh is any Mesh object that will be used as a surface model for the points
  71265. * @param nb (positive integer) the number of particles to be created from this model
  71266. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71267. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71268. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71269. * @returns the number of groups in the system
  71270. */
  71271. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71272. /**
  71273. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71274. * This method calls `updateParticle()` for each particle of the SPS.
  71275. * For an animated SPS, it is usually called within the render loop.
  71276. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71277. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71278. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71279. * @returns the PCS.
  71280. */
  71281. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71282. /**
  71283. * Disposes the PCS.
  71284. */
  71285. dispose(): void;
  71286. /**
  71287. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71288. * doc :
  71289. * @returns the PCS.
  71290. */
  71291. refreshVisibleSize(): PointsCloudSystem;
  71292. /**
  71293. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71294. * @param size the size (float) of the visibility box
  71295. * note : this doesn't lock the PCS mesh bounding box.
  71296. * doc :
  71297. */
  71298. setVisibilityBox(size: number): void;
  71299. /**
  71300. * Gets whether the PCS is always visible or not
  71301. * doc :
  71302. */
  71303. get isAlwaysVisible(): boolean;
  71304. /**
  71305. * Sets the PCS as always visible or not
  71306. * doc :
  71307. */
  71308. set isAlwaysVisible(val: boolean);
  71309. /**
  71310. * Tells to `setParticles()` to compute the particle rotations or not
  71311. * Default value : false. The PCS is faster when it's set to false
  71312. * Note : particle rotations are only applied to parent particles
  71313. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71314. */
  71315. set computeParticleRotation(val: boolean);
  71316. /**
  71317. * Tells to `setParticles()` to compute the particle colors or not.
  71318. * Default value : true. The PCS is faster when it's set to false.
  71319. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71320. */
  71321. set computeParticleColor(val: boolean);
  71322. set computeParticleTexture(val: boolean);
  71323. /**
  71324. * Gets if `setParticles()` computes the particle colors or not.
  71325. * Default value : false. The PCS is faster when it's set to false.
  71326. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71327. */
  71328. get computeParticleColor(): boolean;
  71329. /**
  71330. * Gets if `setParticles()` computes the particle textures or not.
  71331. * Default value : false. The PCS is faster when it's set to false.
  71332. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71333. */
  71334. get computeParticleTexture(): boolean;
  71335. /**
  71336. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71337. */
  71338. set computeBoundingBox(val: boolean);
  71339. /**
  71340. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71341. */
  71342. get computeBoundingBox(): boolean;
  71343. /**
  71344. * This function does nothing. It may be overwritten to set all the particle first values.
  71345. * The PCS doesn't call this function, you may have to call it by your own.
  71346. * doc :
  71347. */
  71348. initParticles(): void;
  71349. /**
  71350. * This function does nothing. It may be overwritten to recycle a particle
  71351. * The PCS doesn't call this function, you can to call it
  71352. * doc :
  71353. * @param particle The particle to recycle
  71354. * @returns the recycled particle
  71355. */
  71356. recycleParticle(particle: CloudPoint): CloudPoint;
  71357. /**
  71358. * Updates a particle : this function should be overwritten by the user.
  71359. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71360. * doc :
  71361. * @example : just set a particle position or velocity and recycle conditions
  71362. * @param particle The particle to update
  71363. * @returns the updated particle
  71364. */
  71365. updateParticle(particle: CloudPoint): CloudPoint;
  71366. /**
  71367. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71368. * This does nothing and may be overwritten by the user.
  71369. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71370. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71371. * @param update the boolean update value actually passed to setParticles()
  71372. */
  71373. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71374. /**
  71375. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71376. * This will be passed three parameters.
  71377. * This does nothing and may be overwritten by the user.
  71378. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71379. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71380. * @param update the boolean update value actually passed to setParticles()
  71381. */
  71382. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71383. }
  71384. }
  71385. declare module "babylonjs/Particles/cloudPoint" {
  71386. import { Nullable } from "babylonjs/types";
  71387. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71388. import { Mesh } from "babylonjs/Meshes/mesh";
  71389. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71390. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71391. /**
  71392. * Represents one particle of a points cloud system.
  71393. */
  71394. export class CloudPoint {
  71395. /**
  71396. * particle global index
  71397. */
  71398. idx: number;
  71399. /**
  71400. * The color of the particle
  71401. */
  71402. color: Nullable<Color4>;
  71403. /**
  71404. * The world space position of the particle.
  71405. */
  71406. position: Vector3;
  71407. /**
  71408. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71409. */
  71410. rotation: Vector3;
  71411. /**
  71412. * The world space rotation quaternion of the particle.
  71413. */
  71414. rotationQuaternion: Nullable<Quaternion>;
  71415. /**
  71416. * The uv of the particle.
  71417. */
  71418. uv: Nullable<Vector2>;
  71419. /**
  71420. * The current speed of the particle.
  71421. */
  71422. velocity: Vector3;
  71423. /**
  71424. * The pivot point in the particle local space.
  71425. */
  71426. pivot: Vector3;
  71427. /**
  71428. * Must the particle be translated from its pivot point in its local space ?
  71429. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71430. * Default : false
  71431. */
  71432. translateFromPivot: boolean;
  71433. /**
  71434. * Index of this particle in the global "positions" array (Internal use)
  71435. * @hidden
  71436. */
  71437. _pos: number;
  71438. /**
  71439. * @hidden Index of this particle in the global "indices" array (Internal use)
  71440. */
  71441. _ind: number;
  71442. /**
  71443. * Group this particle belongs to
  71444. */
  71445. _group: PointsGroup;
  71446. /**
  71447. * Group id of this particle
  71448. */
  71449. groupId: number;
  71450. /**
  71451. * Index of the particle in its group id (Internal use)
  71452. */
  71453. idxInGroup: number;
  71454. /**
  71455. * @hidden Particle BoundingInfo object (Internal use)
  71456. */
  71457. _boundingInfo: BoundingInfo;
  71458. /**
  71459. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71460. */
  71461. _pcs: PointsCloudSystem;
  71462. /**
  71463. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71464. */
  71465. _stillInvisible: boolean;
  71466. /**
  71467. * @hidden Last computed particle rotation matrix
  71468. */
  71469. _rotationMatrix: number[];
  71470. /**
  71471. * Parent particle Id, if any.
  71472. * Default null.
  71473. */
  71474. parentId: Nullable<number>;
  71475. /**
  71476. * @hidden Internal global position in the PCS.
  71477. */
  71478. _globalPosition: Vector3;
  71479. /**
  71480. * Creates a Point Cloud object.
  71481. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71482. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71483. * @param group (PointsGroup) is the group the particle belongs to
  71484. * @param groupId (integer) is the group identifier in the PCS.
  71485. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71486. * @param pcs defines the PCS it is associated to
  71487. */
  71488. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71489. /**
  71490. * get point size
  71491. */
  71492. get size(): Vector3;
  71493. /**
  71494. * Set point size
  71495. */
  71496. set size(scale: Vector3);
  71497. /**
  71498. * Legacy support, changed quaternion to rotationQuaternion
  71499. */
  71500. get quaternion(): Nullable<Quaternion>;
  71501. /**
  71502. * Legacy support, changed quaternion to rotationQuaternion
  71503. */
  71504. set quaternion(q: Nullable<Quaternion>);
  71505. /**
  71506. * Returns a boolean. True if the particle intersects a mesh, else false
  71507. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71508. * @param target is the object (point or mesh) what the intersection is computed against
  71509. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71510. * @returns true if it intersects
  71511. */
  71512. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71513. /**
  71514. * get the rotation matrix of the particle
  71515. * @hidden
  71516. */
  71517. getRotationMatrix(m: Matrix): void;
  71518. }
  71519. /**
  71520. * Represents a group of points in a points cloud system
  71521. * * PCS internal tool, don't use it manually.
  71522. */
  71523. export class PointsGroup {
  71524. /**
  71525. * The group id
  71526. * @hidden
  71527. */
  71528. groupID: number;
  71529. /**
  71530. * image data for group (internal use)
  71531. * @hidden
  71532. */
  71533. _groupImageData: Nullable<ArrayBufferView>;
  71534. /**
  71535. * Image Width (internal use)
  71536. * @hidden
  71537. */
  71538. _groupImgWidth: number;
  71539. /**
  71540. * Image Height (internal use)
  71541. * @hidden
  71542. */
  71543. _groupImgHeight: number;
  71544. /**
  71545. * Custom position function (internal use)
  71546. * @hidden
  71547. */
  71548. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71549. /**
  71550. * density per facet for surface points
  71551. * @hidden
  71552. */
  71553. _groupDensity: number[];
  71554. /**
  71555. * Only when points are colored by texture carries pointer to texture list array
  71556. * @hidden
  71557. */
  71558. _textureNb: number;
  71559. /**
  71560. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71561. * PCS internal tool, don't use it manually.
  71562. * @hidden
  71563. */
  71564. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71565. }
  71566. }
  71567. declare module "babylonjs/Particles/index" {
  71568. export * from "babylonjs/Particles/baseParticleSystem";
  71569. export * from "babylonjs/Particles/EmitterTypes/index";
  71570. export * from "babylonjs/Particles/gpuParticleSystem";
  71571. export * from "babylonjs/Particles/IParticleSystem";
  71572. export * from "babylonjs/Particles/particle";
  71573. export * from "babylonjs/Particles/particleHelper";
  71574. export * from "babylonjs/Particles/particleSystem";
  71575. import "babylonjs/Particles/particleSystemComponent";
  71576. export * from "babylonjs/Particles/particleSystemComponent";
  71577. export * from "babylonjs/Particles/particleSystemSet";
  71578. export * from "babylonjs/Particles/solidParticle";
  71579. export * from "babylonjs/Particles/solidParticleSystem";
  71580. export * from "babylonjs/Particles/cloudPoint";
  71581. export * from "babylonjs/Particles/pointsCloudSystem";
  71582. export * from "babylonjs/Particles/subEmitter";
  71583. }
  71584. declare module "babylonjs/Physics/physicsEngineComponent" {
  71585. import { Nullable } from "babylonjs/types";
  71586. import { Observable, Observer } from "babylonjs/Misc/observable";
  71587. import { Vector3 } from "babylonjs/Maths/math.vector";
  71588. import { Mesh } from "babylonjs/Meshes/mesh";
  71589. import { ISceneComponent } from "babylonjs/sceneComponent";
  71590. import { Scene } from "babylonjs/scene";
  71591. import { Node } from "babylonjs/node";
  71592. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71593. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71594. module "babylonjs/scene" {
  71595. interface Scene {
  71596. /** @hidden (Backing field) */
  71597. _physicsEngine: Nullable<IPhysicsEngine>;
  71598. /** @hidden */
  71599. _physicsTimeAccumulator: number;
  71600. /**
  71601. * Gets the current physics engine
  71602. * @returns a IPhysicsEngine or null if none attached
  71603. */
  71604. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71605. /**
  71606. * Enables physics to the current scene
  71607. * @param gravity defines the scene's gravity for the physics engine
  71608. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71609. * @return a boolean indicating if the physics engine was initialized
  71610. */
  71611. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71612. /**
  71613. * Disables and disposes the physics engine associated with the scene
  71614. */
  71615. disablePhysicsEngine(): void;
  71616. /**
  71617. * Gets a boolean indicating if there is an active physics engine
  71618. * @returns a boolean indicating if there is an active physics engine
  71619. */
  71620. isPhysicsEnabled(): boolean;
  71621. /**
  71622. * Deletes a physics compound impostor
  71623. * @param compound defines the compound to delete
  71624. */
  71625. deleteCompoundImpostor(compound: any): void;
  71626. /**
  71627. * An event triggered when physic simulation is about to be run
  71628. */
  71629. onBeforePhysicsObservable: Observable<Scene>;
  71630. /**
  71631. * An event triggered when physic simulation has been done
  71632. */
  71633. onAfterPhysicsObservable: Observable<Scene>;
  71634. }
  71635. }
  71636. module "babylonjs/Meshes/abstractMesh" {
  71637. interface AbstractMesh {
  71638. /** @hidden */
  71639. _physicsImpostor: Nullable<PhysicsImpostor>;
  71640. /**
  71641. * Gets or sets impostor used for physic simulation
  71642. * @see https://doc.babylonjs.com/features/physics_engine
  71643. */
  71644. physicsImpostor: Nullable<PhysicsImpostor>;
  71645. /**
  71646. * Gets the current physics impostor
  71647. * @see https://doc.babylonjs.com/features/physics_engine
  71648. * @returns a physics impostor or null
  71649. */
  71650. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71651. /** Apply a physic impulse to the mesh
  71652. * @param force defines the force to apply
  71653. * @param contactPoint defines where to apply the force
  71654. * @returns the current mesh
  71655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71656. */
  71657. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71658. /**
  71659. * Creates a physic joint between two meshes
  71660. * @param otherMesh defines the other mesh to use
  71661. * @param pivot1 defines the pivot to use on this mesh
  71662. * @param pivot2 defines the pivot to use on the other mesh
  71663. * @param options defines additional options (can be plugin dependent)
  71664. * @returns the current mesh
  71665. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71666. */
  71667. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71668. /** @hidden */
  71669. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71670. }
  71671. }
  71672. /**
  71673. * Defines the physics engine scene component responsible to manage a physics engine
  71674. */
  71675. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71676. /**
  71677. * The component name helpful to identify the component in the list of scene components.
  71678. */
  71679. readonly name: string;
  71680. /**
  71681. * The scene the component belongs to.
  71682. */
  71683. scene: Scene;
  71684. /**
  71685. * Creates a new instance of the component for the given scene
  71686. * @param scene Defines the scene to register the component in
  71687. */
  71688. constructor(scene: Scene);
  71689. /**
  71690. * Registers the component in a given scene
  71691. */
  71692. register(): void;
  71693. /**
  71694. * Rebuilds the elements related to this component in case of
  71695. * context lost for instance.
  71696. */
  71697. rebuild(): void;
  71698. /**
  71699. * Disposes the component and the associated ressources
  71700. */
  71701. dispose(): void;
  71702. }
  71703. }
  71704. declare module "babylonjs/Physics/physicsHelper" {
  71705. import { Nullable } from "babylonjs/types";
  71706. import { Vector3 } from "babylonjs/Maths/math.vector";
  71707. import { Mesh } from "babylonjs/Meshes/mesh";
  71708. import { Scene } from "babylonjs/scene";
  71709. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71710. /**
  71711. * A helper for physics simulations
  71712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71713. */
  71714. export class PhysicsHelper {
  71715. private _scene;
  71716. private _physicsEngine;
  71717. /**
  71718. * Initializes the Physics helper
  71719. * @param scene Babylon.js scene
  71720. */
  71721. constructor(scene: Scene);
  71722. /**
  71723. * Applies a radial explosion impulse
  71724. * @param origin the origin of the explosion
  71725. * @param radiusOrEventOptions the radius or the options of radial explosion
  71726. * @param strength the explosion strength
  71727. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71728. * @returns A physics radial explosion event, or null
  71729. */
  71730. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71731. /**
  71732. * Applies a radial explosion force
  71733. * @param origin the origin of the explosion
  71734. * @param radiusOrEventOptions the radius or the options of radial explosion
  71735. * @param strength the explosion strength
  71736. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71737. * @returns A physics radial explosion event, or null
  71738. */
  71739. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71740. /**
  71741. * Creates a gravitational field
  71742. * @param origin the origin of the explosion
  71743. * @param radiusOrEventOptions the radius or the options of radial explosion
  71744. * @param strength the explosion strength
  71745. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71746. * @returns A physics gravitational field event, or null
  71747. */
  71748. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71749. /**
  71750. * Creates a physics updraft event
  71751. * @param origin the origin of the updraft
  71752. * @param radiusOrEventOptions the radius or the options of the updraft
  71753. * @param strength the strength of the updraft
  71754. * @param height the height of the updraft
  71755. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71756. * @returns A physics updraft event, or null
  71757. */
  71758. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71759. /**
  71760. * Creates a physics vortex event
  71761. * @param origin the of the vortex
  71762. * @param radiusOrEventOptions the radius or the options of the vortex
  71763. * @param strength the strength of the vortex
  71764. * @param height the height of the vortex
  71765. * @returns a Physics vortex event, or null
  71766. * A physics vortex event or null
  71767. */
  71768. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71769. }
  71770. /**
  71771. * Represents a physics radial explosion event
  71772. */
  71773. class PhysicsRadialExplosionEvent {
  71774. private _scene;
  71775. private _options;
  71776. private _sphere;
  71777. private _dataFetched;
  71778. /**
  71779. * Initializes a radial explosioin event
  71780. * @param _scene BabylonJS scene
  71781. * @param _options The options for the vortex event
  71782. */
  71783. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71784. /**
  71785. * Returns the data related to the radial explosion event (sphere).
  71786. * @returns The radial explosion event data
  71787. */
  71788. getData(): PhysicsRadialExplosionEventData;
  71789. /**
  71790. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71791. * @param impostor A physics imposter
  71792. * @param origin the origin of the explosion
  71793. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71794. */
  71795. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71796. /**
  71797. * Triggers affecterd impostors callbacks
  71798. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71799. */
  71800. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71801. /**
  71802. * Disposes the sphere.
  71803. * @param force Specifies if the sphere should be disposed by force
  71804. */
  71805. dispose(force?: boolean): void;
  71806. /*** Helpers ***/
  71807. private _prepareSphere;
  71808. private _intersectsWithSphere;
  71809. }
  71810. /**
  71811. * Represents a gravitational field event
  71812. */
  71813. class PhysicsGravitationalFieldEvent {
  71814. private _physicsHelper;
  71815. private _scene;
  71816. private _origin;
  71817. private _options;
  71818. private _tickCallback;
  71819. private _sphere;
  71820. private _dataFetched;
  71821. /**
  71822. * Initializes the physics gravitational field event
  71823. * @param _physicsHelper A physics helper
  71824. * @param _scene BabylonJS scene
  71825. * @param _origin The origin position of the gravitational field event
  71826. * @param _options The options for the vortex event
  71827. */
  71828. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71829. /**
  71830. * Returns the data related to the gravitational field event (sphere).
  71831. * @returns A gravitational field event
  71832. */
  71833. getData(): PhysicsGravitationalFieldEventData;
  71834. /**
  71835. * Enables the gravitational field.
  71836. */
  71837. enable(): void;
  71838. /**
  71839. * Disables the gravitational field.
  71840. */
  71841. disable(): void;
  71842. /**
  71843. * Disposes the sphere.
  71844. * @param force The force to dispose from the gravitational field event
  71845. */
  71846. dispose(force?: boolean): void;
  71847. private _tick;
  71848. }
  71849. /**
  71850. * Represents a physics updraft event
  71851. */
  71852. class PhysicsUpdraftEvent {
  71853. private _scene;
  71854. private _origin;
  71855. private _options;
  71856. private _physicsEngine;
  71857. private _originTop;
  71858. private _originDirection;
  71859. private _tickCallback;
  71860. private _cylinder;
  71861. private _cylinderPosition;
  71862. private _dataFetched;
  71863. /**
  71864. * Initializes the physics updraft event
  71865. * @param _scene BabylonJS scene
  71866. * @param _origin The origin position of the updraft
  71867. * @param _options The options for the updraft event
  71868. */
  71869. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71870. /**
  71871. * Returns the data related to the updraft event (cylinder).
  71872. * @returns A physics updraft event
  71873. */
  71874. getData(): PhysicsUpdraftEventData;
  71875. /**
  71876. * Enables the updraft.
  71877. */
  71878. enable(): void;
  71879. /**
  71880. * Disables the updraft.
  71881. */
  71882. disable(): void;
  71883. /**
  71884. * Disposes the cylinder.
  71885. * @param force Specifies if the updraft should be disposed by force
  71886. */
  71887. dispose(force?: boolean): void;
  71888. private getImpostorHitData;
  71889. private _tick;
  71890. /*** Helpers ***/
  71891. private _prepareCylinder;
  71892. private _intersectsWithCylinder;
  71893. }
  71894. /**
  71895. * Represents a physics vortex event
  71896. */
  71897. class PhysicsVortexEvent {
  71898. private _scene;
  71899. private _origin;
  71900. private _options;
  71901. private _physicsEngine;
  71902. private _originTop;
  71903. private _tickCallback;
  71904. private _cylinder;
  71905. private _cylinderPosition;
  71906. private _dataFetched;
  71907. /**
  71908. * Initializes the physics vortex event
  71909. * @param _scene The BabylonJS scene
  71910. * @param _origin The origin position of the vortex
  71911. * @param _options The options for the vortex event
  71912. */
  71913. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71914. /**
  71915. * Returns the data related to the vortex event (cylinder).
  71916. * @returns The physics vortex event data
  71917. */
  71918. getData(): PhysicsVortexEventData;
  71919. /**
  71920. * Enables the vortex.
  71921. */
  71922. enable(): void;
  71923. /**
  71924. * Disables the cortex.
  71925. */
  71926. disable(): void;
  71927. /**
  71928. * Disposes the sphere.
  71929. * @param force
  71930. */
  71931. dispose(force?: boolean): void;
  71932. private getImpostorHitData;
  71933. private _tick;
  71934. /*** Helpers ***/
  71935. private _prepareCylinder;
  71936. private _intersectsWithCylinder;
  71937. }
  71938. /**
  71939. * Options fot the radial explosion event
  71940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71941. */
  71942. export class PhysicsRadialExplosionEventOptions {
  71943. /**
  71944. * The radius of the sphere for the radial explosion.
  71945. */
  71946. radius: number;
  71947. /**
  71948. * The strenth of the explosion.
  71949. */
  71950. strength: number;
  71951. /**
  71952. * The strenght of the force in correspondence to the distance of the affected object
  71953. */
  71954. falloff: PhysicsRadialImpulseFalloff;
  71955. /**
  71956. * Sphere options for the radial explosion.
  71957. */
  71958. sphere: {
  71959. segments: number;
  71960. diameter: number;
  71961. };
  71962. /**
  71963. * Sphere options for the radial explosion.
  71964. */
  71965. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71966. }
  71967. /**
  71968. * Options fot the updraft event
  71969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71970. */
  71971. export class PhysicsUpdraftEventOptions {
  71972. /**
  71973. * The radius of the cylinder for the vortex
  71974. */
  71975. radius: number;
  71976. /**
  71977. * The strenth of the updraft.
  71978. */
  71979. strength: number;
  71980. /**
  71981. * The height of the cylinder for the updraft.
  71982. */
  71983. height: number;
  71984. /**
  71985. * The mode for the the updraft.
  71986. */
  71987. updraftMode: PhysicsUpdraftMode;
  71988. }
  71989. /**
  71990. * Options fot the vortex event
  71991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71992. */
  71993. export class PhysicsVortexEventOptions {
  71994. /**
  71995. * The radius of the cylinder for the vortex
  71996. */
  71997. radius: number;
  71998. /**
  71999. * The strenth of the vortex.
  72000. */
  72001. strength: number;
  72002. /**
  72003. * The height of the cylinder for the vortex.
  72004. */
  72005. height: number;
  72006. /**
  72007. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72008. */
  72009. centripetalForceThreshold: number;
  72010. /**
  72011. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72012. */
  72013. centripetalForceMultiplier: number;
  72014. /**
  72015. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72016. */
  72017. centrifugalForceMultiplier: number;
  72018. /**
  72019. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72020. */
  72021. updraftForceMultiplier: number;
  72022. }
  72023. /**
  72024. * The strenght of the force in correspondence to the distance of the affected object
  72025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72026. */
  72027. export enum PhysicsRadialImpulseFalloff {
  72028. /** Defines that impulse is constant in strength across it's whole radius */
  72029. Constant = 0,
  72030. /** Defines that impulse gets weaker if it's further from the origin */
  72031. Linear = 1
  72032. }
  72033. /**
  72034. * The strength of the force in correspondence to the distance of the affected object
  72035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72036. */
  72037. export enum PhysicsUpdraftMode {
  72038. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72039. Center = 0,
  72040. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72041. Perpendicular = 1
  72042. }
  72043. /**
  72044. * Interface for a physics hit data
  72045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72046. */
  72047. export interface PhysicsHitData {
  72048. /**
  72049. * The force applied at the contact point
  72050. */
  72051. force: Vector3;
  72052. /**
  72053. * The contact point
  72054. */
  72055. contactPoint: Vector3;
  72056. /**
  72057. * The distance from the origin to the contact point
  72058. */
  72059. distanceFromOrigin: number;
  72060. }
  72061. /**
  72062. * Interface for radial explosion event data
  72063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72064. */
  72065. export interface PhysicsRadialExplosionEventData {
  72066. /**
  72067. * A sphere used for the radial explosion event
  72068. */
  72069. sphere: Mesh;
  72070. }
  72071. /**
  72072. * Interface for gravitational field event data
  72073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72074. */
  72075. export interface PhysicsGravitationalFieldEventData {
  72076. /**
  72077. * A sphere mesh used for the gravitational field event
  72078. */
  72079. sphere: Mesh;
  72080. }
  72081. /**
  72082. * Interface for updraft event data
  72083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72084. */
  72085. export interface PhysicsUpdraftEventData {
  72086. /**
  72087. * A cylinder used for the updraft event
  72088. */
  72089. cylinder: Mesh;
  72090. }
  72091. /**
  72092. * Interface for vortex event data
  72093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72094. */
  72095. export interface PhysicsVortexEventData {
  72096. /**
  72097. * A cylinder used for the vortex event
  72098. */
  72099. cylinder: Mesh;
  72100. }
  72101. /**
  72102. * Interface for an affected physics impostor
  72103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72104. */
  72105. export interface PhysicsAffectedImpostorWithData {
  72106. /**
  72107. * The impostor affected by the effect
  72108. */
  72109. impostor: PhysicsImpostor;
  72110. /**
  72111. * The data about the hit/horce from the explosion
  72112. */
  72113. hitData: PhysicsHitData;
  72114. }
  72115. }
  72116. declare module "babylonjs/Physics/Plugins/index" {
  72117. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72118. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72119. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72120. }
  72121. declare module "babylonjs/Physics/index" {
  72122. export * from "babylonjs/Physics/IPhysicsEngine";
  72123. export * from "babylonjs/Physics/physicsEngine";
  72124. export * from "babylonjs/Physics/physicsEngineComponent";
  72125. export * from "babylonjs/Physics/physicsHelper";
  72126. export * from "babylonjs/Physics/physicsImpostor";
  72127. export * from "babylonjs/Physics/physicsJoint";
  72128. export * from "babylonjs/Physics/Plugins/index";
  72129. }
  72130. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72131. /** @hidden */
  72132. export var blackAndWhitePixelShader: {
  72133. name: string;
  72134. shader: string;
  72135. };
  72136. }
  72137. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72138. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72139. import { Camera } from "babylonjs/Cameras/camera";
  72140. import { Engine } from "babylonjs/Engines/engine";
  72141. import "babylonjs/Shaders/blackAndWhite.fragment";
  72142. /**
  72143. * Post process used to render in black and white
  72144. */
  72145. export class BlackAndWhitePostProcess extends PostProcess {
  72146. /**
  72147. * Linear about to convert he result to black and white (default: 1)
  72148. */
  72149. degree: number;
  72150. /**
  72151. * Creates a black and white post process
  72152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72153. * @param name The name of the effect.
  72154. * @param options The required width/height ratio to downsize to before computing the render pass.
  72155. * @param camera The camera to apply the render pass to.
  72156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72157. * @param engine The engine which the post process will be applied. (default: current engine)
  72158. * @param reusable If the post process can be reused on the same frame. (default: false)
  72159. */
  72160. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72161. }
  72162. }
  72163. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72164. import { Nullable } from "babylonjs/types";
  72165. import { Camera } from "babylonjs/Cameras/camera";
  72166. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72167. import { Engine } from "babylonjs/Engines/engine";
  72168. /**
  72169. * This represents a set of one or more post processes in Babylon.
  72170. * A post process can be used to apply a shader to a texture after it is rendered.
  72171. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72172. */
  72173. export class PostProcessRenderEffect {
  72174. private _postProcesses;
  72175. private _getPostProcesses;
  72176. private _singleInstance;
  72177. private _cameras;
  72178. private _indicesForCamera;
  72179. /**
  72180. * Name of the effect
  72181. * @hidden
  72182. */
  72183. _name: string;
  72184. /**
  72185. * Instantiates a post process render effect.
  72186. * A post process can be used to apply a shader to a texture after it is rendered.
  72187. * @param engine The engine the effect is tied to
  72188. * @param name The name of the effect
  72189. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72190. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72191. */
  72192. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72193. /**
  72194. * Checks if all the post processes in the effect are supported.
  72195. */
  72196. get isSupported(): boolean;
  72197. /**
  72198. * Updates the current state of the effect
  72199. * @hidden
  72200. */
  72201. _update(): void;
  72202. /**
  72203. * Attaches the effect on cameras
  72204. * @param cameras The camera to attach to.
  72205. * @hidden
  72206. */
  72207. _attachCameras(cameras: Camera): void;
  72208. /**
  72209. * Attaches the effect on cameras
  72210. * @param cameras The camera to attach to.
  72211. * @hidden
  72212. */
  72213. _attachCameras(cameras: Camera[]): void;
  72214. /**
  72215. * Detaches the effect on cameras
  72216. * @param cameras The camera to detatch from.
  72217. * @hidden
  72218. */
  72219. _detachCameras(cameras: Camera): void;
  72220. /**
  72221. * Detatches the effect on cameras
  72222. * @param cameras The camera to detatch from.
  72223. * @hidden
  72224. */
  72225. _detachCameras(cameras: Camera[]): void;
  72226. /**
  72227. * Enables the effect on given cameras
  72228. * @param cameras The camera to enable.
  72229. * @hidden
  72230. */
  72231. _enable(cameras: Camera): void;
  72232. /**
  72233. * Enables the effect on given cameras
  72234. * @param cameras The camera to enable.
  72235. * @hidden
  72236. */
  72237. _enable(cameras: Nullable<Camera[]>): void;
  72238. /**
  72239. * Disables the effect on the given cameras
  72240. * @param cameras The camera to disable.
  72241. * @hidden
  72242. */
  72243. _disable(cameras: Camera): void;
  72244. /**
  72245. * Disables the effect on the given cameras
  72246. * @param cameras The camera to disable.
  72247. * @hidden
  72248. */
  72249. _disable(cameras: Nullable<Camera[]>): void;
  72250. /**
  72251. * Gets a list of the post processes contained in the effect.
  72252. * @param camera The camera to get the post processes on.
  72253. * @returns The list of the post processes in the effect.
  72254. */
  72255. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72256. }
  72257. }
  72258. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72259. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72260. /** @hidden */
  72261. export var extractHighlightsPixelShader: {
  72262. name: string;
  72263. shader: string;
  72264. };
  72265. }
  72266. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72267. import { Nullable } from "babylonjs/types";
  72268. import { Camera } from "babylonjs/Cameras/camera";
  72269. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72270. import { Engine } from "babylonjs/Engines/engine";
  72271. import "babylonjs/Shaders/extractHighlights.fragment";
  72272. /**
  72273. * 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.
  72274. */
  72275. export class ExtractHighlightsPostProcess extends PostProcess {
  72276. /**
  72277. * The luminance threshold, pixels below this value will be set to black.
  72278. */
  72279. threshold: number;
  72280. /** @hidden */
  72281. _exposure: number;
  72282. /**
  72283. * Post process which has the input texture to be used when performing highlight extraction
  72284. * @hidden
  72285. */
  72286. _inputPostProcess: Nullable<PostProcess>;
  72287. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72288. }
  72289. }
  72290. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72291. /** @hidden */
  72292. export var bloomMergePixelShader: {
  72293. name: string;
  72294. shader: string;
  72295. };
  72296. }
  72297. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72298. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72299. import { Nullable } from "babylonjs/types";
  72300. import { Engine } from "babylonjs/Engines/engine";
  72301. import { Camera } from "babylonjs/Cameras/camera";
  72302. import "babylonjs/Shaders/bloomMerge.fragment";
  72303. /**
  72304. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72305. */
  72306. export class BloomMergePostProcess extends PostProcess {
  72307. /** Weight of the bloom to be added to the original input. */
  72308. weight: number;
  72309. /**
  72310. * Creates a new instance of @see BloomMergePostProcess
  72311. * @param name The name of the effect.
  72312. * @param originalFromInput Post process which's input will be used for the merge.
  72313. * @param blurred Blurred highlights post process which's output will be used.
  72314. * @param weight Weight of the bloom to be added to the original input.
  72315. * @param options The required width/height ratio to downsize to before computing the render pass.
  72316. * @param camera The camera to apply the render pass to.
  72317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72318. * @param engine The engine which the post process will be applied. (default: current engine)
  72319. * @param reusable If the post process can be reused on the same frame. (default: false)
  72320. * @param textureType Type of textures used when performing the post process. (default: 0)
  72321. * @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)
  72322. */
  72323. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72324. /** Weight of the bloom to be added to the original input. */
  72325. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72326. }
  72327. }
  72328. declare module "babylonjs/PostProcesses/bloomEffect" {
  72329. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72330. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72331. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72332. import { Camera } from "babylonjs/Cameras/camera";
  72333. import { Scene } from "babylonjs/scene";
  72334. /**
  72335. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72336. */
  72337. export class BloomEffect extends PostProcessRenderEffect {
  72338. private bloomScale;
  72339. /**
  72340. * @hidden Internal
  72341. */
  72342. _effects: Array<PostProcess>;
  72343. /**
  72344. * @hidden Internal
  72345. */
  72346. _downscale: ExtractHighlightsPostProcess;
  72347. private _blurX;
  72348. private _blurY;
  72349. private _merge;
  72350. /**
  72351. * The luminance threshold to find bright areas of the image to bloom.
  72352. */
  72353. get threshold(): number;
  72354. set threshold(value: number);
  72355. /**
  72356. * The strength of the bloom.
  72357. */
  72358. get weight(): number;
  72359. set weight(value: number);
  72360. /**
  72361. * Specifies the size of the bloom blur kernel, relative to the final output size
  72362. */
  72363. get kernel(): number;
  72364. set kernel(value: number);
  72365. /**
  72366. * Creates a new instance of @see BloomEffect
  72367. * @param scene The scene the effect belongs to.
  72368. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72369. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72370. * @param bloomWeight The the strength of bloom.
  72371. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72372. * @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)
  72373. */
  72374. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72375. /**
  72376. * Disposes each of the internal effects for a given camera.
  72377. * @param camera The camera to dispose the effect on.
  72378. */
  72379. disposeEffects(camera: Camera): void;
  72380. /**
  72381. * @hidden Internal
  72382. */
  72383. _updateEffects(): void;
  72384. /**
  72385. * Internal
  72386. * @returns if all the contained post processes are ready.
  72387. * @hidden
  72388. */
  72389. _isReady(): boolean;
  72390. }
  72391. }
  72392. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72393. /** @hidden */
  72394. export var chromaticAberrationPixelShader: {
  72395. name: string;
  72396. shader: string;
  72397. };
  72398. }
  72399. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72400. import { Vector2 } from "babylonjs/Maths/math.vector";
  72401. import { Nullable } from "babylonjs/types";
  72402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72403. import { Camera } from "babylonjs/Cameras/camera";
  72404. import { Engine } from "babylonjs/Engines/engine";
  72405. import "babylonjs/Shaders/chromaticAberration.fragment";
  72406. /**
  72407. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72408. */
  72409. export class ChromaticAberrationPostProcess extends PostProcess {
  72410. /**
  72411. * The amount of seperation of rgb channels (default: 30)
  72412. */
  72413. aberrationAmount: number;
  72414. /**
  72415. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72416. */
  72417. radialIntensity: number;
  72418. /**
  72419. * 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))
  72420. */
  72421. direction: Vector2;
  72422. /**
  72423. * 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))
  72424. */
  72425. centerPosition: Vector2;
  72426. /**
  72427. * Creates a new instance ChromaticAberrationPostProcess
  72428. * @param name The name of the effect.
  72429. * @param screenWidth The width of the screen to apply the effect on.
  72430. * @param screenHeight The height of the screen to apply the effect on.
  72431. * @param options The required width/height ratio to downsize to before computing the render pass.
  72432. * @param camera The camera to apply the render pass to.
  72433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72434. * @param engine The engine which the post process will be applied. (default: current engine)
  72435. * @param reusable If the post process can be reused on the same frame. (default: false)
  72436. * @param textureType Type of textures used when performing the post process. (default: 0)
  72437. * @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)
  72438. */
  72439. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72440. }
  72441. }
  72442. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72443. /** @hidden */
  72444. export var circleOfConfusionPixelShader: {
  72445. name: string;
  72446. shader: string;
  72447. };
  72448. }
  72449. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72450. import { Nullable } from "babylonjs/types";
  72451. import { Engine } from "babylonjs/Engines/engine";
  72452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72453. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72454. import { Camera } from "babylonjs/Cameras/camera";
  72455. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72456. /**
  72457. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72458. */
  72459. export class CircleOfConfusionPostProcess extends PostProcess {
  72460. /**
  72461. * 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.
  72462. */
  72463. lensSize: number;
  72464. /**
  72465. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72466. */
  72467. fStop: number;
  72468. /**
  72469. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72470. */
  72471. focusDistance: number;
  72472. /**
  72473. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72474. */
  72475. focalLength: number;
  72476. private _depthTexture;
  72477. /**
  72478. * Creates a new instance CircleOfConfusionPostProcess
  72479. * @param name The name of the effect.
  72480. * @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.
  72481. * @param options The required width/height ratio to downsize to before computing the render pass.
  72482. * @param camera The camera to apply the render pass to.
  72483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72484. * @param engine The engine which the post process will be applied. (default: current engine)
  72485. * @param reusable If the post process can be reused on the same frame. (default: false)
  72486. * @param textureType Type of textures used when performing the post process. (default: 0)
  72487. * @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)
  72488. */
  72489. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72490. /**
  72491. * 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.
  72492. */
  72493. set depthTexture(value: RenderTargetTexture);
  72494. }
  72495. }
  72496. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72497. /** @hidden */
  72498. export var colorCorrectionPixelShader: {
  72499. name: string;
  72500. shader: string;
  72501. };
  72502. }
  72503. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72504. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72505. import { Engine } from "babylonjs/Engines/engine";
  72506. import { Camera } from "babylonjs/Cameras/camera";
  72507. import "babylonjs/Shaders/colorCorrection.fragment";
  72508. /**
  72509. *
  72510. * This post-process allows the modification of rendered colors by using
  72511. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72512. *
  72513. * The object needs to be provided an url to a texture containing the color
  72514. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72515. * Use an image editing software to tweak the LUT to match your needs.
  72516. *
  72517. * For an example of a color LUT, see here:
  72518. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72519. * For explanations on color grading, see here:
  72520. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72521. *
  72522. */
  72523. export class ColorCorrectionPostProcess extends PostProcess {
  72524. private _colorTableTexture;
  72525. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72526. }
  72527. }
  72528. declare module "babylonjs/Shaders/convolution.fragment" {
  72529. /** @hidden */
  72530. export var convolutionPixelShader: {
  72531. name: string;
  72532. shader: string;
  72533. };
  72534. }
  72535. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72536. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72537. import { Nullable } from "babylonjs/types";
  72538. import { Camera } from "babylonjs/Cameras/camera";
  72539. import { Engine } from "babylonjs/Engines/engine";
  72540. import "babylonjs/Shaders/convolution.fragment";
  72541. /**
  72542. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72543. * input texture to perform effects such as edge detection or sharpening
  72544. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72545. */
  72546. export class ConvolutionPostProcess extends PostProcess {
  72547. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72548. kernel: number[];
  72549. /**
  72550. * Creates a new instance ConvolutionPostProcess
  72551. * @param name The name of the effect.
  72552. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72553. * @param options The required width/height ratio to downsize to before computing the render pass.
  72554. * @param camera The camera to apply the render pass to.
  72555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72556. * @param engine The engine which the post process will be applied. (default: current engine)
  72557. * @param reusable If the post process can be reused on the same frame. (default: false)
  72558. * @param textureType Type of textures used when performing the post process. (default: 0)
  72559. */
  72560. constructor(name: string,
  72561. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72562. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72563. /**
  72564. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72565. */
  72566. static EdgeDetect0Kernel: number[];
  72567. /**
  72568. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72569. */
  72570. static EdgeDetect1Kernel: number[];
  72571. /**
  72572. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72573. */
  72574. static EdgeDetect2Kernel: number[];
  72575. /**
  72576. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72577. */
  72578. static SharpenKernel: number[];
  72579. /**
  72580. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72581. */
  72582. static EmbossKernel: number[];
  72583. /**
  72584. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72585. */
  72586. static GaussianKernel: number[];
  72587. }
  72588. }
  72589. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72590. import { Nullable } from "babylonjs/types";
  72591. import { Vector2 } from "babylonjs/Maths/math.vector";
  72592. import { Camera } from "babylonjs/Cameras/camera";
  72593. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72594. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72595. import { Engine } from "babylonjs/Engines/engine";
  72596. import { Scene } from "babylonjs/scene";
  72597. /**
  72598. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72599. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72600. * based on samples that have a large difference in distance than the center pixel.
  72601. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72602. */
  72603. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72604. direction: Vector2;
  72605. /**
  72606. * Creates a new instance CircleOfConfusionPostProcess
  72607. * @param name The name of the effect.
  72608. * @param scene The scene the effect belongs to.
  72609. * @param direction The direction the blur should be applied.
  72610. * @param kernel The size of the kernel used to blur.
  72611. * @param options The required width/height ratio to downsize to before computing the render pass.
  72612. * @param camera The camera to apply the render pass to.
  72613. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72614. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72616. * @param engine The engine which the post process will be applied. (default: current engine)
  72617. * @param reusable If the post process can be reused on the same frame. (default: false)
  72618. * @param textureType Type of textures used when performing the post process. (default: 0)
  72619. * @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)
  72620. */
  72621. 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);
  72622. }
  72623. }
  72624. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72625. /** @hidden */
  72626. export var depthOfFieldMergePixelShader: {
  72627. name: string;
  72628. shader: string;
  72629. };
  72630. }
  72631. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72632. import { Nullable } from "babylonjs/types";
  72633. import { Camera } from "babylonjs/Cameras/camera";
  72634. import { Effect } from "babylonjs/Materials/effect";
  72635. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72636. import { Engine } from "babylonjs/Engines/engine";
  72637. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72638. /**
  72639. * Options to be set when merging outputs from the default pipeline.
  72640. */
  72641. export class DepthOfFieldMergePostProcessOptions {
  72642. /**
  72643. * The original image to merge on top of
  72644. */
  72645. originalFromInput: PostProcess;
  72646. /**
  72647. * Parameters to perform the merge of the depth of field effect
  72648. */
  72649. depthOfField?: {
  72650. circleOfConfusion: PostProcess;
  72651. blurSteps: Array<PostProcess>;
  72652. };
  72653. /**
  72654. * Parameters to perform the merge of bloom effect
  72655. */
  72656. bloom?: {
  72657. blurred: PostProcess;
  72658. weight: number;
  72659. };
  72660. }
  72661. /**
  72662. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72663. */
  72664. export class DepthOfFieldMergePostProcess extends PostProcess {
  72665. private blurSteps;
  72666. /**
  72667. * Creates a new instance of DepthOfFieldMergePostProcess
  72668. * @param name The name of the effect.
  72669. * @param originalFromInput Post process which's input will be used for the merge.
  72670. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72671. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72672. * @param options The required width/height ratio to downsize to before computing the render pass.
  72673. * @param camera The camera to apply the render pass to.
  72674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72675. * @param engine The engine which the post process will be applied. (default: current engine)
  72676. * @param reusable If the post process can be reused on the same frame. (default: false)
  72677. * @param textureType Type of textures used when performing the post process. (default: 0)
  72678. * @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)
  72679. */
  72680. 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);
  72681. /**
  72682. * Updates the effect with the current post process compile time values and recompiles the shader.
  72683. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72684. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72685. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72686. * @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
  72687. * @param onCompiled Called when the shader has been compiled.
  72688. * @param onError Called if there is an error when compiling a shader.
  72689. */
  72690. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72691. }
  72692. }
  72693. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72694. import { Nullable } from "babylonjs/types";
  72695. import { Camera } from "babylonjs/Cameras/camera";
  72696. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72697. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72698. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72699. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72700. import { Scene } from "babylonjs/scene";
  72701. /**
  72702. * Specifies the level of max blur that should be applied when using the depth of field effect
  72703. */
  72704. export enum DepthOfFieldEffectBlurLevel {
  72705. /**
  72706. * Subtle blur
  72707. */
  72708. Low = 0,
  72709. /**
  72710. * Medium blur
  72711. */
  72712. Medium = 1,
  72713. /**
  72714. * Large blur
  72715. */
  72716. High = 2
  72717. }
  72718. /**
  72719. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72720. */
  72721. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72722. private _circleOfConfusion;
  72723. /**
  72724. * @hidden Internal, blurs from high to low
  72725. */
  72726. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72727. private _depthOfFieldBlurY;
  72728. private _dofMerge;
  72729. /**
  72730. * @hidden Internal post processes in depth of field effect
  72731. */
  72732. _effects: Array<PostProcess>;
  72733. /**
  72734. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72735. */
  72736. set focalLength(value: number);
  72737. get focalLength(): number;
  72738. /**
  72739. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72740. */
  72741. set fStop(value: number);
  72742. get fStop(): number;
  72743. /**
  72744. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72745. */
  72746. set focusDistance(value: number);
  72747. get focusDistance(): number;
  72748. /**
  72749. * 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.
  72750. */
  72751. set lensSize(value: number);
  72752. get lensSize(): number;
  72753. /**
  72754. * Creates a new instance DepthOfFieldEffect
  72755. * @param scene The scene the effect belongs to.
  72756. * @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.
  72757. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72758. * @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)
  72759. */
  72760. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72761. /**
  72762. * Get the current class name of the current effet
  72763. * @returns "DepthOfFieldEffect"
  72764. */
  72765. getClassName(): string;
  72766. /**
  72767. * 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.
  72768. */
  72769. set depthTexture(value: RenderTargetTexture);
  72770. /**
  72771. * Disposes each of the internal effects for a given camera.
  72772. * @param camera The camera to dispose the effect on.
  72773. */
  72774. disposeEffects(camera: Camera): void;
  72775. /**
  72776. * @hidden Internal
  72777. */
  72778. _updateEffects(): void;
  72779. /**
  72780. * Internal
  72781. * @returns if all the contained post processes are ready.
  72782. * @hidden
  72783. */
  72784. _isReady(): boolean;
  72785. }
  72786. }
  72787. declare module "babylonjs/Shaders/displayPass.fragment" {
  72788. /** @hidden */
  72789. export var displayPassPixelShader: {
  72790. name: string;
  72791. shader: string;
  72792. };
  72793. }
  72794. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72795. import { Nullable } from "babylonjs/types";
  72796. import { Camera } from "babylonjs/Cameras/camera";
  72797. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72798. import { Engine } from "babylonjs/Engines/engine";
  72799. import "babylonjs/Shaders/displayPass.fragment";
  72800. /**
  72801. * DisplayPassPostProcess which produces an output the same as it's input
  72802. */
  72803. export class DisplayPassPostProcess extends PostProcess {
  72804. /**
  72805. * Creates the DisplayPassPostProcess
  72806. * @param name The name of the effect.
  72807. * @param options The required width/height ratio to downsize to before computing the render pass.
  72808. * @param camera The camera to apply the render pass to.
  72809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72810. * @param engine The engine which the post process will be applied. (default: current engine)
  72811. * @param reusable If the post process can be reused on the same frame. (default: false)
  72812. */
  72813. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72814. }
  72815. }
  72816. declare module "babylonjs/Shaders/filter.fragment" {
  72817. /** @hidden */
  72818. export var filterPixelShader: {
  72819. name: string;
  72820. shader: string;
  72821. };
  72822. }
  72823. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72824. import { Nullable } from "babylonjs/types";
  72825. import { Matrix } from "babylonjs/Maths/math.vector";
  72826. import { Camera } from "babylonjs/Cameras/camera";
  72827. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72828. import { Engine } from "babylonjs/Engines/engine";
  72829. import "babylonjs/Shaders/filter.fragment";
  72830. /**
  72831. * Applies a kernel filter to the image
  72832. */
  72833. export class FilterPostProcess extends PostProcess {
  72834. /** The matrix to be applied to the image */
  72835. kernelMatrix: Matrix;
  72836. /**
  72837. *
  72838. * @param name The name of the effect.
  72839. * @param kernelMatrix The matrix to be applied to the image
  72840. * @param options The required width/height ratio to downsize to before computing the render pass.
  72841. * @param camera The camera to apply the render pass to.
  72842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72843. * @param engine The engine which the post process will be applied. (default: current engine)
  72844. * @param reusable If the post process can be reused on the same frame. (default: false)
  72845. */
  72846. constructor(name: string,
  72847. /** The matrix to be applied to the image */
  72848. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72849. }
  72850. }
  72851. declare module "babylonjs/Shaders/fxaa.fragment" {
  72852. /** @hidden */
  72853. export var fxaaPixelShader: {
  72854. name: string;
  72855. shader: string;
  72856. };
  72857. }
  72858. declare module "babylonjs/Shaders/fxaa.vertex" {
  72859. /** @hidden */
  72860. export var fxaaVertexShader: {
  72861. name: string;
  72862. shader: string;
  72863. };
  72864. }
  72865. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72866. import { Nullable } from "babylonjs/types";
  72867. import { Camera } from "babylonjs/Cameras/camera";
  72868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72869. import { Engine } from "babylonjs/Engines/engine";
  72870. import "babylonjs/Shaders/fxaa.fragment";
  72871. import "babylonjs/Shaders/fxaa.vertex";
  72872. /**
  72873. * Fxaa post process
  72874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72875. */
  72876. export class FxaaPostProcess extends PostProcess {
  72877. /** @hidden */
  72878. texelWidth: number;
  72879. /** @hidden */
  72880. texelHeight: number;
  72881. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72882. private _getDefines;
  72883. }
  72884. }
  72885. declare module "babylonjs/Shaders/grain.fragment" {
  72886. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72887. /** @hidden */
  72888. export var grainPixelShader: {
  72889. name: string;
  72890. shader: string;
  72891. };
  72892. }
  72893. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72894. import { Nullable } from "babylonjs/types";
  72895. import { Camera } from "babylonjs/Cameras/camera";
  72896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72897. import { Engine } from "babylonjs/Engines/engine";
  72898. import "babylonjs/Shaders/grain.fragment";
  72899. /**
  72900. * The GrainPostProcess adds noise to the image at mid luminance levels
  72901. */
  72902. export class GrainPostProcess extends PostProcess {
  72903. /**
  72904. * The intensity of the grain added (default: 30)
  72905. */
  72906. intensity: number;
  72907. /**
  72908. * If the grain should be randomized on every frame
  72909. */
  72910. animated: boolean;
  72911. /**
  72912. * Creates a new instance of @see GrainPostProcess
  72913. * @param name The name of the effect.
  72914. * @param options The required width/height ratio to downsize to before computing the render pass.
  72915. * @param camera The camera to apply the render pass to.
  72916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72917. * @param engine The engine which the post process will be applied. (default: current engine)
  72918. * @param reusable If the post process can be reused on the same frame. (default: false)
  72919. * @param textureType Type of textures used when performing the post process. (default: 0)
  72920. * @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)
  72921. */
  72922. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72923. }
  72924. }
  72925. declare module "babylonjs/Shaders/highlights.fragment" {
  72926. /** @hidden */
  72927. export var highlightsPixelShader: {
  72928. name: string;
  72929. shader: string;
  72930. };
  72931. }
  72932. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72933. import { Nullable } from "babylonjs/types";
  72934. import { Camera } from "babylonjs/Cameras/camera";
  72935. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72936. import { Engine } from "babylonjs/Engines/engine";
  72937. import "babylonjs/Shaders/highlights.fragment";
  72938. /**
  72939. * Extracts highlights from the image
  72940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72941. */
  72942. export class HighlightsPostProcess extends PostProcess {
  72943. /**
  72944. * Extracts highlights from the image
  72945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72946. * @param name The name of the effect.
  72947. * @param options The required width/height ratio to downsize to before computing the render pass.
  72948. * @param camera The camera to apply the render pass to.
  72949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72950. * @param engine The engine which the post process will be applied. (default: current engine)
  72951. * @param reusable If the post process can be reused on the same frame. (default: false)
  72952. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72953. */
  72954. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72955. }
  72956. }
  72957. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72958. /** @hidden */
  72959. export var mrtFragmentDeclaration: {
  72960. name: string;
  72961. shader: string;
  72962. };
  72963. }
  72964. declare module "babylonjs/Shaders/geometry.fragment" {
  72965. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72966. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72967. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72968. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72969. /** @hidden */
  72970. export var geometryPixelShader: {
  72971. name: string;
  72972. shader: string;
  72973. };
  72974. }
  72975. declare module "babylonjs/Shaders/geometry.vertex" {
  72976. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72977. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72978. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72979. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72981. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72982. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72983. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72984. /** @hidden */
  72985. export var geometryVertexShader: {
  72986. name: string;
  72987. shader: string;
  72988. };
  72989. }
  72990. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72991. import { Matrix } from "babylonjs/Maths/math.vector";
  72992. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72993. import { Mesh } from "babylonjs/Meshes/mesh";
  72994. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72995. import { Effect } from "babylonjs/Materials/effect";
  72996. import { Scene } from "babylonjs/scene";
  72997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72998. import "babylonjs/Shaders/geometry.fragment";
  72999. import "babylonjs/Shaders/geometry.vertex";
  73000. /** @hidden */
  73001. interface ISavedTransformationMatrix {
  73002. world: Matrix;
  73003. viewProjection: Matrix;
  73004. }
  73005. /**
  73006. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73007. */
  73008. export class GeometryBufferRenderer {
  73009. /**
  73010. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73011. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73012. */
  73013. static readonly POSITION_TEXTURE_TYPE: number;
  73014. /**
  73015. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73016. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73017. */
  73018. static readonly VELOCITY_TEXTURE_TYPE: number;
  73019. /**
  73020. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73021. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73022. */
  73023. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73024. /**
  73025. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73026. * in order to compute objects velocities when enableVelocity is set to "true"
  73027. * @hidden
  73028. */
  73029. _previousTransformationMatrices: {
  73030. [index: number]: ISavedTransformationMatrix;
  73031. };
  73032. /**
  73033. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73034. * in order to compute objects velocities when enableVelocity is set to "true"
  73035. * @hidden
  73036. */
  73037. _previousBonesTransformationMatrices: {
  73038. [index: number]: Float32Array;
  73039. };
  73040. /**
  73041. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73042. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73043. */
  73044. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73045. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73046. renderTransparentMeshes: boolean;
  73047. private _scene;
  73048. private _resizeObserver;
  73049. private _multiRenderTarget;
  73050. private _ratio;
  73051. private _enablePosition;
  73052. private _enableVelocity;
  73053. private _enableReflectivity;
  73054. private _positionIndex;
  73055. private _velocityIndex;
  73056. private _reflectivityIndex;
  73057. protected _effect: Effect;
  73058. protected _cachedDefines: string;
  73059. /**
  73060. * Set the render list (meshes to be rendered) used in the G buffer.
  73061. */
  73062. set renderList(meshes: Mesh[]);
  73063. /**
  73064. * Gets wether or not G buffer are supported by the running hardware.
  73065. * This requires draw buffer supports
  73066. */
  73067. get isSupported(): boolean;
  73068. /**
  73069. * Returns the index of the given texture type in the G-Buffer textures array
  73070. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73071. * @returns the index of the given texture type in the G-Buffer textures array
  73072. */
  73073. getTextureIndex(textureType: number): number;
  73074. /**
  73075. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73076. */
  73077. get enablePosition(): boolean;
  73078. /**
  73079. * Sets whether or not objects positions are enabled for the G buffer.
  73080. */
  73081. set enablePosition(enable: boolean);
  73082. /**
  73083. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73084. */
  73085. get enableVelocity(): boolean;
  73086. /**
  73087. * Sets wether or not objects velocities are enabled for the G buffer.
  73088. */
  73089. set enableVelocity(enable: boolean);
  73090. /**
  73091. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73092. */
  73093. get enableReflectivity(): boolean;
  73094. /**
  73095. * Sets wether or not objects roughness are enabled for the G buffer.
  73096. */
  73097. set enableReflectivity(enable: boolean);
  73098. /**
  73099. * Gets the scene associated with the buffer.
  73100. */
  73101. get scene(): Scene;
  73102. /**
  73103. * Gets the ratio used by the buffer during its creation.
  73104. * How big is the buffer related to the main canvas.
  73105. */
  73106. get ratio(): number;
  73107. /** @hidden */
  73108. static _SceneComponentInitialization: (scene: Scene) => void;
  73109. /**
  73110. * Creates a new G Buffer for the scene
  73111. * @param scene The scene the buffer belongs to
  73112. * @param ratio How big is the buffer related to the main canvas.
  73113. */
  73114. constructor(scene: Scene, ratio?: number);
  73115. /**
  73116. * Checks wether everything is ready to render a submesh to the G buffer.
  73117. * @param subMesh the submesh to check readiness for
  73118. * @param useInstances is the mesh drawn using instance or not
  73119. * @returns true if ready otherwise false
  73120. */
  73121. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73122. /**
  73123. * Gets the current underlying G Buffer.
  73124. * @returns the buffer
  73125. */
  73126. getGBuffer(): MultiRenderTarget;
  73127. /**
  73128. * Gets the number of samples used to render the buffer (anti aliasing).
  73129. */
  73130. get samples(): number;
  73131. /**
  73132. * Sets the number of samples used to render the buffer (anti aliasing).
  73133. */
  73134. set samples(value: number);
  73135. /**
  73136. * Disposes the renderer and frees up associated resources.
  73137. */
  73138. dispose(): void;
  73139. protected _createRenderTargets(): void;
  73140. private _copyBonesTransformationMatrices;
  73141. }
  73142. }
  73143. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73144. import { Nullable } from "babylonjs/types";
  73145. import { Scene } from "babylonjs/scene";
  73146. import { ISceneComponent } from "babylonjs/sceneComponent";
  73147. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73148. module "babylonjs/scene" {
  73149. interface Scene {
  73150. /** @hidden (Backing field) */
  73151. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73152. /**
  73153. * Gets or Sets the current geometry buffer associated to the scene.
  73154. */
  73155. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73156. /**
  73157. * Enables a GeometryBufferRender and associates it with the scene
  73158. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73159. * @returns the GeometryBufferRenderer
  73160. */
  73161. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73162. /**
  73163. * Disables the GeometryBufferRender associated with the scene
  73164. */
  73165. disableGeometryBufferRenderer(): void;
  73166. }
  73167. }
  73168. /**
  73169. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73170. * in several rendering techniques.
  73171. */
  73172. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73173. /**
  73174. * The component name helpful to identify the component in the list of scene components.
  73175. */
  73176. readonly name: string;
  73177. /**
  73178. * The scene the component belongs to.
  73179. */
  73180. scene: Scene;
  73181. /**
  73182. * Creates a new instance of the component for the given scene
  73183. * @param scene Defines the scene to register the component in
  73184. */
  73185. constructor(scene: Scene);
  73186. /**
  73187. * Registers the component in a given scene
  73188. */
  73189. register(): void;
  73190. /**
  73191. * Rebuilds the elements related to this component in case of
  73192. * context lost for instance.
  73193. */
  73194. rebuild(): void;
  73195. /**
  73196. * Disposes the component and the associated ressources
  73197. */
  73198. dispose(): void;
  73199. private _gatherRenderTargets;
  73200. }
  73201. }
  73202. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73203. /** @hidden */
  73204. export var motionBlurPixelShader: {
  73205. name: string;
  73206. shader: string;
  73207. };
  73208. }
  73209. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73210. import { Nullable } from "babylonjs/types";
  73211. import { Camera } from "babylonjs/Cameras/camera";
  73212. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73213. import { Scene } from "babylonjs/scene";
  73214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73215. import "babylonjs/Animations/animatable";
  73216. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73217. import "babylonjs/Shaders/motionBlur.fragment";
  73218. import { Engine } from "babylonjs/Engines/engine";
  73219. /**
  73220. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73221. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73222. * As an example, all you have to do is to create the post-process:
  73223. * var mb = new BABYLON.MotionBlurPostProcess(
  73224. * 'mb', // The name of the effect.
  73225. * scene, // The scene containing the objects to blur according to their velocity.
  73226. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73227. * camera // The camera to apply the render pass to.
  73228. * );
  73229. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73230. */
  73231. export class MotionBlurPostProcess extends PostProcess {
  73232. /**
  73233. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73234. */
  73235. motionStrength: number;
  73236. /**
  73237. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73238. */
  73239. get motionBlurSamples(): number;
  73240. /**
  73241. * Sets the number of iterations to be used for motion blur quality
  73242. */
  73243. set motionBlurSamples(samples: number);
  73244. private _motionBlurSamples;
  73245. private _geometryBufferRenderer;
  73246. /**
  73247. * Creates a new instance MotionBlurPostProcess
  73248. * @param name The name of the effect.
  73249. * @param scene The scene containing the objects to blur according to their velocity.
  73250. * @param options The required width/height ratio to downsize to before computing the render pass.
  73251. * @param camera The camera to apply the render pass to.
  73252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73253. * @param engine The engine which the post process will be applied. (default: current engine)
  73254. * @param reusable If the post process can be reused on the same frame. (default: false)
  73255. * @param textureType Type of textures used when performing the post process. (default: 0)
  73256. * @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)
  73257. */
  73258. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73259. /**
  73260. * Excludes the given skinned mesh from computing bones velocities.
  73261. * 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.
  73262. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73263. */
  73264. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73265. /**
  73266. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73267. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73268. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73269. */
  73270. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73271. /**
  73272. * Disposes the post process.
  73273. * @param camera The camera to dispose the post process on.
  73274. */
  73275. dispose(camera?: Camera): void;
  73276. }
  73277. }
  73278. declare module "babylonjs/Shaders/refraction.fragment" {
  73279. /** @hidden */
  73280. export var refractionPixelShader: {
  73281. name: string;
  73282. shader: string;
  73283. };
  73284. }
  73285. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73286. import { Color3 } from "babylonjs/Maths/math.color";
  73287. import { Camera } from "babylonjs/Cameras/camera";
  73288. import { Texture } from "babylonjs/Materials/Textures/texture";
  73289. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73290. import { Engine } from "babylonjs/Engines/engine";
  73291. import "babylonjs/Shaders/refraction.fragment";
  73292. /**
  73293. * Post process which applies a refractin texture
  73294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73295. */
  73296. export class RefractionPostProcess extends PostProcess {
  73297. /** the base color of the refraction (used to taint the rendering) */
  73298. color: Color3;
  73299. /** simulated refraction depth */
  73300. depth: number;
  73301. /** the coefficient of the base color (0 to remove base color tainting) */
  73302. colorLevel: number;
  73303. private _refTexture;
  73304. private _ownRefractionTexture;
  73305. /**
  73306. * Gets or sets the refraction texture
  73307. * Please note that you are responsible for disposing the texture if you set it manually
  73308. */
  73309. get refractionTexture(): Texture;
  73310. set refractionTexture(value: Texture);
  73311. /**
  73312. * Initializes the RefractionPostProcess
  73313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73314. * @param name The name of the effect.
  73315. * @param refractionTextureUrl Url of the refraction texture to use
  73316. * @param color the base color of the refraction (used to taint the rendering)
  73317. * @param depth simulated refraction depth
  73318. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73319. * @param camera The camera to apply the render pass to.
  73320. * @param options The required width/height ratio to downsize to before computing the render pass.
  73321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73322. * @param engine The engine which the post process will be applied. (default: current engine)
  73323. * @param reusable If the post process can be reused on the same frame. (default: false)
  73324. */
  73325. constructor(name: string, refractionTextureUrl: string,
  73326. /** the base color of the refraction (used to taint the rendering) */
  73327. color: Color3,
  73328. /** simulated refraction depth */
  73329. depth: number,
  73330. /** the coefficient of the base color (0 to remove base color tainting) */
  73331. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73332. /**
  73333. * Disposes of the post process
  73334. * @param camera Camera to dispose post process on
  73335. */
  73336. dispose(camera: Camera): void;
  73337. }
  73338. }
  73339. declare module "babylonjs/Shaders/sharpen.fragment" {
  73340. /** @hidden */
  73341. export var sharpenPixelShader: {
  73342. name: string;
  73343. shader: string;
  73344. };
  73345. }
  73346. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73347. import { Nullable } from "babylonjs/types";
  73348. import { Camera } from "babylonjs/Cameras/camera";
  73349. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73350. import "babylonjs/Shaders/sharpen.fragment";
  73351. import { Engine } from "babylonjs/Engines/engine";
  73352. /**
  73353. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73354. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73355. */
  73356. export class SharpenPostProcess extends PostProcess {
  73357. /**
  73358. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73359. */
  73360. colorAmount: number;
  73361. /**
  73362. * How much sharpness should be applied (default: 0.3)
  73363. */
  73364. edgeAmount: number;
  73365. /**
  73366. * Creates a new instance ConvolutionPostProcess
  73367. * @param name The name of the effect.
  73368. * @param options The required width/height ratio to downsize to before computing the render pass.
  73369. * @param camera The camera to apply the render pass to.
  73370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73371. * @param engine The engine which the post process will be applied. (default: current engine)
  73372. * @param reusable If the post process can be reused on the same frame. (default: false)
  73373. * @param textureType Type of textures used when performing the post process. (default: 0)
  73374. * @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)
  73375. */
  73376. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73377. }
  73378. }
  73379. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73380. import { Nullable } from "babylonjs/types";
  73381. import { Camera } from "babylonjs/Cameras/camera";
  73382. import { Engine } from "babylonjs/Engines/engine";
  73383. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73384. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73385. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73386. /**
  73387. * PostProcessRenderPipeline
  73388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73389. */
  73390. export class PostProcessRenderPipeline {
  73391. private engine;
  73392. private _renderEffects;
  73393. private _renderEffectsForIsolatedPass;
  73394. /**
  73395. * List of inspectable custom properties (used by the Inspector)
  73396. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73397. */
  73398. inspectableCustomProperties: IInspectable[];
  73399. /**
  73400. * @hidden
  73401. */
  73402. protected _cameras: Camera[];
  73403. /** @hidden */
  73404. _name: string;
  73405. /**
  73406. * Gets pipeline name
  73407. */
  73408. get name(): string;
  73409. /** Gets the list of attached cameras */
  73410. get cameras(): Camera[];
  73411. /**
  73412. * Initializes a PostProcessRenderPipeline
  73413. * @param engine engine to add the pipeline to
  73414. * @param name name of the pipeline
  73415. */
  73416. constructor(engine: Engine, name: string);
  73417. /**
  73418. * Gets the class name
  73419. * @returns "PostProcessRenderPipeline"
  73420. */
  73421. getClassName(): string;
  73422. /**
  73423. * If all the render effects in the pipeline are supported
  73424. */
  73425. get isSupported(): boolean;
  73426. /**
  73427. * Adds an effect to the pipeline
  73428. * @param renderEffect the effect to add
  73429. */
  73430. addEffect(renderEffect: PostProcessRenderEffect): void;
  73431. /** @hidden */
  73432. _rebuild(): void;
  73433. /** @hidden */
  73434. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73435. /** @hidden */
  73436. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73437. /** @hidden */
  73438. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73439. /** @hidden */
  73440. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73441. /** @hidden */
  73442. _attachCameras(cameras: Camera, unique: boolean): void;
  73443. /** @hidden */
  73444. _attachCameras(cameras: Camera[], unique: boolean): void;
  73445. /** @hidden */
  73446. _detachCameras(cameras: Camera): void;
  73447. /** @hidden */
  73448. _detachCameras(cameras: Nullable<Camera[]>): void;
  73449. /** @hidden */
  73450. _update(): void;
  73451. /** @hidden */
  73452. _reset(): void;
  73453. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73454. /**
  73455. * Sets the required values to the prepass renderer.
  73456. * @param prePassRenderer defines the prepass renderer to setup.
  73457. * @returns true if the pre pass is needed.
  73458. */
  73459. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73460. /**
  73461. * Disposes of the pipeline
  73462. */
  73463. dispose(): void;
  73464. }
  73465. }
  73466. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73467. import { Camera } from "babylonjs/Cameras/camera";
  73468. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73469. /**
  73470. * PostProcessRenderPipelineManager class
  73471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73472. */
  73473. export class PostProcessRenderPipelineManager {
  73474. private _renderPipelines;
  73475. /**
  73476. * Initializes a PostProcessRenderPipelineManager
  73477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73478. */
  73479. constructor();
  73480. /**
  73481. * Gets the list of supported render pipelines
  73482. */
  73483. get supportedPipelines(): PostProcessRenderPipeline[];
  73484. /**
  73485. * Adds a pipeline to the manager
  73486. * @param renderPipeline The pipeline to add
  73487. */
  73488. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73489. /**
  73490. * Attaches a camera to the pipeline
  73491. * @param renderPipelineName The name of the pipeline to attach to
  73492. * @param cameras the camera to attach
  73493. * @param unique if the camera can be attached multiple times to the pipeline
  73494. */
  73495. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73496. /**
  73497. * Detaches a camera from the pipeline
  73498. * @param renderPipelineName The name of the pipeline to detach from
  73499. * @param cameras the camera to detach
  73500. */
  73501. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73502. /**
  73503. * Enables an effect by name on a pipeline
  73504. * @param renderPipelineName the name of the pipeline to enable the effect in
  73505. * @param renderEffectName the name of the effect to enable
  73506. * @param cameras the cameras that the effect should be enabled on
  73507. */
  73508. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73509. /**
  73510. * Disables an effect by name on a pipeline
  73511. * @param renderPipelineName the name of the pipeline to disable the effect in
  73512. * @param renderEffectName the name of the effect to disable
  73513. * @param cameras the cameras that the effect should be disabled on
  73514. */
  73515. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73516. /**
  73517. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73518. */
  73519. update(): void;
  73520. /** @hidden */
  73521. _rebuild(): void;
  73522. /**
  73523. * Disposes of the manager and pipelines
  73524. */
  73525. dispose(): void;
  73526. }
  73527. }
  73528. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73529. import { ISceneComponent } from "babylonjs/sceneComponent";
  73530. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73531. import { Scene } from "babylonjs/scene";
  73532. module "babylonjs/scene" {
  73533. interface Scene {
  73534. /** @hidden (Backing field) */
  73535. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73536. /**
  73537. * Gets the postprocess render pipeline manager
  73538. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73539. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73540. */
  73541. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73542. }
  73543. }
  73544. /**
  73545. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73546. */
  73547. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73548. /**
  73549. * The component name helpfull to identify the component in the list of scene components.
  73550. */
  73551. readonly name: string;
  73552. /**
  73553. * The scene the component belongs to.
  73554. */
  73555. scene: Scene;
  73556. /**
  73557. * Creates a new instance of the component for the given scene
  73558. * @param scene Defines the scene to register the component in
  73559. */
  73560. constructor(scene: Scene);
  73561. /**
  73562. * Registers the component in a given scene
  73563. */
  73564. register(): void;
  73565. /**
  73566. * Rebuilds the elements related to this component in case of
  73567. * context lost for instance.
  73568. */
  73569. rebuild(): void;
  73570. /**
  73571. * Disposes the component and the associated ressources
  73572. */
  73573. dispose(): void;
  73574. private _gatherRenderTargets;
  73575. }
  73576. }
  73577. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73578. import { Nullable } from "babylonjs/types";
  73579. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73580. import { Camera } from "babylonjs/Cameras/camera";
  73581. import { IDisposable } from "babylonjs/scene";
  73582. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73583. import { Scene } from "babylonjs/scene";
  73584. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73585. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73586. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73587. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73588. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73589. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73590. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73591. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73592. import { Animation } from "babylonjs/Animations/animation";
  73593. /**
  73594. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73595. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73596. */
  73597. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73598. private _scene;
  73599. private _camerasToBeAttached;
  73600. /**
  73601. * ID of the sharpen post process,
  73602. */
  73603. private readonly SharpenPostProcessId;
  73604. /**
  73605. * @ignore
  73606. * ID of the image processing post process;
  73607. */
  73608. readonly ImageProcessingPostProcessId: string;
  73609. /**
  73610. * @ignore
  73611. * ID of the Fast Approximate Anti-Aliasing post process;
  73612. */
  73613. readonly FxaaPostProcessId: string;
  73614. /**
  73615. * ID of the chromatic aberration post process,
  73616. */
  73617. private readonly ChromaticAberrationPostProcessId;
  73618. /**
  73619. * ID of the grain post process
  73620. */
  73621. private readonly GrainPostProcessId;
  73622. /**
  73623. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73624. */
  73625. sharpen: SharpenPostProcess;
  73626. private _sharpenEffect;
  73627. private bloom;
  73628. /**
  73629. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73630. */
  73631. depthOfField: DepthOfFieldEffect;
  73632. /**
  73633. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73634. */
  73635. fxaa: FxaaPostProcess;
  73636. /**
  73637. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73638. */
  73639. imageProcessing: ImageProcessingPostProcess;
  73640. /**
  73641. * Chromatic aberration post process which will shift rgb colors in the image
  73642. */
  73643. chromaticAberration: ChromaticAberrationPostProcess;
  73644. private _chromaticAberrationEffect;
  73645. /**
  73646. * Grain post process which add noise to the image
  73647. */
  73648. grain: GrainPostProcess;
  73649. private _grainEffect;
  73650. /**
  73651. * Glow post process which adds a glow to emissive areas of the image
  73652. */
  73653. private _glowLayer;
  73654. /**
  73655. * Animations which can be used to tweak settings over a period of time
  73656. */
  73657. animations: Animation[];
  73658. private _imageProcessingConfigurationObserver;
  73659. private _sharpenEnabled;
  73660. private _bloomEnabled;
  73661. private _depthOfFieldEnabled;
  73662. private _depthOfFieldBlurLevel;
  73663. private _fxaaEnabled;
  73664. private _imageProcessingEnabled;
  73665. private _defaultPipelineTextureType;
  73666. private _bloomScale;
  73667. private _chromaticAberrationEnabled;
  73668. private _grainEnabled;
  73669. private _buildAllowed;
  73670. /**
  73671. * Gets active scene
  73672. */
  73673. get scene(): Scene;
  73674. /**
  73675. * Enable or disable the sharpen process from the pipeline
  73676. */
  73677. set sharpenEnabled(enabled: boolean);
  73678. get sharpenEnabled(): boolean;
  73679. private _resizeObserver;
  73680. private _hardwareScaleLevel;
  73681. private _bloomKernel;
  73682. /**
  73683. * Specifies the size of the bloom blur kernel, relative to the final output size
  73684. */
  73685. get bloomKernel(): number;
  73686. set bloomKernel(value: number);
  73687. /**
  73688. * Specifies the weight of the bloom in the final rendering
  73689. */
  73690. private _bloomWeight;
  73691. /**
  73692. * Specifies the luma threshold for the area that will be blurred by the bloom
  73693. */
  73694. private _bloomThreshold;
  73695. private _hdr;
  73696. /**
  73697. * The strength of the bloom.
  73698. */
  73699. set bloomWeight(value: number);
  73700. get bloomWeight(): number;
  73701. /**
  73702. * The strength of the bloom.
  73703. */
  73704. set bloomThreshold(value: number);
  73705. get bloomThreshold(): number;
  73706. /**
  73707. * The scale of the bloom, lower value will provide better performance.
  73708. */
  73709. set bloomScale(value: number);
  73710. get bloomScale(): number;
  73711. /**
  73712. * Enable or disable the bloom from the pipeline
  73713. */
  73714. set bloomEnabled(enabled: boolean);
  73715. get bloomEnabled(): boolean;
  73716. private _rebuildBloom;
  73717. /**
  73718. * If the depth of field is enabled.
  73719. */
  73720. get depthOfFieldEnabled(): boolean;
  73721. set depthOfFieldEnabled(enabled: boolean);
  73722. /**
  73723. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73724. */
  73725. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73726. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73727. /**
  73728. * If the anti aliasing is enabled.
  73729. */
  73730. set fxaaEnabled(enabled: boolean);
  73731. get fxaaEnabled(): boolean;
  73732. private _samples;
  73733. /**
  73734. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73735. */
  73736. set samples(sampleCount: number);
  73737. get samples(): number;
  73738. /**
  73739. * If image processing is enabled.
  73740. */
  73741. set imageProcessingEnabled(enabled: boolean);
  73742. get imageProcessingEnabled(): boolean;
  73743. /**
  73744. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73745. */
  73746. set glowLayerEnabled(enabled: boolean);
  73747. get glowLayerEnabled(): boolean;
  73748. /**
  73749. * Gets the glow layer (or null if not defined)
  73750. */
  73751. get glowLayer(): Nullable<GlowLayer>;
  73752. /**
  73753. * Enable or disable the chromaticAberration process from the pipeline
  73754. */
  73755. set chromaticAberrationEnabled(enabled: boolean);
  73756. get chromaticAberrationEnabled(): boolean;
  73757. /**
  73758. * Enable or disable the grain process from the pipeline
  73759. */
  73760. set grainEnabled(enabled: boolean);
  73761. get grainEnabled(): boolean;
  73762. /**
  73763. * @constructor
  73764. * @param name - The rendering pipeline name (default: "")
  73765. * @param hdr - If high dynamic range textures should be used (default: true)
  73766. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73767. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73768. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73769. */
  73770. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73771. /**
  73772. * Get the class name
  73773. * @returns "DefaultRenderingPipeline"
  73774. */
  73775. getClassName(): string;
  73776. /**
  73777. * Force the compilation of the entire pipeline.
  73778. */
  73779. prepare(): void;
  73780. private _hasCleared;
  73781. private _prevPostProcess;
  73782. private _prevPrevPostProcess;
  73783. private _setAutoClearAndTextureSharing;
  73784. private _depthOfFieldSceneObserver;
  73785. private _buildPipeline;
  73786. private _disposePostProcesses;
  73787. /**
  73788. * Adds a camera to the pipeline
  73789. * @param camera the camera to be added
  73790. */
  73791. addCamera(camera: Camera): void;
  73792. /**
  73793. * Removes a camera from the pipeline
  73794. * @param camera the camera to remove
  73795. */
  73796. removeCamera(camera: Camera): void;
  73797. /**
  73798. * Dispose of the pipeline and stop all post processes
  73799. */
  73800. dispose(): void;
  73801. /**
  73802. * Serialize the rendering pipeline (Used when exporting)
  73803. * @returns the serialized object
  73804. */
  73805. serialize(): any;
  73806. /**
  73807. * Parse the serialized pipeline
  73808. * @param source Source pipeline.
  73809. * @param scene The scene to load the pipeline to.
  73810. * @param rootUrl The URL of the serialized pipeline.
  73811. * @returns An instantiated pipeline from the serialized object.
  73812. */
  73813. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73814. }
  73815. }
  73816. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73817. /** @hidden */
  73818. export var lensHighlightsPixelShader: {
  73819. name: string;
  73820. shader: string;
  73821. };
  73822. }
  73823. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73824. /** @hidden */
  73825. export var depthOfFieldPixelShader: {
  73826. name: string;
  73827. shader: string;
  73828. };
  73829. }
  73830. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73831. import { Camera } from "babylonjs/Cameras/camera";
  73832. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73833. import { Scene } from "babylonjs/scene";
  73834. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73835. import "babylonjs/Shaders/chromaticAberration.fragment";
  73836. import "babylonjs/Shaders/lensHighlights.fragment";
  73837. import "babylonjs/Shaders/depthOfField.fragment";
  73838. /**
  73839. * BABYLON.JS Chromatic Aberration GLSL Shader
  73840. * Author: Olivier Guyot
  73841. * Separates very slightly R, G and B colors on the edges of the screen
  73842. * Inspired by Francois Tarlier & Martins Upitis
  73843. */
  73844. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73845. /**
  73846. * @ignore
  73847. * The chromatic aberration PostProcess id in the pipeline
  73848. */
  73849. LensChromaticAberrationEffect: string;
  73850. /**
  73851. * @ignore
  73852. * The highlights enhancing PostProcess id in the pipeline
  73853. */
  73854. HighlightsEnhancingEffect: string;
  73855. /**
  73856. * @ignore
  73857. * The depth-of-field PostProcess id in the pipeline
  73858. */
  73859. LensDepthOfFieldEffect: string;
  73860. private _scene;
  73861. private _depthTexture;
  73862. private _grainTexture;
  73863. private _chromaticAberrationPostProcess;
  73864. private _highlightsPostProcess;
  73865. private _depthOfFieldPostProcess;
  73866. private _edgeBlur;
  73867. private _grainAmount;
  73868. private _chromaticAberration;
  73869. private _distortion;
  73870. private _highlightsGain;
  73871. private _highlightsThreshold;
  73872. private _dofDistance;
  73873. private _dofAperture;
  73874. private _dofDarken;
  73875. private _dofPentagon;
  73876. private _blurNoise;
  73877. /**
  73878. * @constructor
  73879. *
  73880. * Effect parameters are as follow:
  73881. * {
  73882. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73883. * edge_blur: number; // from 0 to x (1 for realism)
  73884. * distortion: number; // from 0 to x (1 for realism)
  73885. * grain_amount: number; // from 0 to 1
  73886. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73887. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73888. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73889. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73890. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73891. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73892. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73893. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73894. * }
  73895. * Note: if an effect parameter is unset, effect is disabled
  73896. *
  73897. * @param name The rendering pipeline name
  73898. * @param parameters - An object containing all parameters (see above)
  73899. * @param scene The scene linked to this pipeline
  73900. * @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)
  73901. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73902. */
  73903. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73904. /**
  73905. * Get the class name
  73906. * @returns "LensRenderingPipeline"
  73907. */
  73908. getClassName(): string;
  73909. /**
  73910. * Gets associated scene
  73911. */
  73912. get scene(): Scene;
  73913. /**
  73914. * Gets or sets the edge blur
  73915. */
  73916. get edgeBlur(): number;
  73917. set edgeBlur(value: number);
  73918. /**
  73919. * Gets or sets the grain amount
  73920. */
  73921. get grainAmount(): number;
  73922. set grainAmount(value: number);
  73923. /**
  73924. * Gets or sets the chromatic aberration amount
  73925. */
  73926. get chromaticAberration(): number;
  73927. set chromaticAberration(value: number);
  73928. /**
  73929. * Gets or sets the depth of field aperture
  73930. */
  73931. get dofAperture(): number;
  73932. set dofAperture(value: number);
  73933. /**
  73934. * Gets or sets the edge distortion
  73935. */
  73936. get edgeDistortion(): number;
  73937. set edgeDistortion(value: number);
  73938. /**
  73939. * Gets or sets the depth of field distortion
  73940. */
  73941. get dofDistortion(): number;
  73942. set dofDistortion(value: number);
  73943. /**
  73944. * Gets or sets the darken out of focus amount
  73945. */
  73946. get darkenOutOfFocus(): number;
  73947. set darkenOutOfFocus(value: number);
  73948. /**
  73949. * Gets or sets a boolean indicating if blur noise is enabled
  73950. */
  73951. get blurNoise(): boolean;
  73952. set blurNoise(value: boolean);
  73953. /**
  73954. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73955. */
  73956. get pentagonBokeh(): boolean;
  73957. set pentagonBokeh(value: boolean);
  73958. /**
  73959. * Gets or sets the highlight grain amount
  73960. */
  73961. get highlightsGain(): number;
  73962. set highlightsGain(value: number);
  73963. /**
  73964. * Gets or sets the highlight threshold
  73965. */
  73966. get highlightsThreshold(): number;
  73967. set highlightsThreshold(value: number);
  73968. /**
  73969. * Sets the amount of blur at the edges
  73970. * @param amount blur amount
  73971. */
  73972. setEdgeBlur(amount: number): void;
  73973. /**
  73974. * Sets edge blur to 0
  73975. */
  73976. disableEdgeBlur(): void;
  73977. /**
  73978. * Sets the amout of grain
  73979. * @param amount Amount of grain
  73980. */
  73981. setGrainAmount(amount: number): void;
  73982. /**
  73983. * Set grain amount to 0
  73984. */
  73985. disableGrain(): void;
  73986. /**
  73987. * Sets the chromatic aberration amount
  73988. * @param amount amount of chromatic aberration
  73989. */
  73990. setChromaticAberration(amount: number): void;
  73991. /**
  73992. * Sets chromatic aberration amount to 0
  73993. */
  73994. disableChromaticAberration(): void;
  73995. /**
  73996. * Sets the EdgeDistortion amount
  73997. * @param amount amount of EdgeDistortion
  73998. */
  73999. setEdgeDistortion(amount: number): void;
  74000. /**
  74001. * Sets edge distortion to 0
  74002. */
  74003. disableEdgeDistortion(): void;
  74004. /**
  74005. * Sets the FocusDistance amount
  74006. * @param amount amount of FocusDistance
  74007. */
  74008. setFocusDistance(amount: number): void;
  74009. /**
  74010. * Disables depth of field
  74011. */
  74012. disableDepthOfField(): void;
  74013. /**
  74014. * Sets the Aperture amount
  74015. * @param amount amount of Aperture
  74016. */
  74017. setAperture(amount: number): void;
  74018. /**
  74019. * Sets the DarkenOutOfFocus amount
  74020. * @param amount amount of DarkenOutOfFocus
  74021. */
  74022. setDarkenOutOfFocus(amount: number): void;
  74023. private _pentagonBokehIsEnabled;
  74024. /**
  74025. * Creates a pentagon bokeh effect
  74026. */
  74027. enablePentagonBokeh(): void;
  74028. /**
  74029. * Disables the pentagon bokeh effect
  74030. */
  74031. disablePentagonBokeh(): void;
  74032. /**
  74033. * Enables noise blur
  74034. */
  74035. enableNoiseBlur(): void;
  74036. /**
  74037. * Disables noise blur
  74038. */
  74039. disableNoiseBlur(): void;
  74040. /**
  74041. * Sets the HighlightsGain amount
  74042. * @param amount amount of HighlightsGain
  74043. */
  74044. setHighlightsGain(amount: number): void;
  74045. /**
  74046. * Sets the HighlightsThreshold amount
  74047. * @param amount amount of HighlightsThreshold
  74048. */
  74049. setHighlightsThreshold(amount: number): void;
  74050. /**
  74051. * Disables highlights
  74052. */
  74053. disableHighlights(): void;
  74054. /**
  74055. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74056. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74057. */
  74058. dispose(disableDepthRender?: boolean): void;
  74059. private _createChromaticAberrationPostProcess;
  74060. private _createHighlightsPostProcess;
  74061. private _createDepthOfFieldPostProcess;
  74062. private _createGrainTexture;
  74063. }
  74064. }
  74065. declare module "babylonjs/Shaders/ssao2.fragment" {
  74066. /** @hidden */
  74067. export var ssao2PixelShader: {
  74068. name: string;
  74069. shader: string;
  74070. };
  74071. }
  74072. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74073. /** @hidden */
  74074. export var ssaoCombinePixelShader: {
  74075. name: string;
  74076. shader: string;
  74077. };
  74078. }
  74079. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74080. import { Camera } from "babylonjs/Cameras/camera";
  74081. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74082. import { Scene } from "babylonjs/scene";
  74083. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74084. import "babylonjs/Shaders/ssao2.fragment";
  74085. import "babylonjs/Shaders/ssaoCombine.fragment";
  74086. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74087. /**
  74088. * Render pipeline to produce ssao effect
  74089. */
  74090. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74091. /**
  74092. * @ignore
  74093. * The PassPostProcess id in the pipeline that contains the original scene color
  74094. */
  74095. SSAOOriginalSceneColorEffect: string;
  74096. /**
  74097. * @ignore
  74098. * The SSAO PostProcess id in the pipeline
  74099. */
  74100. SSAORenderEffect: string;
  74101. /**
  74102. * @ignore
  74103. * The horizontal blur PostProcess id in the pipeline
  74104. */
  74105. SSAOBlurHRenderEffect: string;
  74106. /**
  74107. * @ignore
  74108. * The vertical blur PostProcess id in the pipeline
  74109. */
  74110. SSAOBlurVRenderEffect: string;
  74111. /**
  74112. * @ignore
  74113. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74114. */
  74115. SSAOCombineRenderEffect: string;
  74116. /**
  74117. * The output strength of the SSAO post-process. Default value is 1.0.
  74118. */
  74119. totalStrength: number;
  74120. /**
  74121. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74122. */
  74123. maxZ: number;
  74124. /**
  74125. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74126. */
  74127. minZAspect: number;
  74128. private _samples;
  74129. /**
  74130. * Number of samples used for the SSAO calculations. Default value is 8
  74131. */
  74132. set samples(n: number);
  74133. get samples(): number;
  74134. private _textureSamples;
  74135. /**
  74136. * Number of samples to use for antialiasing
  74137. */
  74138. set textureSamples(n: number);
  74139. get textureSamples(): number;
  74140. /**
  74141. * Force rendering the geometry through geometry buffer
  74142. */
  74143. private _forceGeometryBuffer;
  74144. /**
  74145. * Ratio object used for SSAO ratio and blur ratio
  74146. */
  74147. private _ratio;
  74148. /**
  74149. * Dynamically generated sphere sampler.
  74150. */
  74151. private _sampleSphere;
  74152. /**
  74153. * Blur filter offsets
  74154. */
  74155. private _samplerOffsets;
  74156. private _expensiveBlur;
  74157. /**
  74158. * If bilateral blur should be used
  74159. */
  74160. set expensiveBlur(b: boolean);
  74161. get expensiveBlur(): boolean;
  74162. /**
  74163. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74164. */
  74165. radius: number;
  74166. /**
  74167. * The base color of the SSAO post-process
  74168. * The final result is "base + ssao" between [0, 1]
  74169. */
  74170. base: number;
  74171. /**
  74172. * Support test.
  74173. */
  74174. static get IsSupported(): boolean;
  74175. private _scene;
  74176. private _randomTexture;
  74177. private _originalColorPostProcess;
  74178. private _ssaoPostProcess;
  74179. private _blurHPostProcess;
  74180. private _blurVPostProcess;
  74181. private _ssaoCombinePostProcess;
  74182. private _prePassRenderer;
  74183. /**
  74184. * Gets active scene
  74185. */
  74186. get scene(): Scene;
  74187. /**
  74188. * @constructor
  74189. * @param name The rendering pipeline name
  74190. * @param scene The scene linked to this pipeline
  74191. * @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 }
  74192. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74193. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74194. */
  74195. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74196. /**
  74197. * Get the class name
  74198. * @returns "SSAO2RenderingPipeline"
  74199. */
  74200. getClassName(): string;
  74201. /**
  74202. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74203. */
  74204. dispose(disableGeometryBufferRenderer?: boolean): void;
  74205. private _createBlurPostProcess;
  74206. /** @hidden */
  74207. _rebuild(): void;
  74208. private _bits;
  74209. private _radicalInverse_VdC;
  74210. private _hammersley;
  74211. private _hemisphereSample_uniform;
  74212. private _generateHemisphere;
  74213. private _getDefinesForSSAO;
  74214. private _createSSAOPostProcess;
  74215. private _createSSAOCombinePostProcess;
  74216. private _createRandomTexture;
  74217. /**
  74218. * Serialize the rendering pipeline (Used when exporting)
  74219. * @returns the serialized object
  74220. */
  74221. serialize(): any;
  74222. /**
  74223. * Parse the serialized pipeline
  74224. * @param source Source pipeline.
  74225. * @param scene The scene to load the pipeline to.
  74226. * @param rootUrl The URL of the serialized pipeline.
  74227. * @returns An instantiated pipeline from the serialized object.
  74228. */
  74229. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74230. /**
  74231. * Sets the required values to the prepass renderer.
  74232. * @param prePassRenderer defines the prepass renderer to setup
  74233. * @returns true if the pre pass is needed.
  74234. */
  74235. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74236. }
  74237. }
  74238. declare module "babylonjs/Shaders/ssao.fragment" {
  74239. /** @hidden */
  74240. export var ssaoPixelShader: {
  74241. name: string;
  74242. shader: string;
  74243. };
  74244. }
  74245. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74246. import { Camera } from "babylonjs/Cameras/camera";
  74247. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74248. import { Scene } from "babylonjs/scene";
  74249. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74250. import "babylonjs/Shaders/ssao.fragment";
  74251. import "babylonjs/Shaders/ssaoCombine.fragment";
  74252. /**
  74253. * Render pipeline to produce ssao effect
  74254. */
  74255. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74256. /**
  74257. * @ignore
  74258. * The PassPostProcess id in the pipeline that contains the original scene color
  74259. */
  74260. SSAOOriginalSceneColorEffect: string;
  74261. /**
  74262. * @ignore
  74263. * The SSAO PostProcess id in the pipeline
  74264. */
  74265. SSAORenderEffect: string;
  74266. /**
  74267. * @ignore
  74268. * The horizontal blur PostProcess id in the pipeline
  74269. */
  74270. SSAOBlurHRenderEffect: string;
  74271. /**
  74272. * @ignore
  74273. * The vertical blur PostProcess id in the pipeline
  74274. */
  74275. SSAOBlurVRenderEffect: string;
  74276. /**
  74277. * @ignore
  74278. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74279. */
  74280. SSAOCombineRenderEffect: string;
  74281. /**
  74282. * The output strength of the SSAO post-process. Default value is 1.0.
  74283. */
  74284. totalStrength: number;
  74285. /**
  74286. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74287. */
  74288. radius: number;
  74289. /**
  74290. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74291. * Must not be equal to fallOff and superior to fallOff.
  74292. * Default value is 0.0075
  74293. */
  74294. area: number;
  74295. /**
  74296. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74297. * Must not be equal to area and inferior to area.
  74298. * Default value is 0.000001
  74299. */
  74300. fallOff: number;
  74301. /**
  74302. * The base color of the SSAO post-process
  74303. * The final result is "base + ssao" between [0, 1]
  74304. */
  74305. base: number;
  74306. private _scene;
  74307. private _depthTexture;
  74308. private _randomTexture;
  74309. private _originalColorPostProcess;
  74310. private _ssaoPostProcess;
  74311. private _blurHPostProcess;
  74312. private _blurVPostProcess;
  74313. private _ssaoCombinePostProcess;
  74314. private _firstUpdate;
  74315. /**
  74316. * Gets active scene
  74317. */
  74318. get scene(): Scene;
  74319. /**
  74320. * @constructor
  74321. * @param name - The rendering pipeline name
  74322. * @param scene - The scene linked to this pipeline
  74323. * @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 }
  74324. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74325. */
  74326. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74327. /**
  74328. * Get the class name
  74329. * @returns "SSAORenderingPipeline"
  74330. */
  74331. getClassName(): string;
  74332. /**
  74333. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74334. */
  74335. dispose(disableDepthRender?: boolean): void;
  74336. private _createBlurPostProcess;
  74337. /** @hidden */
  74338. _rebuild(): void;
  74339. private _createSSAOPostProcess;
  74340. private _createSSAOCombinePostProcess;
  74341. private _createRandomTexture;
  74342. }
  74343. }
  74344. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74345. /** @hidden */
  74346. export var screenSpaceReflectionPixelShader: {
  74347. name: string;
  74348. shader: string;
  74349. };
  74350. }
  74351. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74352. import { Nullable } from "babylonjs/types";
  74353. import { Camera } from "babylonjs/Cameras/camera";
  74354. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74355. import { Scene } from "babylonjs/scene";
  74356. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74357. import { Engine } from "babylonjs/Engines/engine";
  74358. /**
  74359. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74360. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74361. */
  74362. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74363. /**
  74364. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74365. */
  74366. threshold: number;
  74367. /**
  74368. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74369. */
  74370. strength: number;
  74371. /**
  74372. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74373. */
  74374. reflectionSpecularFalloffExponent: number;
  74375. /**
  74376. * 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]
  74377. */
  74378. step: number;
  74379. /**
  74380. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74381. */
  74382. roughnessFactor: number;
  74383. private _geometryBufferRenderer;
  74384. private _enableSmoothReflections;
  74385. private _reflectionSamples;
  74386. private _smoothSteps;
  74387. /**
  74388. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74389. * @param name The name of the effect.
  74390. * @param scene The scene containing the objects to calculate reflections.
  74391. * @param options The required width/height ratio to downsize to before computing the render pass.
  74392. * @param camera The camera to apply the render pass to.
  74393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74394. * @param engine The engine which the post process will be applied. (default: current engine)
  74395. * @param reusable If the post process can be reused on the same frame. (default: false)
  74396. * @param textureType Type of textures used when performing the post process. (default: 0)
  74397. * @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)
  74398. */
  74399. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74400. /**
  74401. * Gets wether or not smoothing reflections is enabled.
  74402. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74403. */
  74404. get enableSmoothReflections(): boolean;
  74405. /**
  74406. * Sets wether or not smoothing reflections is enabled.
  74407. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74408. */
  74409. set enableSmoothReflections(enabled: boolean);
  74410. /**
  74411. * Gets 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. get reflectionSamples(): number;
  74415. /**
  74416. * Sets the number of samples taken while computing reflections. More samples count is high,
  74417. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74418. */
  74419. set reflectionSamples(samples: number);
  74420. /**
  74421. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74422. * more the post-process will require GPU power and can generate a drop in FPS.
  74423. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74424. */
  74425. get smoothSteps(): number;
  74426. set smoothSteps(steps: number);
  74427. private _updateEffectDefines;
  74428. }
  74429. }
  74430. declare module "babylonjs/Shaders/standard.fragment" {
  74431. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74432. /** @hidden */
  74433. export var standardPixelShader: {
  74434. name: string;
  74435. shader: string;
  74436. };
  74437. }
  74438. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74439. import { Nullable } from "babylonjs/types";
  74440. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74441. import { Camera } from "babylonjs/Cameras/camera";
  74442. import { Texture } from "babylonjs/Materials/Textures/texture";
  74443. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74444. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74445. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74446. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74447. import { IDisposable } from "babylonjs/scene";
  74448. import { SpotLight } from "babylonjs/Lights/spotLight";
  74449. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74450. import { Scene } from "babylonjs/scene";
  74451. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74452. import { Animation } from "babylonjs/Animations/animation";
  74453. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74454. import "babylonjs/Shaders/standard.fragment";
  74455. /**
  74456. * Standard rendering pipeline
  74457. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74458. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74459. */
  74460. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74461. /**
  74462. * Public members
  74463. */
  74464. /**
  74465. * Post-process which contains the original scene color before the pipeline applies all the effects
  74466. */
  74467. originalPostProcess: Nullable<PostProcess>;
  74468. /**
  74469. * Post-process used to down scale an image x4
  74470. */
  74471. downSampleX4PostProcess: Nullable<PostProcess>;
  74472. /**
  74473. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74474. */
  74475. brightPassPostProcess: Nullable<PostProcess>;
  74476. /**
  74477. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74478. */
  74479. blurHPostProcesses: PostProcess[];
  74480. /**
  74481. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74482. */
  74483. blurVPostProcesses: PostProcess[];
  74484. /**
  74485. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74486. */
  74487. textureAdderPostProcess: Nullable<PostProcess>;
  74488. /**
  74489. * Post-process used to create volumetric lighting effect
  74490. */
  74491. volumetricLightPostProcess: Nullable<PostProcess>;
  74492. /**
  74493. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74494. */
  74495. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74496. /**
  74497. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74498. */
  74499. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74500. /**
  74501. * Post-process used to merge the volumetric light effect and the real scene color
  74502. */
  74503. volumetricLightMergePostProces: Nullable<PostProcess>;
  74504. /**
  74505. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74506. */
  74507. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74508. /**
  74509. * Base post-process used to calculate the average luminance of the final image for HDR
  74510. */
  74511. luminancePostProcess: Nullable<PostProcess>;
  74512. /**
  74513. * Post-processes used to create down sample post-processes in order to get
  74514. * the average luminance of the final image for HDR
  74515. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74516. */
  74517. luminanceDownSamplePostProcesses: PostProcess[];
  74518. /**
  74519. * Post-process used to create a HDR effect (light adaptation)
  74520. */
  74521. hdrPostProcess: Nullable<PostProcess>;
  74522. /**
  74523. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74524. */
  74525. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74526. /**
  74527. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74528. */
  74529. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74530. /**
  74531. * Post-process used to merge the final HDR post-process and the real scene color
  74532. */
  74533. hdrFinalPostProcess: Nullable<PostProcess>;
  74534. /**
  74535. * Post-process used to create a lens flare effect
  74536. */
  74537. lensFlarePostProcess: Nullable<PostProcess>;
  74538. /**
  74539. * Post-process that merges the result of the lens flare post-process and the real scene color
  74540. */
  74541. lensFlareComposePostProcess: Nullable<PostProcess>;
  74542. /**
  74543. * Post-process used to create a motion blur effect
  74544. */
  74545. motionBlurPostProcess: Nullable<PostProcess>;
  74546. /**
  74547. * Post-process used to create a depth of field effect
  74548. */
  74549. depthOfFieldPostProcess: Nullable<PostProcess>;
  74550. /**
  74551. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74552. */
  74553. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74554. /**
  74555. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74556. */
  74557. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74558. /**
  74559. * Represents the brightness threshold in order to configure the illuminated surfaces
  74560. */
  74561. brightThreshold: number;
  74562. /**
  74563. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74564. */
  74565. blurWidth: number;
  74566. /**
  74567. * Sets if the blur for highlighted surfaces must be only horizontal
  74568. */
  74569. horizontalBlur: boolean;
  74570. /**
  74571. * Gets the overall exposure used by the pipeline
  74572. */
  74573. get exposure(): number;
  74574. /**
  74575. * Sets the overall exposure used by the pipeline
  74576. */
  74577. set exposure(value: number);
  74578. /**
  74579. * Texture used typically to simulate "dirty" on camera lens
  74580. */
  74581. lensTexture: Nullable<Texture>;
  74582. /**
  74583. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74584. */
  74585. volumetricLightCoefficient: number;
  74586. /**
  74587. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74588. */
  74589. volumetricLightPower: number;
  74590. /**
  74591. * Used the set the blur intensity to smooth the volumetric lights
  74592. */
  74593. volumetricLightBlurScale: number;
  74594. /**
  74595. * Light (spot or directional) used to generate the volumetric lights rays
  74596. * The source light must have a shadow generate so the pipeline can get its
  74597. * depth map
  74598. */
  74599. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74600. /**
  74601. * For eye adaptation, represents the minimum luminance the eye can see
  74602. */
  74603. hdrMinimumLuminance: number;
  74604. /**
  74605. * For eye adaptation, represents the decrease luminance speed
  74606. */
  74607. hdrDecreaseRate: number;
  74608. /**
  74609. * For eye adaptation, represents the increase luminance speed
  74610. */
  74611. hdrIncreaseRate: number;
  74612. /**
  74613. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74614. */
  74615. get hdrAutoExposure(): boolean;
  74616. /**
  74617. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74618. */
  74619. set hdrAutoExposure(value: boolean);
  74620. /**
  74621. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74622. */
  74623. lensColorTexture: Nullable<Texture>;
  74624. /**
  74625. * The overall strengh for the lens flare effect
  74626. */
  74627. lensFlareStrength: number;
  74628. /**
  74629. * Dispersion coefficient for lens flare ghosts
  74630. */
  74631. lensFlareGhostDispersal: number;
  74632. /**
  74633. * Main lens flare halo width
  74634. */
  74635. lensFlareHaloWidth: number;
  74636. /**
  74637. * Based on the lens distortion effect, defines how much the lens flare result
  74638. * is distorted
  74639. */
  74640. lensFlareDistortionStrength: number;
  74641. /**
  74642. * Configures the blur intensity used for for lens flare (halo)
  74643. */
  74644. lensFlareBlurWidth: number;
  74645. /**
  74646. * Lens star texture must be used to simulate rays on the flares and is available
  74647. * in the documentation
  74648. */
  74649. lensStarTexture: Nullable<Texture>;
  74650. /**
  74651. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74652. * flare effect by taking account of the dirt texture
  74653. */
  74654. lensFlareDirtTexture: Nullable<Texture>;
  74655. /**
  74656. * Represents the focal length for the depth of field effect
  74657. */
  74658. depthOfFieldDistance: number;
  74659. /**
  74660. * Represents the blur intensity for the blurred part of the depth of field effect
  74661. */
  74662. depthOfFieldBlurWidth: number;
  74663. /**
  74664. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74665. */
  74666. get motionStrength(): number;
  74667. /**
  74668. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74669. */
  74670. set motionStrength(strength: number);
  74671. /**
  74672. * Gets wether or not the motion blur post-process is object based or screen based.
  74673. */
  74674. get objectBasedMotionBlur(): boolean;
  74675. /**
  74676. * Sets wether or not the motion blur post-process should be object based or screen based
  74677. */
  74678. set objectBasedMotionBlur(value: boolean);
  74679. /**
  74680. * List of animations for the pipeline (IAnimatable implementation)
  74681. */
  74682. animations: Animation[];
  74683. /**
  74684. * Private members
  74685. */
  74686. private _scene;
  74687. private _currentDepthOfFieldSource;
  74688. private _basePostProcess;
  74689. private _fixedExposure;
  74690. private _currentExposure;
  74691. private _hdrAutoExposure;
  74692. private _hdrCurrentLuminance;
  74693. private _motionStrength;
  74694. private _isObjectBasedMotionBlur;
  74695. private _floatTextureType;
  74696. private _camerasToBeAttached;
  74697. private _ratio;
  74698. private _bloomEnabled;
  74699. private _depthOfFieldEnabled;
  74700. private _vlsEnabled;
  74701. private _lensFlareEnabled;
  74702. private _hdrEnabled;
  74703. private _motionBlurEnabled;
  74704. private _fxaaEnabled;
  74705. private _screenSpaceReflectionsEnabled;
  74706. private _motionBlurSamples;
  74707. private _volumetricLightStepsCount;
  74708. private _samples;
  74709. /**
  74710. * @ignore
  74711. * Specifies if the bloom pipeline is enabled
  74712. */
  74713. get BloomEnabled(): boolean;
  74714. set BloomEnabled(enabled: boolean);
  74715. /**
  74716. * @ignore
  74717. * Specifies if the depth of field pipeline is enabed
  74718. */
  74719. get DepthOfFieldEnabled(): boolean;
  74720. set DepthOfFieldEnabled(enabled: boolean);
  74721. /**
  74722. * @ignore
  74723. * Specifies if the lens flare pipeline is enabed
  74724. */
  74725. get LensFlareEnabled(): boolean;
  74726. set LensFlareEnabled(enabled: boolean);
  74727. /**
  74728. * @ignore
  74729. * Specifies if the HDR pipeline is enabled
  74730. */
  74731. get HDREnabled(): boolean;
  74732. set HDREnabled(enabled: boolean);
  74733. /**
  74734. * @ignore
  74735. * Specifies if the volumetric lights scattering effect is enabled
  74736. */
  74737. get VLSEnabled(): boolean;
  74738. set VLSEnabled(enabled: boolean);
  74739. /**
  74740. * @ignore
  74741. * Specifies if the motion blur effect is enabled
  74742. */
  74743. get MotionBlurEnabled(): boolean;
  74744. set MotionBlurEnabled(enabled: boolean);
  74745. /**
  74746. * Specifies if anti-aliasing is enabled
  74747. */
  74748. get fxaaEnabled(): boolean;
  74749. set fxaaEnabled(enabled: boolean);
  74750. /**
  74751. * Specifies if screen space reflections are enabled.
  74752. */
  74753. get screenSpaceReflectionsEnabled(): boolean;
  74754. set screenSpaceReflectionsEnabled(enabled: boolean);
  74755. /**
  74756. * Specifies the number of steps used to calculate the volumetric lights
  74757. * Typically in interval [50, 200]
  74758. */
  74759. get volumetricLightStepsCount(): number;
  74760. set volumetricLightStepsCount(count: number);
  74761. /**
  74762. * Specifies the number of samples used for the motion blur effect
  74763. * Typically in interval [16, 64]
  74764. */
  74765. get motionBlurSamples(): number;
  74766. set motionBlurSamples(samples: number);
  74767. /**
  74768. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74769. */
  74770. get samples(): number;
  74771. set samples(sampleCount: number);
  74772. /**
  74773. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74774. * @constructor
  74775. * @param name The rendering pipeline name
  74776. * @param scene The scene linked to this pipeline
  74777. * @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)
  74778. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74779. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74780. */
  74781. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74782. private _buildPipeline;
  74783. private _createDownSampleX4PostProcess;
  74784. private _createBrightPassPostProcess;
  74785. private _createBlurPostProcesses;
  74786. private _createTextureAdderPostProcess;
  74787. private _createVolumetricLightPostProcess;
  74788. private _createLuminancePostProcesses;
  74789. private _createHdrPostProcess;
  74790. private _createLensFlarePostProcess;
  74791. private _createDepthOfFieldPostProcess;
  74792. private _createMotionBlurPostProcess;
  74793. private _getDepthTexture;
  74794. private _disposePostProcesses;
  74795. /**
  74796. * Dispose of the pipeline and stop all post processes
  74797. */
  74798. dispose(): void;
  74799. /**
  74800. * Serialize the rendering pipeline (Used when exporting)
  74801. * @returns the serialized object
  74802. */
  74803. serialize(): any;
  74804. /**
  74805. * Parse the serialized pipeline
  74806. * @param source Source pipeline.
  74807. * @param scene The scene to load the pipeline to.
  74808. * @param rootUrl The URL of the serialized pipeline.
  74809. * @returns An instantiated pipeline from the serialized object.
  74810. */
  74811. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74812. /**
  74813. * Luminance steps
  74814. */
  74815. static LuminanceSteps: number;
  74816. }
  74817. }
  74818. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74819. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74820. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74821. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74822. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74823. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74824. }
  74825. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74826. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74827. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74828. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74829. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74830. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74831. }
  74832. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74833. /** @hidden */
  74834. export var stereoscopicInterlacePixelShader: {
  74835. name: string;
  74836. shader: string;
  74837. };
  74838. }
  74839. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74840. import { Camera } from "babylonjs/Cameras/camera";
  74841. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74842. import { Engine } from "babylonjs/Engines/engine";
  74843. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74844. /**
  74845. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74846. */
  74847. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74848. private _stepSize;
  74849. private _passedProcess;
  74850. /**
  74851. * Initializes a StereoscopicInterlacePostProcessI
  74852. * @param name The name of the effect.
  74853. * @param rigCameras The rig cameras to be appled to the post process
  74854. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74855. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74857. * @param engine The engine which the post process will be applied. (default: current engine)
  74858. * @param reusable If the post process can be reused on the same frame. (default: false)
  74859. */
  74860. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74861. }
  74862. /**
  74863. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74864. */
  74865. export class StereoscopicInterlacePostProcess extends PostProcess {
  74866. private _stepSize;
  74867. private _passedProcess;
  74868. /**
  74869. * Initializes a StereoscopicInterlacePostProcess
  74870. * @param name The name of the effect.
  74871. * @param rigCameras The rig cameras to be appled to the post process
  74872. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74874. * @param engine The engine which the post process will be applied. (default: current engine)
  74875. * @param reusable If the post process can be reused on the same frame. (default: false)
  74876. */
  74877. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74878. }
  74879. }
  74880. declare module "babylonjs/Shaders/tonemap.fragment" {
  74881. /** @hidden */
  74882. export var tonemapPixelShader: {
  74883. name: string;
  74884. shader: string;
  74885. };
  74886. }
  74887. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74888. import { Camera } from "babylonjs/Cameras/camera";
  74889. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74890. import "babylonjs/Shaders/tonemap.fragment";
  74891. import { Engine } from "babylonjs/Engines/engine";
  74892. /** Defines operator used for tonemapping */
  74893. export enum TonemappingOperator {
  74894. /** Hable */
  74895. Hable = 0,
  74896. /** Reinhard */
  74897. Reinhard = 1,
  74898. /** HejiDawson */
  74899. HejiDawson = 2,
  74900. /** Photographic */
  74901. Photographic = 3
  74902. }
  74903. /**
  74904. * Defines a post process to apply tone mapping
  74905. */
  74906. export class TonemapPostProcess extends PostProcess {
  74907. private _operator;
  74908. /** Defines the required exposure adjustement */
  74909. exposureAdjustment: number;
  74910. /**
  74911. * Creates a new TonemapPostProcess
  74912. * @param name defines the name of the postprocess
  74913. * @param _operator defines the operator to use
  74914. * @param exposureAdjustment defines the required exposure adjustement
  74915. * @param camera defines the camera to use (can be null)
  74916. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74917. * @param engine defines the hosting engine (can be ignore if camera is set)
  74918. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74919. */
  74920. constructor(name: string, _operator: TonemappingOperator,
  74921. /** Defines the required exposure adjustement */
  74922. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74923. }
  74924. }
  74925. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74926. /** @hidden */
  74927. export var volumetricLightScatteringPixelShader: {
  74928. name: string;
  74929. shader: string;
  74930. };
  74931. }
  74932. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74933. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74934. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74935. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74936. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74937. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74938. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74939. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74940. /** @hidden */
  74941. export var volumetricLightScatteringPassVertexShader: {
  74942. name: string;
  74943. shader: string;
  74944. };
  74945. }
  74946. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74947. /** @hidden */
  74948. export var volumetricLightScatteringPassPixelShader: {
  74949. name: string;
  74950. shader: string;
  74951. };
  74952. }
  74953. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74954. import { Vector3 } from "babylonjs/Maths/math.vector";
  74955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74956. import { Mesh } from "babylonjs/Meshes/mesh";
  74957. import { Camera } from "babylonjs/Cameras/camera";
  74958. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74959. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74960. import { Scene } from "babylonjs/scene";
  74961. import "babylonjs/Meshes/Builders/planeBuilder";
  74962. import "babylonjs/Shaders/depth.vertex";
  74963. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74964. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74965. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74966. import { Engine } from "babylonjs/Engines/engine";
  74967. /**
  74968. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74969. */
  74970. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74971. private _volumetricLightScatteringPass;
  74972. private _volumetricLightScatteringRTT;
  74973. private _viewPort;
  74974. private _screenCoordinates;
  74975. private _cachedDefines;
  74976. /**
  74977. * If not undefined, the mesh position is computed from the attached node position
  74978. */
  74979. attachedNode: {
  74980. position: Vector3;
  74981. };
  74982. /**
  74983. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74984. */
  74985. customMeshPosition: Vector3;
  74986. /**
  74987. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74988. */
  74989. useCustomMeshPosition: boolean;
  74990. /**
  74991. * If the post-process should inverse the light scattering direction
  74992. */
  74993. invert: boolean;
  74994. /**
  74995. * The internal mesh used by the post-process
  74996. */
  74997. mesh: Mesh;
  74998. /**
  74999. * @hidden
  75000. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75001. */
  75002. get useDiffuseColor(): boolean;
  75003. set useDiffuseColor(useDiffuseColor: boolean);
  75004. /**
  75005. * Array containing the excluded meshes not rendered in the internal pass
  75006. */
  75007. excludedMeshes: AbstractMesh[];
  75008. /**
  75009. * Controls the overall intensity of the post-process
  75010. */
  75011. exposure: number;
  75012. /**
  75013. * Dissipates each sample's contribution in range [0, 1]
  75014. */
  75015. decay: number;
  75016. /**
  75017. * Controls the overall intensity of each sample
  75018. */
  75019. weight: number;
  75020. /**
  75021. * Controls the density of each sample
  75022. */
  75023. density: number;
  75024. /**
  75025. * @constructor
  75026. * @param name The post-process name
  75027. * @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)
  75028. * @param camera The camera that the post-process will be attached to
  75029. * @param mesh The mesh used to create the light scattering
  75030. * @param samples The post-process quality, default 100
  75031. * @param samplingModeThe post-process filtering mode
  75032. * @param engine The babylon engine
  75033. * @param reusable If the post-process is reusable
  75034. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75035. */
  75036. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75037. /**
  75038. * Returns the string "VolumetricLightScatteringPostProcess"
  75039. * @returns "VolumetricLightScatteringPostProcess"
  75040. */
  75041. getClassName(): string;
  75042. private _isReady;
  75043. /**
  75044. * Sets the new light position for light scattering effect
  75045. * @param position The new custom light position
  75046. */
  75047. setCustomMeshPosition(position: Vector3): void;
  75048. /**
  75049. * Returns the light position for light scattering effect
  75050. * @return Vector3 The custom light position
  75051. */
  75052. getCustomMeshPosition(): Vector3;
  75053. /**
  75054. * Disposes the internal assets and detaches the post-process from the camera
  75055. */
  75056. dispose(camera: Camera): void;
  75057. /**
  75058. * Returns the render target texture used by the post-process
  75059. * @return the render target texture used by the post-process
  75060. */
  75061. getPass(): RenderTargetTexture;
  75062. private _meshExcluded;
  75063. private _createPass;
  75064. private _updateMeshScreenCoordinates;
  75065. /**
  75066. * Creates a default mesh for the Volumeric Light Scattering post-process
  75067. * @param name The mesh name
  75068. * @param scene The scene where to create the mesh
  75069. * @return the default mesh
  75070. */
  75071. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75072. }
  75073. }
  75074. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75075. /** @hidden */
  75076. export var screenSpaceCurvaturePixelShader: {
  75077. name: string;
  75078. shader: string;
  75079. };
  75080. }
  75081. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75082. import { Nullable } from "babylonjs/types";
  75083. import { Camera } from "babylonjs/Cameras/camera";
  75084. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75085. import { Scene } from "babylonjs/scene";
  75086. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75087. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75088. import { Engine } from "babylonjs/Engines/engine";
  75089. /**
  75090. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75091. */
  75092. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75093. /**
  75094. * Defines how much ridge the curvature effect displays.
  75095. */
  75096. ridge: number;
  75097. /**
  75098. * Defines how much valley the curvature effect displays.
  75099. */
  75100. valley: number;
  75101. private _geometryBufferRenderer;
  75102. /**
  75103. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75104. * @param name The name of the effect.
  75105. * @param scene The scene containing the objects to blur according to their velocity.
  75106. * @param options The required width/height ratio to downsize to before computing the render pass.
  75107. * @param camera The camera to apply the render pass to.
  75108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75109. * @param engine The engine which the post process will be applied. (default: current engine)
  75110. * @param reusable If the post process can be reused on the same frame. (default: false)
  75111. * @param textureType Type of textures used when performing the post process. (default: 0)
  75112. * @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)
  75113. */
  75114. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75115. /**
  75116. * Support test.
  75117. */
  75118. static get IsSupported(): boolean;
  75119. }
  75120. }
  75121. declare module "babylonjs/PostProcesses/index" {
  75122. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75123. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75124. export * from "babylonjs/PostProcesses/bloomEffect";
  75125. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75126. export * from "babylonjs/PostProcesses/blurPostProcess";
  75127. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75128. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75129. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75130. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75131. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75132. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75133. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75134. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75135. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75136. export * from "babylonjs/PostProcesses/filterPostProcess";
  75137. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75138. export * from "babylonjs/PostProcesses/grainPostProcess";
  75139. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75140. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75141. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75142. export * from "babylonjs/PostProcesses/passPostProcess";
  75143. export * from "babylonjs/PostProcesses/postProcess";
  75144. export * from "babylonjs/PostProcesses/postProcessManager";
  75145. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75146. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75147. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75148. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75149. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75150. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75151. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75152. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75153. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75154. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75155. }
  75156. declare module "babylonjs/Probes/index" {
  75157. export * from "babylonjs/Probes/reflectionProbe";
  75158. }
  75159. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75160. import { Scene } from "babylonjs/scene";
  75161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75162. import { SmartArray } from "babylonjs/Misc/smartArray";
  75163. import { ISceneComponent } from "babylonjs/sceneComponent";
  75164. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75165. import "babylonjs/Meshes/Builders/boxBuilder";
  75166. import "babylonjs/Shaders/color.fragment";
  75167. import "babylonjs/Shaders/color.vertex";
  75168. import { Color3 } from "babylonjs/Maths/math.color";
  75169. import { Observable } from "babylonjs/Misc/observable";
  75170. module "babylonjs/scene" {
  75171. interface Scene {
  75172. /** @hidden (Backing field) */
  75173. _boundingBoxRenderer: BoundingBoxRenderer;
  75174. /** @hidden (Backing field) */
  75175. _forceShowBoundingBoxes: boolean;
  75176. /**
  75177. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75178. */
  75179. forceShowBoundingBoxes: boolean;
  75180. /**
  75181. * Gets the bounding box renderer associated with the scene
  75182. * @returns a BoundingBoxRenderer
  75183. */
  75184. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75185. }
  75186. }
  75187. module "babylonjs/Meshes/abstractMesh" {
  75188. interface AbstractMesh {
  75189. /** @hidden (Backing field) */
  75190. _showBoundingBox: boolean;
  75191. /**
  75192. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75193. */
  75194. showBoundingBox: boolean;
  75195. }
  75196. }
  75197. /**
  75198. * Component responsible of rendering the bounding box of the meshes in a scene.
  75199. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75200. */
  75201. export class BoundingBoxRenderer implements ISceneComponent {
  75202. /**
  75203. * The component name helpfull to identify the component in the list of scene components.
  75204. */
  75205. readonly name: string;
  75206. /**
  75207. * The scene the component belongs to.
  75208. */
  75209. scene: Scene;
  75210. /**
  75211. * Color of the bounding box lines placed in front of an object
  75212. */
  75213. frontColor: Color3;
  75214. /**
  75215. * Color of the bounding box lines placed behind an object
  75216. */
  75217. backColor: Color3;
  75218. /**
  75219. * Defines if the renderer should show the back lines or not
  75220. */
  75221. showBackLines: boolean;
  75222. /**
  75223. * Observable raised before rendering a bounding box
  75224. */
  75225. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75226. /**
  75227. * Observable raised after rendering a bounding box
  75228. */
  75229. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75230. /**
  75231. * @hidden
  75232. */
  75233. renderList: SmartArray<BoundingBox>;
  75234. private _colorShader;
  75235. private _vertexBuffers;
  75236. private _indexBuffer;
  75237. private _fillIndexBuffer;
  75238. private _fillIndexData;
  75239. /**
  75240. * Instantiates a new bounding box renderer in a scene.
  75241. * @param scene the scene the renderer renders in
  75242. */
  75243. constructor(scene: Scene);
  75244. /**
  75245. * Registers the component in a given scene
  75246. */
  75247. register(): void;
  75248. private _evaluateSubMesh;
  75249. private _activeMesh;
  75250. private _prepareRessources;
  75251. private _createIndexBuffer;
  75252. /**
  75253. * Rebuilds the elements related to this component in case of
  75254. * context lost for instance.
  75255. */
  75256. rebuild(): void;
  75257. /**
  75258. * @hidden
  75259. */
  75260. reset(): void;
  75261. /**
  75262. * Render the bounding boxes of a specific rendering group
  75263. * @param renderingGroupId defines the rendering group to render
  75264. */
  75265. render(renderingGroupId: number): void;
  75266. /**
  75267. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75268. * @param mesh Define the mesh to render the occlusion bounding box for
  75269. */
  75270. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75271. /**
  75272. * Dispose and release the resources attached to this renderer.
  75273. */
  75274. dispose(): void;
  75275. }
  75276. }
  75277. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75278. import { Nullable } from "babylonjs/types";
  75279. import { Scene } from "babylonjs/scene";
  75280. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75281. import { Camera } from "babylonjs/Cameras/camera";
  75282. import { ISceneComponent } from "babylonjs/sceneComponent";
  75283. module "babylonjs/scene" {
  75284. interface Scene {
  75285. /** @hidden (Backing field) */
  75286. _depthRenderer: {
  75287. [id: string]: DepthRenderer;
  75288. };
  75289. /**
  75290. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75291. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75292. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75293. * @returns the created depth renderer
  75294. */
  75295. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75296. /**
  75297. * Disables a depth renderer for a given camera
  75298. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75299. */
  75300. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75301. }
  75302. }
  75303. /**
  75304. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75305. * in several rendering techniques.
  75306. */
  75307. export class DepthRendererSceneComponent implements ISceneComponent {
  75308. /**
  75309. * The component name helpfull to identify the component in the list of scene components.
  75310. */
  75311. readonly name: string;
  75312. /**
  75313. * The scene the component belongs to.
  75314. */
  75315. scene: Scene;
  75316. /**
  75317. * Creates a new instance of the component for the given scene
  75318. * @param scene Defines the scene to register the component in
  75319. */
  75320. constructor(scene: Scene);
  75321. /**
  75322. * Registers the component in a given scene
  75323. */
  75324. register(): void;
  75325. /**
  75326. * Rebuilds the elements related to this component in case of
  75327. * context lost for instance.
  75328. */
  75329. rebuild(): void;
  75330. /**
  75331. * Disposes the component and the associated ressources
  75332. */
  75333. dispose(): void;
  75334. private _gatherRenderTargets;
  75335. private _gatherActiveCameraRenderTargets;
  75336. }
  75337. }
  75338. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75339. import { Nullable } from "babylonjs/types";
  75340. import { Scene } from "babylonjs/scene";
  75341. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75342. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75343. import { AbstractScene } from "babylonjs/abstractScene";
  75344. module "babylonjs/abstractScene" {
  75345. interface AbstractScene {
  75346. /** @hidden (Backing field) */
  75347. _prePassRenderer: Nullable<PrePassRenderer>;
  75348. /**
  75349. * Gets or Sets the current prepass renderer associated to the scene.
  75350. */
  75351. prePassRenderer: Nullable<PrePassRenderer>;
  75352. /**
  75353. * Enables the prepass and associates it with the scene
  75354. * @returns the PrePassRenderer
  75355. */
  75356. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75357. /**
  75358. * Disables the prepass associated with the scene
  75359. */
  75360. disablePrePassRenderer(): void;
  75361. }
  75362. }
  75363. /**
  75364. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75365. * in several rendering techniques.
  75366. */
  75367. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75368. /**
  75369. * The component name helpful to identify the component in the list of scene components.
  75370. */
  75371. readonly name: string;
  75372. /**
  75373. * The scene the component belongs to.
  75374. */
  75375. scene: Scene;
  75376. /**
  75377. * Creates a new instance of the component for the given scene
  75378. * @param scene Defines the scene to register the component in
  75379. */
  75380. constructor(scene: Scene);
  75381. /**
  75382. * Registers the component in a given scene
  75383. */
  75384. register(): void;
  75385. private _beforeCameraDraw;
  75386. private _afterCameraDraw;
  75387. private _beforeClearStage;
  75388. /**
  75389. * Serializes the component data to the specified json object
  75390. * @param serializationObject The object to serialize to
  75391. */
  75392. serialize(serializationObject: any): void;
  75393. /**
  75394. * Adds all the elements from the container to the scene
  75395. * @param container the container holding the elements
  75396. */
  75397. addFromContainer(container: AbstractScene): void;
  75398. /**
  75399. * Removes all the elements in the container from the scene
  75400. * @param container contains the elements to remove
  75401. * @param dispose if the removed element should be disposed (default: false)
  75402. */
  75403. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75404. /**
  75405. * Rebuilds the elements related to this component in case of
  75406. * context lost for instance.
  75407. */
  75408. rebuild(): void;
  75409. /**
  75410. * Disposes the component and the associated ressources
  75411. */
  75412. dispose(): void;
  75413. }
  75414. }
  75415. declare module "babylonjs/Shaders/outline.fragment" {
  75416. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75417. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75418. /** @hidden */
  75419. export var outlinePixelShader: {
  75420. name: string;
  75421. shader: string;
  75422. };
  75423. }
  75424. declare module "babylonjs/Shaders/outline.vertex" {
  75425. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75427. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75428. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75429. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75430. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75431. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75432. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75433. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75434. /** @hidden */
  75435. export var outlineVertexShader: {
  75436. name: string;
  75437. shader: string;
  75438. };
  75439. }
  75440. declare module "babylonjs/Rendering/outlineRenderer" {
  75441. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75442. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75443. import { Scene } from "babylonjs/scene";
  75444. import { ISceneComponent } from "babylonjs/sceneComponent";
  75445. import "babylonjs/Shaders/outline.fragment";
  75446. import "babylonjs/Shaders/outline.vertex";
  75447. module "babylonjs/scene" {
  75448. interface Scene {
  75449. /** @hidden */
  75450. _outlineRenderer: OutlineRenderer;
  75451. /**
  75452. * Gets the outline renderer associated with the scene
  75453. * @returns a OutlineRenderer
  75454. */
  75455. getOutlineRenderer(): OutlineRenderer;
  75456. }
  75457. }
  75458. module "babylonjs/Meshes/abstractMesh" {
  75459. interface AbstractMesh {
  75460. /** @hidden (Backing field) */
  75461. _renderOutline: boolean;
  75462. /**
  75463. * Gets or sets a boolean indicating if the outline must be rendered as well
  75464. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75465. */
  75466. renderOutline: boolean;
  75467. /** @hidden (Backing field) */
  75468. _renderOverlay: boolean;
  75469. /**
  75470. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75471. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75472. */
  75473. renderOverlay: boolean;
  75474. }
  75475. }
  75476. /**
  75477. * This class is responsible to draw bothe outline/overlay of meshes.
  75478. * It should not be used directly but through the available method on mesh.
  75479. */
  75480. export class OutlineRenderer implements ISceneComponent {
  75481. /**
  75482. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75483. */
  75484. private static _StencilReference;
  75485. /**
  75486. * The name of the component. Each component must have a unique name.
  75487. */
  75488. name: string;
  75489. /**
  75490. * The scene the component belongs to.
  75491. */
  75492. scene: Scene;
  75493. /**
  75494. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75495. */
  75496. zOffset: number;
  75497. private _engine;
  75498. private _effect;
  75499. private _cachedDefines;
  75500. private _savedDepthWrite;
  75501. /**
  75502. * Instantiates a new outline renderer. (There could be only one per scene).
  75503. * @param scene Defines the scene it belongs to
  75504. */
  75505. constructor(scene: Scene);
  75506. /**
  75507. * Register the component to one instance of a scene.
  75508. */
  75509. register(): void;
  75510. /**
  75511. * Rebuilds the elements related to this component in case of
  75512. * context lost for instance.
  75513. */
  75514. rebuild(): void;
  75515. /**
  75516. * Disposes the component and the associated ressources.
  75517. */
  75518. dispose(): void;
  75519. /**
  75520. * Renders the outline in the canvas.
  75521. * @param subMesh Defines the sumesh to render
  75522. * @param batch Defines the batch of meshes in case of instances
  75523. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75524. */
  75525. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75526. /**
  75527. * Returns whether or not the outline renderer is ready for a given submesh.
  75528. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75529. * @param subMesh Defines the submesh to check readyness for
  75530. * @param useInstances Defines wheter wee are trying to render instances or not
  75531. * @returns true if ready otherwise false
  75532. */
  75533. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75534. private _beforeRenderingMesh;
  75535. private _afterRenderingMesh;
  75536. }
  75537. }
  75538. declare module "babylonjs/Rendering/index" {
  75539. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75540. export * from "babylonjs/Rendering/depthRenderer";
  75541. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75542. export * from "babylonjs/Rendering/edgesRenderer";
  75543. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75544. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75545. export * from "babylonjs/Rendering/prePassRenderer";
  75546. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75547. export * from "babylonjs/Rendering/outlineRenderer";
  75548. export * from "babylonjs/Rendering/renderingGroup";
  75549. export * from "babylonjs/Rendering/renderingManager";
  75550. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75551. }
  75552. declare module "babylonjs/Sprites/ISprites" {
  75553. /**
  75554. * Defines the basic options interface of a Sprite Frame Source Size.
  75555. */
  75556. export interface ISpriteJSONSpriteSourceSize {
  75557. /**
  75558. * number of the original width of the Frame
  75559. */
  75560. w: number;
  75561. /**
  75562. * number of the original height of the Frame
  75563. */
  75564. h: number;
  75565. }
  75566. /**
  75567. * Defines the basic options interface of a Sprite Frame Data.
  75568. */
  75569. export interface ISpriteJSONSpriteFrameData {
  75570. /**
  75571. * number of the x offset of the Frame
  75572. */
  75573. x: number;
  75574. /**
  75575. * number of the y offset of the Frame
  75576. */
  75577. y: number;
  75578. /**
  75579. * number of the width of the Frame
  75580. */
  75581. w: number;
  75582. /**
  75583. * number of the height of the Frame
  75584. */
  75585. h: number;
  75586. }
  75587. /**
  75588. * Defines the basic options interface of a JSON Sprite.
  75589. */
  75590. export interface ISpriteJSONSprite {
  75591. /**
  75592. * string name of the Frame
  75593. */
  75594. filename: string;
  75595. /**
  75596. * ISpriteJSONSpriteFrame basic object of the frame data
  75597. */
  75598. frame: ISpriteJSONSpriteFrameData;
  75599. /**
  75600. * boolean to flag is the frame was rotated.
  75601. */
  75602. rotated: boolean;
  75603. /**
  75604. * boolean to flag is the frame was trimmed.
  75605. */
  75606. trimmed: boolean;
  75607. /**
  75608. * ISpriteJSONSpriteFrame basic object of the source data
  75609. */
  75610. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75611. /**
  75612. * ISpriteJSONSpriteFrame basic object of the source data
  75613. */
  75614. sourceSize: ISpriteJSONSpriteSourceSize;
  75615. }
  75616. /**
  75617. * Defines the basic options interface of a JSON atlas.
  75618. */
  75619. export interface ISpriteJSONAtlas {
  75620. /**
  75621. * Array of objects that contain the frame data.
  75622. */
  75623. frames: Array<ISpriteJSONSprite>;
  75624. /**
  75625. * object basic object containing the sprite meta data.
  75626. */
  75627. meta?: object;
  75628. }
  75629. }
  75630. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75631. /** @hidden */
  75632. export var spriteMapPixelShader: {
  75633. name: string;
  75634. shader: string;
  75635. };
  75636. }
  75637. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75638. /** @hidden */
  75639. export var spriteMapVertexShader: {
  75640. name: string;
  75641. shader: string;
  75642. };
  75643. }
  75644. declare module "babylonjs/Sprites/spriteMap" {
  75645. import { IDisposable, Scene } from "babylonjs/scene";
  75646. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75647. import { Texture } from "babylonjs/Materials/Textures/texture";
  75648. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75649. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75650. import "babylonjs/Meshes/Builders/planeBuilder";
  75651. import "babylonjs/Shaders/spriteMap.fragment";
  75652. import "babylonjs/Shaders/spriteMap.vertex";
  75653. /**
  75654. * Defines the basic options interface of a SpriteMap
  75655. */
  75656. export interface ISpriteMapOptions {
  75657. /**
  75658. * Vector2 of the number of cells in the grid.
  75659. */
  75660. stageSize?: Vector2;
  75661. /**
  75662. * Vector2 of the size of the output plane in World Units.
  75663. */
  75664. outputSize?: Vector2;
  75665. /**
  75666. * Vector3 of the position of the output plane in World Units.
  75667. */
  75668. outputPosition?: Vector3;
  75669. /**
  75670. * Vector3 of the rotation of the output plane.
  75671. */
  75672. outputRotation?: Vector3;
  75673. /**
  75674. * number of layers that the system will reserve in resources.
  75675. */
  75676. layerCount?: number;
  75677. /**
  75678. * number of max animation frames a single cell will reserve in resources.
  75679. */
  75680. maxAnimationFrames?: number;
  75681. /**
  75682. * number cell index of the base tile when the system compiles.
  75683. */
  75684. baseTile?: number;
  75685. /**
  75686. * boolean flip the sprite after its been repositioned by the framing data.
  75687. */
  75688. flipU?: boolean;
  75689. /**
  75690. * Vector3 scalar of the global RGB values of the SpriteMap.
  75691. */
  75692. colorMultiply?: Vector3;
  75693. }
  75694. /**
  75695. * Defines the IDisposable interface in order to be cleanable from resources.
  75696. */
  75697. export interface ISpriteMap extends IDisposable {
  75698. /**
  75699. * String name of the SpriteMap.
  75700. */
  75701. name: string;
  75702. /**
  75703. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75704. */
  75705. atlasJSON: ISpriteJSONAtlas;
  75706. /**
  75707. * Texture of the SpriteMap.
  75708. */
  75709. spriteSheet: Texture;
  75710. /**
  75711. * The parameters to initialize the SpriteMap with.
  75712. */
  75713. options: ISpriteMapOptions;
  75714. }
  75715. /**
  75716. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75717. */
  75718. export class SpriteMap implements ISpriteMap {
  75719. /** The Name of the spriteMap */
  75720. name: string;
  75721. /** The JSON file with the frame and meta data */
  75722. atlasJSON: ISpriteJSONAtlas;
  75723. /** The systems Sprite Sheet Texture */
  75724. spriteSheet: Texture;
  75725. /** Arguments passed with the Constructor */
  75726. options: ISpriteMapOptions;
  75727. /** Public Sprite Storage array, parsed from atlasJSON */
  75728. sprites: Array<ISpriteJSONSprite>;
  75729. /** Returns the Number of Sprites in the System */
  75730. get spriteCount(): number;
  75731. /** Returns the Position of Output Plane*/
  75732. get position(): Vector3;
  75733. /** Returns the Position of Output Plane*/
  75734. set position(v: Vector3);
  75735. /** Returns the Rotation of Output Plane*/
  75736. get rotation(): Vector3;
  75737. /** Returns the Rotation of Output Plane*/
  75738. set rotation(v: Vector3);
  75739. /** Sets the AnimationMap*/
  75740. get animationMap(): RawTexture;
  75741. /** Sets the AnimationMap*/
  75742. set animationMap(v: RawTexture);
  75743. /** Scene that the SpriteMap was created in */
  75744. private _scene;
  75745. /** Texture Buffer of Float32 that holds tile frame data*/
  75746. private _frameMap;
  75747. /** Texture Buffers of Float32 that holds tileMap data*/
  75748. private _tileMaps;
  75749. /** Texture Buffer of Float32 that holds Animation Data*/
  75750. private _animationMap;
  75751. /** Custom ShaderMaterial Central to the System*/
  75752. private _material;
  75753. /** Custom ShaderMaterial Central to the System*/
  75754. private _output;
  75755. /** Systems Time Ticker*/
  75756. private _time;
  75757. /**
  75758. * Creates a new SpriteMap
  75759. * @param name defines the SpriteMaps Name
  75760. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75761. * @param spriteSheet is the Texture that the Sprites are on.
  75762. * @param options a basic deployment configuration
  75763. * @param scene The Scene that the map is deployed on
  75764. */
  75765. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75766. /**
  75767. * Returns tileID location
  75768. * @returns Vector2 the cell position ID
  75769. */
  75770. getTileID(): Vector2;
  75771. /**
  75772. * Gets the UV location of the mouse over the SpriteMap.
  75773. * @returns Vector2 the UV position of the mouse interaction
  75774. */
  75775. getMousePosition(): Vector2;
  75776. /**
  75777. * Creates the "frame" texture Buffer
  75778. * -------------------------------------
  75779. * Structure of frames
  75780. * "filename": "Falling-Water-2.png",
  75781. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75782. * "rotated": true,
  75783. * "trimmed": true,
  75784. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75785. * "sourceSize": {"w":32,"h":32}
  75786. * @returns RawTexture of the frameMap
  75787. */
  75788. private _createFrameBuffer;
  75789. /**
  75790. * Creates the tileMap texture Buffer
  75791. * @param buffer normally and array of numbers, or a false to generate from scratch
  75792. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75793. * @returns RawTexture of the tileMap
  75794. */
  75795. private _createTileBuffer;
  75796. /**
  75797. * Modifies the data of the tileMaps
  75798. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75799. * @param pos is the iVector2 Coordinates of the Tile
  75800. * @param tile The SpriteIndex of the new Tile
  75801. */
  75802. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75803. /**
  75804. * Creates the animationMap texture Buffer
  75805. * @param buffer normally and array of numbers, or a false to generate from scratch
  75806. * @returns RawTexture of the animationMap
  75807. */
  75808. private _createTileAnimationBuffer;
  75809. /**
  75810. * Modifies the data of the animationMap
  75811. * @param cellID is the Index of the Sprite
  75812. * @param _frame is the target Animation frame
  75813. * @param toCell is the Target Index of the next frame of the animation
  75814. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75815. * @param speed is a global scalar of the time variable on the map.
  75816. */
  75817. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75818. /**
  75819. * Exports the .tilemaps file
  75820. */
  75821. saveTileMaps(): void;
  75822. /**
  75823. * Imports the .tilemaps file
  75824. * @param url of the .tilemaps file
  75825. */
  75826. loadTileMaps(url: string): void;
  75827. /**
  75828. * Release associated resources
  75829. */
  75830. dispose(): void;
  75831. }
  75832. }
  75833. declare module "babylonjs/Sprites/spritePackedManager" {
  75834. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75835. import { Scene } from "babylonjs/scene";
  75836. /**
  75837. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75838. * @see https://doc.babylonjs.com/babylon101/sprites
  75839. */
  75840. export class SpritePackedManager extends SpriteManager {
  75841. /** defines the packed manager's name */
  75842. name: string;
  75843. /**
  75844. * Creates a new sprite manager from a packed sprite sheet
  75845. * @param name defines the manager's name
  75846. * @param imgUrl defines the sprite sheet url
  75847. * @param capacity defines the maximum allowed number of sprites
  75848. * @param scene defines the hosting scene
  75849. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75850. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75851. * @param samplingMode defines the smapling mode to use with spritesheet
  75852. * @param fromPacked set to true; do not alter
  75853. */
  75854. constructor(
  75855. /** defines the packed manager's name */
  75856. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75857. }
  75858. }
  75859. declare module "babylonjs/Sprites/index" {
  75860. export * from "babylonjs/Sprites/sprite";
  75861. export * from "babylonjs/Sprites/ISprites";
  75862. export * from "babylonjs/Sprites/spriteManager";
  75863. export * from "babylonjs/Sprites/spriteMap";
  75864. export * from "babylonjs/Sprites/spritePackedManager";
  75865. export * from "babylonjs/Sprites/spriteSceneComponent";
  75866. }
  75867. declare module "babylonjs/States/index" {
  75868. export * from "babylonjs/States/alphaCullingState";
  75869. export * from "babylonjs/States/depthCullingState";
  75870. export * from "babylonjs/States/stencilState";
  75871. }
  75872. declare module "babylonjs/Misc/assetsManager" {
  75873. import { Scene } from "babylonjs/scene";
  75874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75875. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75876. import { Skeleton } from "babylonjs/Bones/skeleton";
  75877. import { Observable } from "babylonjs/Misc/observable";
  75878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75879. import { Texture } from "babylonjs/Materials/Textures/texture";
  75880. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75881. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75882. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75883. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75884. import { AssetContainer } from "babylonjs/assetContainer";
  75885. /**
  75886. * Defines the list of states available for a task inside a AssetsManager
  75887. */
  75888. export enum AssetTaskState {
  75889. /**
  75890. * Initialization
  75891. */
  75892. INIT = 0,
  75893. /**
  75894. * Running
  75895. */
  75896. RUNNING = 1,
  75897. /**
  75898. * Done
  75899. */
  75900. DONE = 2,
  75901. /**
  75902. * Error
  75903. */
  75904. ERROR = 3
  75905. }
  75906. /**
  75907. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75908. */
  75909. export abstract class AbstractAssetTask {
  75910. /**
  75911. * Task name
  75912. */ name: string;
  75913. /**
  75914. * Callback called when the task is successful
  75915. */
  75916. onSuccess: (task: any) => void;
  75917. /**
  75918. * Callback called when the task is not successful
  75919. */
  75920. onError: (task: any, message?: string, exception?: any) => void;
  75921. /**
  75922. * Creates a new AssetsManager
  75923. * @param name defines the name of the task
  75924. */
  75925. constructor(
  75926. /**
  75927. * Task name
  75928. */ name: string);
  75929. private _isCompleted;
  75930. private _taskState;
  75931. private _errorObject;
  75932. /**
  75933. * Get if the task is completed
  75934. */
  75935. get isCompleted(): boolean;
  75936. /**
  75937. * Gets the current state of the task
  75938. */
  75939. get taskState(): AssetTaskState;
  75940. /**
  75941. * Gets the current error object (if task is in error)
  75942. */
  75943. get errorObject(): {
  75944. message?: string;
  75945. exception?: any;
  75946. };
  75947. /**
  75948. * Internal only
  75949. * @hidden
  75950. */
  75951. _setErrorObject(message?: string, exception?: any): void;
  75952. /**
  75953. * Execute the current task
  75954. * @param scene defines the scene where you want your assets to be loaded
  75955. * @param onSuccess is a callback called when the task is successfully executed
  75956. * @param onError is a callback called if an error occurs
  75957. */
  75958. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75959. /**
  75960. * Execute the current task
  75961. * @param scene defines the scene where you want your assets to be loaded
  75962. * @param onSuccess is a callback called when the task is successfully executed
  75963. * @param onError is a callback called if an error occurs
  75964. */
  75965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75966. /**
  75967. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75968. * This can be used with failed tasks that have the reason for failure fixed.
  75969. */
  75970. reset(): void;
  75971. private onErrorCallback;
  75972. private onDoneCallback;
  75973. }
  75974. /**
  75975. * Define the interface used by progress events raised during assets loading
  75976. */
  75977. export interface IAssetsProgressEvent {
  75978. /**
  75979. * Defines the number of remaining tasks to process
  75980. */
  75981. remainingCount: number;
  75982. /**
  75983. * Defines the total number of tasks
  75984. */
  75985. totalCount: number;
  75986. /**
  75987. * Defines the task that was just processed
  75988. */
  75989. task: AbstractAssetTask;
  75990. }
  75991. /**
  75992. * Class used to share progress information about assets loading
  75993. */
  75994. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75995. /**
  75996. * Defines the number of remaining tasks to process
  75997. */
  75998. remainingCount: number;
  75999. /**
  76000. * Defines the total number of tasks
  76001. */
  76002. totalCount: number;
  76003. /**
  76004. * Defines the task that was just processed
  76005. */
  76006. task: AbstractAssetTask;
  76007. /**
  76008. * Creates a AssetsProgressEvent
  76009. * @param remainingCount defines the number of remaining tasks to process
  76010. * @param totalCount defines the total number of tasks
  76011. * @param task defines the task that was just processed
  76012. */
  76013. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76014. }
  76015. /**
  76016. * Define a task used by AssetsManager to load assets into a container
  76017. */
  76018. export class ContainerAssetTask extends AbstractAssetTask {
  76019. /**
  76020. * Defines the name of the task
  76021. */
  76022. name: string;
  76023. /**
  76024. * Defines the list of mesh's names you want to load
  76025. */
  76026. meshesNames: any;
  76027. /**
  76028. * Defines the root url to use as a base to load your meshes and associated resources
  76029. */
  76030. rootUrl: string;
  76031. /**
  76032. * Defines the filename or File of the scene to load from
  76033. */
  76034. sceneFilename: string | File;
  76035. /**
  76036. * Get the loaded asset container
  76037. */
  76038. loadedContainer: AssetContainer;
  76039. /**
  76040. * Gets the list of loaded meshes
  76041. */
  76042. loadedMeshes: Array<AbstractMesh>;
  76043. /**
  76044. * Gets the list of loaded particle systems
  76045. */
  76046. loadedParticleSystems: Array<IParticleSystem>;
  76047. /**
  76048. * Gets the list of loaded skeletons
  76049. */
  76050. loadedSkeletons: Array<Skeleton>;
  76051. /**
  76052. * Gets the list of loaded animation groups
  76053. */
  76054. loadedAnimationGroups: Array<AnimationGroup>;
  76055. /**
  76056. * Callback called when the task is successful
  76057. */
  76058. onSuccess: (task: ContainerAssetTask) => void;
  76059. /**
  76060. * Callback called when the task is successful
  76061. */
  76062. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76063. /**
  76064. * Creates a new ContainerAssetTask
  76065. * @param name defines the name of the task
  76066. * @param meshesNames defines the list of mesh's names you want to load
  76067. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76068. * @param sceneFilename defines the filename or File of the scene to load from
  76069. */
  76070. constructor(
  76071. /**
  76072. * Defines the name of the task
  76073. */
  76074. name: string,
  76075. /**
  76076. * Defines the list of mesh's names you want to load
  76077. */
  76078. meshesNames: any,
  76079. /**
  76080. * Defines the root url to use as a base to load your meshes and associated resources
  76081. */
  76082. rootUrl: string,
  76083. /**
  76084. * Defines the filename or File of the scene to load from
  76085. */
  76086. sceneFilename: string | File);
  76087. /**
  76088. * Execute the current task
  76089. * @param scene defines the scene where you want your assets to be loaded
  76090. * @param onSuccess is a callback called when the task is successfully executed
  76091. * @param onError is a callback called if an error occurs
  76092. */
  76093. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76094. }
  76095. /**
  76096. * Define a task used by AssetsManager to load meshes
  76097. */
  76098. export class MeshAssetTask extends AbstractAssetTask {
  76099. /**
  76100. * Defines the name of the task
  76101. */
  76102. name: string;
  76103. /**
  76104. * Defines the list of mesh's names you want to load
  76105. */
  76106. meshesNames: any;
  76107. /**
  76108. * Defines the root url to use as a base to load your meshes and associated resources
  76109. */
  76110. rootUrl: string;
  76111. /**
  76112. * Defines the filename or File of the scene to load from
  76113. */
  76114. sceneFilename: string | File;
  76115. /**
  76116. * Gets the list of loaded meshes
  76117. */
  76118. loadedMeshes: Array<AbstractMesh>;
  76119. /**
  76120. * Gets the list of loaded particle systems
  76121. */
  76122. loadedParticleSystems: Array<IParticleSystem>;
  76123. /**
  76124. * Gets the list of loaded skeletons
  76125. */
  76126. loadedSkeletons: Array<Skeleton>;
  76127. /**
  76128. * Gets the list of loaded animation groups
  76129. */
  76130. loadedAnimationGroups: Array<AnimationGroup>;
  76131. /**
  76132. * Callback called when the task is successful
  76133. */
  76134. onSuccess: (task: MeshAssetTask) => void;
  76135. /**
  76136. * Callback called when the task is successful
  76137. */
  76138. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76139. /**
  76140. * Creates a new MeshAssetTask
  76141. * @param name defines the name of the task
  76142. * @param meshesNames defines the list of mesh's names you want to load
  76143. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76144. * @param sceneFilename defines the filename or File of the scene to load from
  76145. */
  76146. constructor(
  76147. /**
  76148. * Defines the name of the task
  76149. */
  76150. name: string,
  76151. /**
  76152. * Defines the list of mesh's names you want to load
  76153. */
  76154. meshesNames: any,
  76155. /**
  76156. * Defines the root url to use as a base to load your meshes and associated resources
  76157. */
  76158. rootUrl: string,
  76159. /**
  76160. * Defines the filename or File of the scene to load from
  76161. */
  76162. sceneFilename: string | File);
  76163. /**
  76164. * Execute the current task
  76165. * @param scene defines the scene where you want your assets to be loaded
  76166. * @param onSuccess is a callback called when the task is successfully executed
  76167. * @param onError is a callback called if an error occurs
  76168. */
  76169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76170. }
  76171. /**
  76172. * Define a task used by AssetsManager to load text content
  76173. */
  76174. export class TextFileAssetTask extends AbstractAssetTask {
  76175. /**
  76176. * Defines the name of the task
  76177. */
  76178. name: string;
  76179. /**
  76180. * Defines the location of the file to load
  76181. */
  76182. url: string;
  76183. /**
  76184. * Gets the loaded text string
  76185. */
  76186. text: string;
  76187. /**
  76188. * Callback called when the task is successful
  76189. */
  76190. onSuccess: (task: TextFileAssetTask) => void;
  76191. /**
  76192. * Callback called when the task is successful
  76193. */
  76194. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76195. /**
  76196. * Creates a new TextFileAssetTask object
  76197. * @param name defines the name of the task
  76198. * @param url defines the location of the file to load
  76199. */
  76200. constructor(
  76201. /**
  76202. * Defines the name of the task
  76203. */
  76204. name: string,
  76205. /**
  76206. * Defines the location of the file to load
  76207. */
  76208. url: string);
  76209. /**
  76210. * Execute the current task
  76211. * @param scene defines the scene where you want your assets to be loaded
  76212. * @param onSuccess is a callback called when the task is successfully executed
  76213. * @param onError is a callback called if an error occurs
  76214. */
  76215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76216. }
  76217. /**
  76218. * Define a task used by AssetsManager to load binary data
  76219. */
  76220. export class BinaryFileAssetTask extends AbstractAssetTask {
  76221. /**
  76222. * Defines the name of the task
  76223. */
  76224. name: string;
  76225. /**
  76226. * Defines the location of the file to load
  76227. */
  76228. url: string;
  76229. /**
  76230. * Gets the lodaded data (as an array buffer)
  76231. */
  76232. data: ArrayBuffer;
  76233. /**
  76234. * Callback called when the task is successful
  76235. */
  76236. onSuccess: (task: BinaryFileAssetTask) => void;
  76237. /**
  76238. * Callback called when the task is successful
  76239. */
  76240. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76241. /**
  76242. * Creates a new BinaryFileAssetTask object
  76243. * @param name defines the name of the new task
  76244. * @param url defines the location of the file to load
  76245. */
  76246. constructor(
  76247. /**
  76248. * Defines the name of the task
  76249. */
  76250. name: string,
  76251. /**
  76252. * Defines the location of the file to load
  76253. */
  76254. url: string);
  76255. /**
  76256. * Execute the current task
  76257. * @param scene defines the scene where you want your assets to be loaded
  76258. * @param onSuccess is a callback called when the task is successfully executed
  76259. * @param onError is a callback called if an error occurs
  76260. */
  76261. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76262. }
  76263. /**
  76264. * Define a task used by AssetsManager to load images
  76265. */
  76266. export class ImageAssetTask extends AbstractAssetTask {
  76267. /**
  76268. * Defines the name of the task
  76269. */
  76270. name: string;
  76271. /**
  76272. * Defines the location of the image to load
  76273. */
  76274. url: string;
  76275. /**
  76276. * Gets the loaded images
  76277. */
  76278. image: HTMLImageElement;
  76279. /**
  76280. * Callback called when the task is successful
  76281. */
  76282. onSuccess: (task: ImageAssetTask) => void;
  76283. /**
  76284. * Callback called when the task is successful
  76285. */
  76286. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76287. /**
  76288. * Creates a new ImageAssetTask
  76289. * @param name defines the name of the task
  76290. * @param url defines the location of the image to load
  76291. */
  76292. constructor(
  76293. /**
  76294. * Defines the name of the task
  76295. */
  76296. name: string,
  76297. /**
  76298. * Defines the location of the image to load
  76299. */
  76300. url: string);
  76301. /**
  76302. * Execute the current task
  76303. * @param scene defines the scene where you want your assets to be loaded
  76304. * @param onSuccess is a callback called when the task is successfully executed
  76305. * @param onError is a callback called if an error occurs
  76306. */
  76307. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76308. }
  76309. /**
  76310. * Defines the interface used by texture loading tasks
  76311. */
  76312. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76313. /**
  76314. * Gets the loaded texture
  76315. */
  76316. texture: TEX;
  76317. }
  76318. /**
  76319. * Define a task used by AssetsManager to load 2D textures
  76320. */
  76321. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76322. /**
  76323. * Defines the name of the task
  76324. */
  76325. name: string;
  76326. /**
  76327. * Defines the location of the file to load
  76328. */
  76329. url: string;
  76330. /**
  76331. * Defines if mipmap should not be generated (default is false)
  76332. */
  76333. noMipmap?: boolean | undefined;
  76334. /**
  76335. * Defines if texture must be inverted on Y axis (default is true)
  76336. */
  76337. invertY: boolean;
  76338. /**
  76339. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76340. */
  76341. samplingMode: number;
  76342. /**
  76343. * Gets the loaded texture
  76344. */
  76345. texture: Texture;
  76346. /**
  76347. * Callback called when the task is successful
  76348. */
  76349. onSuccess: (task: TextureAssetTask) => void;
  76350. /**
  76351. * Callback called when the task is successful
  76352. */
  76353. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76354. /**
  76355. * Creates a new TextureAssetTask object
  76356. * @param name defines the name of the task
  76357. * @param url defines the location of the file to load
  76358. * @param noMipmap defines if mipmap should not be generated (default is false)
  76359. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76360. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76361. */
  76362. constructor(
  76363. /**
  76364. * Defines the name of the task
  76365. */
  76366. name: string,
  76367. /**
  76368. * Defines the location of the file to load
  76369. */
  76370. url: string,
  76371. /**
  76372. * Defines if mipmap should not be generated (default is false)
  76373. */
  76374. noMipmap?: boolean | undefined,
  76375. /**
  76376. * Defines if texture must be inverted on Y axis (default is true)
  76377. */
  76378. invertY?: boolean,
  76379. /**
  76380. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76381. */
  76382. samplingMode?: number);
  76383. /**
  76384. * Execute the current task
  76385. * @param scene defines the scene where you want your assets to be loaded
  76386. * @param onSuccess is a callback called when the task is successfully executed
  76387. * @param onError is a callback called if an error occurs
  76388. */
  76389. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76390. }
  76391. /**
  76392. * Define a task used by AssetsManager to load cube textures
  76393. */
  76394. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76395. /**
  76396. * Defines the name of the task
  76397. */
  76398. name: string;
  76399. /**
  76400. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76401. */
  76402. url: string;
  76403. /**
  76404. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76405. */
  76406. extensions?: string[] | undefined;
  76407. /**
  76408. * Defines if mipmaps should not be generated (default is false)
  76409. */
  76410. noMipmap?: boolean | undefined;
  76411. /**
  76412. * Defines the explicit list of files (undefined by default)
  76413. */
  76414. files?: string[] | undefined;
  76415. /**
  76416. * Gets the loaded texture
  76417. */
  76418. texture: CubeTexture;
  76419. /**
  76420. * Callback called when the task is successful
  76421. */
  76422. onSuccess: (task: CubeTextureAssetTask) => void;
  76423. /**
  76424. * Callback called when the task is successful
  76425. */
  76426. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76427. /**
  76428. * Creates a new CubeTextureAssetTask
  76429. * @param name defines the name of the task
  76430. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76431. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76432. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76433. * @param files defines the explicit list of files (undefined by default)
  76434. */
  76435. constructor(
  76436. /**
  76437. * Defines the name of the task
  76438. */
  76439. name: string,
  76440. /**
  76441. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76442. */
  76443. url: string,
  76444. /**
  76445. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76446. */
  76447. extensions?: string[] | undefined,
  76448. /**
  76449. * Defines if mipmaps should not be generated (default is false)
  76450. */
  76451. noMipmap?: boolean | undefined,
  76452. /**
  76453. * Defines the explicit list of files (undefined by default)
  76454. */
  76455. files?: string[] | undefined);
  76456. /**
  76457. * Execute the current task
  76458. * @param scene defines the scene where you want your assets to be loaded
  76459. * @param onSuccess is a callback called when the task is successfully executed
  76460. * @param onError is a callback called if an error occurs
  76461. */
  76462. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76463. }
  76464. /**
  76465. * Define a task used by AssetsManager to load HDR cube textures
  76466. */
  76467. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76468. /**
  76469. * Defines the name of the task
  76470. */
  76471. name: string;
  76472. /**
  76473. * Defines the location of the file to load
  76474. */
  76475. url: string;
  76476. /**
  76477. * Defines the desired size (the more it increases the longer the generation will be)
  76478. */
  76479. size: number;
  76480. /**
  76481. * Defines if mipmaps should not be generated (default is false)
  76482. */
  76483. noMipmap: boolean;
  76484. /**
  76485. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76486. */
  76487. generateHarmonics: boolean;
  76488. /**
  76489. * 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)
  76490. */
  76491. gammaSpace: boolean;
  76492. /**
  76493. * Internal Use Only
  76494. */
  76495. reserved: boolean;
  76496. /**
  76497. * Gets the loaded texture
  76498. */
  76499. texture: HDRCubeTexture;
  76500. /**
  76501. * Callback called when the task is successful
  76502. */
  76503. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76504. /**
  76505. * Callback called when the task is successful
  76506. */
  76507. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76508. /**
  76509. * Creates a new HDRCubeTextureAssetTask object
  76510. * @param name defines the name of the task
  76511. * @param url defines the location of the file to load
  76512. * @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.
  76513. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76514. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76515. * @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)
  76516. * @param reserved Internal use only
  76517. */
  76518. constructor(
  76519. /**
  76520. * Defines the name of the task
  76521. */
  76522. name: string,
  76523. /**
  76524. * Defines the location of the file to load
  76525. */
  76526. url: string,
  76527. /**
  76528. * Defines the desired size (the more it increases the longer the generation will be)
  76529. */
  76530. size: number,
  76531. /**
  76532. * Defines if mipmaps should not be generated (default is false)
  76533. */
  76534. noMipmap?: boolean,
  76535. /**
  76536. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76537. */
  76538. generateHarmonics?: boolean,
  76539. /**
  76540. * 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)
  76541. */
  76542. gammaSpace?: boolean,
  76543. /**
  76544. * Internal Use Only
  76545. */
  76546. reserved?: boolean);
  76547. /**
  76548. * Execute the current task
  76549. * @param scene defines the scene where you want your assets to be loaded
  76550. * @param onSuccess is a callback called when the task is successfully executed
  76551. * @param onError is a callback called if an error occurs
  76552. */
  76553. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76554. }
  76555. /**
  76556. * Define a task used by AssetsManager to load Equirectangular cube textures
  76557. */
  76558. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76559. /**
  76560. * Defines the name of the task
  76561. */
  76562. name: string;
  76563. /**
  76564. * Defines the location of the file to load
  76565. */
  76566. url: string;
  76567. /**
  76568. * Defines the desired size (the more it increases the longer the generation will be)
  76569. */
  76570. size: number;
  76571. /**
  76572. * Defines if mipmaps should not be generated (default is false)
  76573. */
  76574. noMipmap: boolean;
  76575. /**
  76576. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76577. * but the standard material would require them in Gamma space) (default is true)
  76578. */
  76579. gammaSpace: boolean;
  76580. /**
  76581. * Gets the loaded texture
  76582. */
  76583. texture: EquiRectangularCubeTexture;
  76584. /**
  76585. * Callback called when the task is successful
  76586. */
  76587. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76588. /**
  76589. * Callback called when the task is successful
  76590. */
  76591. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76592. /**
  76593. * Creates a new EquiRectangularCubeTextureAssetTask object
  76594. * @param name defines the name of the task
  76595. * @param url defines the location of the file to load
  76596. * @param size defines the desired size (the more it increases the longer the generation will be)
  76597. * If the size is omitted this implies you are using a preprocessed cubemap.
  76598. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76599. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76600. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76601. * (default is true)
  76602. */
  76603. constructor(
  76604. /**
  76605. * Defines the name of the task
  76606. */
  76607. name: string,
  76608. /**
  76609. * Defines the location of the file to load
  76610. */
  76611. url: string,
  76612. /**
  76613. * Defines the desired size (the more it increases the longer the generation will be)
  76614. */
  76615. size: number,
  76616. /**
  76617. * Defines if mipmaps should not be generated (default is false)
  76618. */
  76619. noMipmap?: boolean,
  76620. /**
  76621. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76622. * but the standard material would require them in Gamma space) (default is true)
  76623. */
  76624. gammaSpace?: boolean);
  76625. /**
  76626. * Execute the current task
  76627. * @param scene defines the scene where you want your assets to be loaded
  76628. * @param onSuccess is a callback called when the task is successfully executed
  76629. * @param onError is a callback called if an error occurs
  76630. */
  76631. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76632. }
  76633. /**
  76634. * This class can be used to easily import assets into a scene
  76635. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76636. */
  76637. export class AssetsManager {
  76638. private _scene;
  76639. private _isLoading;
  76640. protected _tasks: AbstractAssetTask[];
  76641. protected _waitingTasksCount: number;
  76642. protected _totalTasksCount: number;
  76643. /**
  76644. * Callback called when all tasks are processed
  76645. */
  76646. onFinish: (tasks: AbstractAssetTask[]) => void;
  76647. /**
  76648. * Callback called when a task is successful
  76649. */
  76650. onTaskSuccess: (task: AbstractAssetTask) => void;
  76651. /**
  76652. * Callback called when a task had an error
  76653. */
  76654. onTaskError: (task: AbstractAssetTask) => void;
  76655. /**
  76656. * Callback called when a task is done (whatever the result is)
  76657. */
  76658. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76659. /**
  76660. * Observable called when all tasks are processed
  76661. */
  76662. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76663. /**
  76664. * Observable called when a task had an error
  76665. */
  76666. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76667. /**
  76668. * Observable called when all tasks were executed
  76669. */
  76670. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76671. /**
  76672. * Observable called when a task is done (whatever the result is)
  76673. */
  76674. onProgressObservable: Observable<IAssetsProgressEvent>;
  76675. /**
  76676. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76677. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76678. */
  76679. useDefaultLoadingScreen: boolean;
  76680. /**
  76681. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76682. * when all assets have been downloaded.
  76683. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76684. */
  76685. autoHideLoadingUI: boolean;
  76686. /**
  76687. * Creates a new AssetsManager
  76688. * @param scene defines the scene to work on
  76689. */
  76690. constructor(scene: Scene);
  76691. /**
  76692. * Add a ContainerAssetTask to the list of active tasks
  76693. * @param taskName defines the name of the new task
  76694. * @param meshesNames defines the name of meshes to load
  76695. * @param rootUrl defines the root url to use to locate files
  76696. * @param sceneFilename defines the filename of the scene file
  76697. * @returns a new ContainerAssetTask object
  76698. */
  76699. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  76700. /**
  76701. * Add a MeshAssetTask to the list of active tasks
  76702. * @param taskName defines the name of the new task
  76703. * @param meshesNames defines the name of meshes to load
  76704. * @param rootUrl defines the root url to use to locate files
  76705. * @param sceneFilename defines the filename of the scene file
  76706. * @returns a new MeshAssetTask object
  76707. */
  76708. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76709. /**
  76710. * Add a TextFileAssetTask to the list of active tasks
  76711. * @param taskName defines the name of the new task
  76712. * @param url defines the url of the file to load
  76713. * @returns a new TextFileAssetTask object
  76714. */
  76715. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76716. /**
  76717. * Add a BinaryFileAssetTask to the list of active tasks
  76718. * @param taskName defines the name of the new task
  76719. * @param url defines the url of the file to load
  76720. * @returns a new BinaryFileAssetTask object
  76721. */
  76722. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76723. /**
  76724. * Add a ImageAssetTask to the list of active tasks
  76725. * @param taskName defines the name of the new task
  76726. * @param url defines the url of the file to load
  76727. * @returns a new ImageAssetTask object
  76728. */
  76729. addImageTask(taskName: string, url: string): ImageAssetTask;
  76730. /**
  76731. * Add a TextureAssetTask to the list of active tasks
  76732. * @param taskName defines the name of the new task
  76733. * @param url defines the url of the file to load
  76734. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76735. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76736. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76737. * @returns a new TextureAssetTask object
  76738. */
  76739. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76740. /**
  76741. * Add a CubeTextureAssetTask to the list of active tasks
  76742. * @param taskName defines the name of the new task
  76743. * @param url defines the url of the file to load
  76744. * @param extensions defines the extension to use to load the cube map (can be null)
  76745. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76746. * @param files defines the list of files to load (can be null)
  76747. * @returns a new CubeTextureAssetTask object
  76748. */
  76749. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76750. /**
  76751. *
  76752. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76753. * @param taskName defines the name of the new task
  76754. * @param url defines the url of the file to load
  76755. * @param size defines the size you want for the cubemap (can be null)
  76756. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76757. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76758. * @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)
  76759. * @param reserved Internal use only
  76760. * @returns a new HDRCubeTextureAssetTask object
  76761. */
  76762. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76763. /**
  76764. *
  76765. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76766. * @param taskName defines the name of the new task
  76767. * @param url defines the url of the file to load
  76768. * @param size defines the size you want for the cubemap (can be null)
  76769. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76770. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76771. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76772. * @returns a new EquiRectangularCubeTextureAssetTask object
  76773. */
  76774. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76775. /**
  76776. * Remove a task from the assets manager.
  76777. * @param task the task to remove
  76778. */
  76779. removeTask(task: AbstractAssetTask): void;
  76780. private _decreaseWaitingTasksCount;
  76781. private _runTask;
  76782. /**
  76783. * Reset the AssetsManager and remove all tasks
  76784. * @return the current instance of the AssetsManager
  76785. */
  76786. reset(): AssetsManager;
  76787. /**
  76788. * Start the loading process
  76789. * @return the current instance of the AssetsManager
  76790. */
  76791. load(): AssetsManager;
  76792. /**
  76793. * Start the loading process as an async operation
  76794. * @return a promise returning the list of failed tasks
  76795. */
  76796. loadAsync(): Promise<void>;
  76797. }
  76798. }
  76799. declare module "babylonjs/Misc/deferred" {
  76800. /**
  76801. * Wrapper class for promise with external resolve and reject.
  76802. */
  76803. export class Deferred<T> {
  76804. /**
  76805. * The promise associated with this deferred object.
  76806. */
  76807. readonly promise: Promise<T>;
  76808. private _resolve;
  76809. private _reject;
  76810. /**
  76811. * The resolve method of the promise associated with this deferred object.
  76812. */
  76813. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76814. /**
  76815. * The reject method of the promise associated with this deferred object.
  76816. */
  76817. get reject(): (reason?: any) => void;
  76818. /**
  76819. * Constructor for this deferred object.
  76820. */
  76821. constructor();
  76822. }
  76823. }
  76824. declare module "babylonjs/Misc/meshExploder" {
  76825. import { Mesh } from "babylonjs/Meshes/mesh";
  76826. /**
  76827. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76828. */
  76829. export class MeshExploder {
  76830. private _centerMesh;
  76831. private _meshes;
  76832. private _meshesOrigins;
  76833. private _toCenterVectors;
  76834. private _scaledDirection;
  76835. private _newPosition;
  76836. private _centerPosition;
  76837. /**
  76838. * Explodes meshes from a center mesh.
  76839. * @param meshes The meshes to explode.
  76840. * @param centerMesh The mesh to be center of explosion.
  76841. */
  76842. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76843. private _setCenterMesh;
  76844. /**
  76845. * Get class name
  76846. * @returns "MeshExploder"
  76847. */
  76848. getClassName(): string;
  76849. /**
  76850. * "Exploded meshes"
  76851. * @returns Array of meshes with the centerMesh at index 0.
  76852. */
  76853. getMeshes(): Array<Mesh>;
  76854. /**
  76855. * Explodes meshes giving a specific direction
  76856. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76857. */
  76858. explode(direction?: number): void;
  76859. }
  76860. }
  76861. declare module "babylonjs/Misc/filesInput" {
  76862. import { Engine } from "babylonjs/Engines/engine";
  76863. import { Scene } from "babylonjs/scene";
  76864. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76865. import { Nullable } from "babylonjs/types";
  76866. /**
  76867. * Class used to help managing file picking and drag'n'drop
  76868. */
  76869. export class FilesInput {
  76870. /**
  76871. * List of files ready to be loaded
  76872. */
  76873. static get FilesToLoad(): {
  76874. [key: string]: File;
  76875. };
  76876. /**
  76877. * Callback called when a file is processed
  76878. */
  76879. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76880. private _engine;
  76881. private _currentScene;
  76882. private _sceneLoadedCallback;
  76883. private _progressCallback;
  76884. private _additionalRenderLoopLogicCallback;
  76885. private _textureLoadingCallback;
  76886. private _startingProcessingFilesCallback;
  76887. private _onReloadCallback;
  76888. private _errorCallback;
  76889. private _elementToMonitor;
  76890. private _sceneFileToLoad;
  76891. private _filesToLoad;
  76892. /**
  76893. * Creates a new FilesInput
  76894. * @param engine defines the rendering engine
  76895. * @param scene defines the hosting scene
  76896. * @param sceneLoadedCallback callback called when scene is loaded
  76897. * @param progressCallback callback called to track progress
  76898. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76899. * @param textureLoadingCallback callback called when a texture is loading
  76900. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76901. * @param onReloadCallback callback called when a reload is requested
  76902. * @param errorCallback callback call if an error occurs
  76903. */
  76904. 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>);
  76905. private _dragEnterHandler;
  76906. private _dragOverHandler;
  76907. private _dropHandler;
  76908. /**
  76909. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76910. * @param elementToMonitor defines the DOM element to track
  76911. */
  76912. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76913. /** Gets the current list of files to load */
  76914. get filesToLoad(): File[];
  76915. /**
  76916. * Release all associated resources
  76917. */
  76918. dispose(): void;
  76919. private renderFunction;
  76920. private drag;
  76921. private drop;
  76922. private _traverseFolder;
  76923. private _processFiles;
  76924. /**
  76925. * Load files from a drop event
  76926. * @param event defines the drop event to use as source
  76927. */
  76928. loadFiles(event: any): void;
  76929. private _processReload;
  76930. /**
  76931. * Reload the current scene from the loaded files
  76932. */
  76933. reload(): void;
  76934. }
  76935. }
  76936. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76937. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76938. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76939. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76940. }
  76941. declare module "babylonjs/Misc/sceneOptimizer" {
  76942. import { Scene, IDisposable } from "babylonjs/scene";
  76943. import { Observable } from "babylonjs/Misc/observable";
  76944. /**
  76945. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76946. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76947. */
  76948. export class SceneOptimization {
  76949. /**
  76950. * Defines the priority of this optimization (0 by default which means first in the list)
  76951. */
  76952. priority: number;
  76953. /**
  76954. * Gets a string describing the action executed by the current optimization
  76955. * @returns description string
  76956. */
  76957. getDescription(): string;
  76958. /**
  76959. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76960. * @param scene defines the current scene where to apply this optimization
  76961. * @param optimizer defines the current optimizer
  76962. * @returns true if everything that can be done was applied
  76963. */
  76964. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76965. /**
  76966. * Creates the SceneOptimization object
  76967. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76968. * @param desc defines the description associated with the optimization
  76969. */
  76970. constructor(
  76971. /**
  76972. * Defines the priority of this optimization (0 by default which means first in the list)
  76973. */
  76974. priority?: number);
  76975. }
  76976. /**
  76977. * Defines an optimization used to reduce the size of render target textures
  76978. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76979. */
  76980. export class TextureOptimization extends SceneOptimization {
  76981. /**
  76982. * Defines the priority of this optimization (0 by default which means first in the list)
  76983. */
  76984. priority: number;
  76985. /**
  76986. * 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
  76987. */
  76988. maximumSize: number;
  76989. /**
  76990. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76991. */
  76992. step: number;
  76993. /**
  76994. * Gets a string describing the action executed by the current optimization
  76995. * @returns description string
  76996. */
  76997. getDescription(): string;
  76998. /**
  76999. * Creates the TextureOptimization object
  77000. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77001. * @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
  77002. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77003. */
  77004. constructor(
  77005. /**
  77006. * Defines the priority of this optimization (0 by default which means first in the list)
  77007. */
  77008. priority?: number,
  77009. /**
  77010. * 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
  77011. */
  77012. maximumSize?: number,
  77013. /**
  77014. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77015. */
  77016. step?: number);
  77017. /**
  77018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77019. * @param scene defines the current scene where to apply this optimization
  77020. * @param optimizer defines the current optimizer
  77021. * @returns true if everything that can be done was applied
  77022. */
  77023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77024. }
  77025. /**
  77026. * Defines an optimization used to increase or decrease the rendering resolution
  77027. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77028. */
  77029. export class HardwareScalingOptimization extends SceneOptimization {
  77030. /**
  77031. * Defines the priority of this optimization (0 by default which means first in the list)
  77032. */
  77033. priority: number;
  77034. /**
  77035. * Defines the maximum scale to use (2 by default)
  77036. */
  77037. maximumScale: number;
  77038. /**
  77039. * Defines the step to use between two passes (0.5 by default)
  77040. */
  77041. step: number;
  77042. private _currentScale;
  77043. private _directionOffset;
  77044. /**
  77045. * Gets a string describing the action executed by the current optimization
  77046. * @return description string
  77047. */
  77048. getDescription(): string;
  77049. /**
  77050. * Creates the HardwareScalingOptimization object
  77051. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77052. * @param maximumScale defines the maximum scale to use (2 by default)
  77053. * @param step defines the step to use between two passes (0.5 by default)
  77054. */
  77055. constructor(
  77056. /**
  77057. * Defines the priority of this optimization (0 by default which means first in the list)
  77058. */
  77059. priority?: number,
  77060. /**
  77061. * Defines the maximum scale to use (2 by default)
  77062. */
  77063. maximumScale?: number,
  77064. /**
  77065. * Defines the step to use between two passes (0.5 by default)
  77066. */
  77067. step?: number);
  77068. /**
  77069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77070. * @param scene defines the current scene where to apply this optimization
  77071. * @param optimizer defines the current optimizer
  77072. * @returns true if everything that can be done was applied
  77073. */
  77074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77075. }
  77076. /**
  77077. * Defines an optimization used to remove shadows
  77078. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77079. */
  77080. export class ShadowsOptimization extends SceneOptimization {
  77081. /**
  77082. * Gets a string describing the action executed by the current optimization
  77083. * @return description string
  77084. */
  77085. getDescription(): string;
  77086. /**
  77087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77088. * @param scene defines the current scene where to apply this optimization
  77089. * @param optimizer defines the current optimizer
  77090. * @returns true if everything that can be done was applied
  77091. */
  77092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77093. }
  77094. /**
  77095. * Defines an optimization used to turn post-processes off
  77096. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77097. */
  77098. export class PostProcessesOptimization extends SceneOptimization {
  77099. /**
  77100. * Gets a string describing the action executed by the current optimization
  77101. * @return description string
  77102. */
  77103. getDescription(): string;
  77104. /**
  77105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77106. * @param scene defines the current scene where to apply this optimization
  77107. * @param optimizer defines the current optimizer
  77108. * @returns true if everything that can be done was applied
  77109. */
  77110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77111. }
  77112. /**
  77113. * Defines an optimization used to turn lens flares off
  77114. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77115. */
  77116. export class LensFlaresOptimization extends SceneOptimization {
  77117. /**
  77118. * Gets a string describing the action executed by the current optimization
  77119. * @return description string
  77120. */
  77121. getDescription(): string;
  77122. /**
  77123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77124. * @param scene defines the current scene where to apply this optimization
  77125. * @param optimizer defines the current optimizer
  77126. * @returns true if everything that can be done was applied
  77127. */
  77128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77129. }
  77130. /**
  77131. * Defines an optimization based on user defined callback.
  77132. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77133. */
  77134. export class CustomOptimization extends SceneOptimization {
  77135. /**
  77136. * Callback called to apply the custom optimization.
  77137. */
  77138. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77139. /**
  77140. * Callback called to get custom description
  77141. */
  77142. onGetDescription: () => string;
  77143. /**
  77144. * Gets a string describing the action executed by the current optimization
  77145. * @returns description string
  77146. */
  77147. getDescription(): string;
  77148. /**
  77149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77150. * @param scene defines the current scene where to apply this optimization
  77151. * @param optimizer defines the current optimizer
  77152. * @returns true if everything that can be done was applied
  77153. */
  77154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77155. }
  77156. /**
  77157. * Defines an optimization used to turn particles off
  77158. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77159. */
  77160. export class ParticlesOptimization extends SceneOptimization {
  77161. /**
  77162. * Gets a string describing the action executed by the current optimization
  77163. * @return description string
  77164. */
  77165. getDescription(): string;
  77166. /**
  77167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77168. * @param scene defines the current scene where to apply this optimization
  77169. * @param optimizer defines the current optimizer
  77170. * @returns true if everything that can be done was applied
  77171. */
  77172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77173. }
  77174. /**
  77175. * Defines an optimization used to turn render targets off
  77176. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77177. */
  77178. export class RenderTargetsOptimization extends SceneOptimization {
  77179. /**
  77180. * Gets a string describing the action executed by the current optimization
  77181. * @return description string
  77182. */
  77183. getDescription(): string;
  77184. /**
  77185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77186. * @param scene defines the current scene where to apply this optimization
  77187. * @param optimizer defines the current optimizer
  77188. * @returns true if everything that can be done was applied
  77189. */
  77190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77191. }
  77192. /**
  77193. * Defines an optimization used to merge meshes with compatible materials
  77194. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77195. */
  77196. export class MergeMeshesOptimization extends SceneOptimization {
  77197. private static _UpdateSelectionTree;
  77198. /**
  77199. * Gets or sets a boolean which defines if optimization octree has to be updated
  77200. */
  77201. static get UpdateSelectionTree(): boolean;
  77202. /**
  77203. * Gets or sets a boolean which defines if optimization octree has to be updated
  77204. */
  77205. static set UpdateSelectionTree(value: boolean);
  77206. /**
  77207. * Gets a string describing the action executed by the current optimization
  77208. * @return description string
  77209. */
  77210. getDescription(): string;
  77211. private _canBeMerged;
  77212. /**
  77213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77214. * @param scene defines the current scene where to apply this optimization
  77215. * @param optimizer defines the current optimizer
  77216. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77217. * @returns true if everything that can be done was applied
  77218. */
  77219. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77220. }
  77221. /**
  77222. * Defines a list of options used by SceneOptimizer
  77223. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77224. */
  77225. export class SceneOptimizerOptions {
  77226. /**
  77227. * Defines the target frame rate to reach (60 by default)
  77228. */
  77229. targetFrameRate: number;
  77230. /**
  77231. * Defines the interval between two checkes (2000ms by default)
  77232. */
  77233. trackerDuration: number;
  77234. /**
  77235. * Gets the list of optimizations to apply
  77236. */
  77237. optimizations: SceneOptimization[];
  77238. /**
  77239. * Creates a new list of options used by SceneOptimizer
  77240. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77241. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77242. */
  77243. constructor(
  77244. /**
  77245. * Defines the target frame rate to reach (60 by default)
  77246. */
  77247. targetFrameRate?: number,
  77248. /**
  77249. * Defines the interval between two checkes (2000ms by default)
  77250. */
  77251. trackerDuration?: number);
  77252. /**
  77253. * Add a new optimization
  77254. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77255. * @returns the current SceneOptimizerOptions
  77256. */
  77257. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77258. /**
  77259. * Add a new custom optimization
  77260. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77261. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77262. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77263. * @returns the current SceneOptimizerOptions
  77264. */
  77265. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77266. /**
  77267. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77268. * @param targetFrameRate defines the target frame rate (60 by default)
  77269. * @returns a SceneOptimizerOptions object
  77270. */
  77271. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77272. /**
  77273. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77274. * @param targetFrameRate defines the target frame rate (60 by default)
  77275. * @returns a SceneOptimizerOptions object
  77276. */
  77277. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77278. /**
  77279. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77280. * @param targetFrameRate defines the target frame rate (60 by default)
  77281. * @returns a SceneOptimizerOptions object
  77282. */
  77283. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77284. }
  77285. /**
  77286. * Class used to run optimizations in order to reach a target frame rate
  77287. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77288. */
  77289. export class SceneOptimizer implements IDisposable {
  77290. private _isRunning;
  77291. private _options;
  77292. private _scene;
  77293. private _currentPriorityLevel;
  77294. private _targetFrameRate;
  77295. private _trackerDuration;
  77296. private _currentFrameRate;
  77297. private _sceneDisposeObserver;
  77298. private _improvementMode;
  77299. /**
  77300. * Defines an observable called when the optimizer reaches the target frame rate
  77301. */
  77302. onSuccessObservable: Observable<SceneOptimizer>;
  77303. /**
  77304. * Defines an observable called when the optimizer enables an optimization
  77305. */
  77306. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77307. /**
  77308. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77309. */
  77310. onFailureObservable: Observable<SceneOptimizer>;
  77311. /**
  77312. * Gets a boolean indicating if the optimizer is in improvement mode
  77313. */
  77314. get isInImprovementMode(): boolean;
  77315. /**
  77316. * Gets the current priority level (0 at start)
  77317. */
  77318. get currentPriorityLevel(): number;
  77319. /**
  77320. * Gets the current frame rate checked by the SceneOptimizer
  77321. */
  77322. get currentFrameRate(): number;
  77323. /**
  77324. * Gets or sets the current target frame rate (60 by default)
  77325. */
  77326. get targetFrameRate(): number;
  77327. /**
  77328. * Gets or sets the current target frame rate (60 by default)
  77329. */
  77330. set targetFrameRate(value: number);
  77331. /**
  77332. * Gets or sets the current interval between two checks (every 2000ms by default)
  77333. */
  77334. get trackerDuration(): number;
  77335. /**
  77336. * Gets or sets the current interval between two checks (every 2000ms by default)
  77337. */
  77338. set trackerDuration(value: number);
  77339. /**
  77340. * Gets the list of active optimizations
  77341. */
  77342. get optimizations(): SceneOptimization[];
  77343. /**
  77344. * Creates a new SceneOptimizer
  77345. * @param scene defines the scene to work on
  77346. * @param options defines the options to use with the SceneOptimizer
  77347. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77348. * @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)
  77349. */
  77350. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77351. /**
  77352. * Stops the current optimizer
  77353. */
  77354. stop(): void;
  77355. /**
  77356. * Reset the optimizer to initial step (current priority level = 0)
  77357. */
  77358. reset(): void;
  77359. /**
  77360. * Start the optimizer. By default it will try to reach a specific framerate
  77361. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77362. */
  77363. start(): void;
  77364. private _checkCurrentState;
  77365. /**
  77366. * Release all resources
  77367. */
  77368. dispose(): void;
  77369. /**
  77370. * Helper function to create a SceneOptimizer with one single line of code
  77371. * @param scene defines the scene to work on
  77372. * @param options defines the options to use with the SceneOptimizer
  77373. * @param onSuccess defines a callback to call on success
  77374. * @param onFailure defines a callback to call on failure
  77375. * @returns the new SceneOptimizer object
  77376. */
  77377. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77378. }
  77379. }
  77380. declare module "babylonjs/Misc/sceneSerializer" {
  77381. import { Scene } from "babylonjs/scene";
  77382. /**
  77383. * Class used to serialize a scene into a string
  77384. */
  77385. export class SceneSerializer {
  77386. /**
  77387. * Clear cache used by a previous serialization
  77388. */
  77389. static ClearCache(): void;
  77390. /**
  77391. * Serialize a scene into a JSON compatible object
  77392. * @param scene defines the scene to serialize
  77393. * @returns a JSON compatible object
  77394. */
  77395. static Serialize(scene: Scene): any;
  77396. /**
  77397. * Serialize a mesh into a JSON compatible object
  77398. * @param toSerialize defines the mesh to serialize
  77399. * @param withParents defines if parents must be serialized as well
  77400. * @param withChildren defines if children must be serialized as well
  77401. * @returns a JSON compatible object
  77402. */
  77403. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77404. }
  77405. }
  77406. declare module "babylonjs/Misc/textureTools" {
  77407. import { Texture } from "babylonjs/Materials/Textures/texture";
  77408. /**
  77409. * Class used to host texture specific utilities
  77410. */
  77411. export class TextureTools {
  77412. /**
  77413. * Uses the GPU to create a copy texture rescaled at a given size
  77414. * @param texture Texture to copy from
  77415. * @param width defines the desired width
  77416. * @param height defines the desired height
  77417. * @param useBilinearMode defines if bilinear mode has to be used
  77418. * @return the generated texture
  77419. */
  77420. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77421. }
  77422. }
  77423. declare module "babylonjs/Misc/videoRecorder" {
  77424. import { Nullable } from "babylonjs/types";
  77425. import { Engine } from "babylonjs/Engines/engine";
  77426. /**
  77427. * This represents the different options available for the video capture.
  77428. */
  77429. export interface VideoRecorderOptions {
  77430. /** Defines the mime type of the video. */
  77431. mimeType: string;
  77432. /** Defines the FPS the video should be recorded at. */
  77433. fps: number;
  77434. /** Defines the chunk size for the recording data. */
  77435. recordChunckSize: number;
  77436. /** The audio tracks to attach to the recording. */
  77437. audioTracks?: MediaStreamTrack[];
  77438. }
  77439. /**
  77440. * This can help with recording videos from BabylonJS.
  77441. * This is based on the available WebRTC functionalities of the browser.
  77442. *
  77443. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77444. */
  77445. export class VideoRecorder {
  77446. private static readonly _defaultOptions;
  77447. /**
  77448. * Returns whether or not the VideoRecorder is available in your browser.
  77449. * @param engine Defines the Babylon Engine.
  77450. * @returns true if supported otherwise false.
  77451. */
  77452. static IsSupported(engine: Engine): boolean;
  77453. private readonly _options;
  77454. private _canvas;
  77455. private _mediaRecorder;
  77456. private _recordedChunks;
  77457. private _fileName;
  77458. private _resolve;
  77459. private _reject;
  77460. /**
  77461. * True when a recording is already in progress.
  77462. */
  77463. get isRecording(): boolean;
  77464. /**
  77465. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77466. * @param engine Defines the BabylonJS Engine you wish to record.
  77467. * @param options Defines options that can be used to customize the capture.
  77468. */
  77469. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77470. /**
  77471. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77472. */
  77473. stopRecording(): void;
  77474. /**
  77475. * Starts recording the canvas for a max duration specified in parameters.
  77476. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77477. * If null no automatic download will start and you can rely on the promise to get the data back.
  77478. * @param maxDuration Defines the maximum recording time in seconds.
  77479. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77480. * @return A promise callback at the end of the recording with the video data in Blob.
  77481. */
  77482. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77483. /**
  77484. * Releases internal resources used during the recording.
  77485. */
  77486. dispose(): void;
  77487. private _handleDataAvailable;
  77488. private _handleError;
  77489. private _handleStop;
  77490. }
  77491. }
  77492. declare module "babylonjs/Misc/screenshotTools" {
  77493. import { Camera } from "babylonjs/Cameras/camera";
  77494. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77495. import { Engine } from "babylonjs/Engines/engine";
  77496. /**
  77497. * Class containing a set of static utilities functions for screenshots
  77498. */
  77499. export class ScreenshotTools {
  77500. /**
  77501. * Captures a screenshot of the current rendering
  77502. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77503. * @param engine defines the rendering engine
  77504. * @param camera defines the source camera
  77505. * @param size This parameter can be set to a single number or to an object with the
  77506. * following (optional) properties: precision, width, height. If a single number is passed,
  77507. * it will be used for both width and height. If an object is passed, the screenshot size
  77508. * will be derived from the parameters. The precision property is a multiplier allowing
  77509. * rendering at a higher or lower resolution
  77510. * @param successCallback defines the callback receives a single parameter which contains the
  77511. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77512. * src parameter of an <img> to display it
  77513. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77514. * Check your browser for supported MIME types
  77515. */
  77516. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77517. /**
  77518. * Captures a screenshot of the current rendering
  77519. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77520. * @param engine defines the rendering engine
  77521. * @param camera defines the source camera
  77522. * @param size This parameter can be set to a single number or to an object with the
  77523. * following (optional) properties: precision, width, height. If a single number is passed,
  77524. * it will be used for both width and height. If an object is passed, the screenshot size
  77525. * will be derived from the parameters. The precision property is a multiplier allowing
  77526. * rendering at a higher or lower resolution
  77527. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77528. * Check your browser for supported MIME types
  77529. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77530. * to the src parameter of an <img> to display it
  77531. */
  77532. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77533. /**
  77534. * Generates an image screenshot from the specified camera.
  77535. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77536. * @param engine The engine to use for rendering
  77537. * @param camera The camera to use for rendering
  77538. * @param size This parameter can be set to a single number or to an object with the
  77539. * following (optional) properties: precision, width, height. If a single number is passed,
  77540. * it will be used for both width and height. If an object is passed, the screenshot size
  77541. * will be derived from the parameters. The precision property is a multiplier allowing
  77542. * rendering at a higher or lower resolution
  77543. * @param successCallback The callback receives a single parameter which contains the
  77544. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77545. * src parameter of an <img> to display it
  77546. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77547. * Check your browser for supported MIME types
  77548. * @param samples Texture samples (default: 1)
  77549. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77550. * @param fileName A name for for the downloaded file.
  77551. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77552. */
  77553. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77554. /**
  77555. * Generates an image screenshot from the specified camera.
  77556. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77557. * @param engine The engine to use for rendering
  77558. * @param camera The camera to use for rendering
  77559. * @param size This parameter can be set to a single number or to an object with the
  77560. * following (optional) properties: precision, width, height. If a single number is passed,
  77561. * it will be used for both width and height. If an object is passed, the screenshot size
  77562. * will be derived from the parameters. The precision property is a multiplier allowing
  77563. * rendering at a higher or lower resolution
  77564. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77565. * Check your browser for supported MIME types
  77566. * @param samples Texture samples (default: 1)
  77567. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77568. * @param fileName A name for for the downloaded file.
  77569. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77570. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77571. * to the src parameter of an <img> to display it
  77572. */
  77573. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77574. /**
  77575. * Gets height and width for screenshot size
  77576. * @private
  77577. */
  77578. private static _getScreenshotSize;
  77579. }
  77580. }
  77581. declare module "babylonjs/Misc/dataReader" {
  77582. /**
  77583. * Interface for a data buffer
  77584. */
  77585. export interface IDataBuffer {
  77586. /**
  77587. * Reads bytes from the data buffer.
  77588. * @param byteOffset The byte offset to read
  77589. * @param byteLength The byte length to read
  77590. * @returns A promise that resolves when the bytes are read
  77591. */
  77592. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77593. /**
  77594. * The byte length of the buffer.
  77595. */
  77596. readonly byteLength: number;
  77597. }
  77598. /**
  77599. * Utility class for reading from a data buffer
  77600. */
  77601. export class DataReader {
  77602. /**
  77603. * The data buffer associated with this data reader.
  77604. */
  77605. readonly buffer: IDataBuffer;
  77606. /**
  77607. * The current byte offset from the beginning of the data buffer.
  77608. */
  77609. byteOffset: number;
  77610. private _dataView;
  77611. private _dataByteOffset;
  77612. /**
  77613. * Constructor
  77614. * @param buffer The buffer to read
  77615. */
  77616. constructor(buffer: IDataBuffer);
  77617. /**
  77618. * Loads the given byte length.
  77619. * @param byteLength The byte length to load
  77620. * @returns A promise that resolves when the load is complete
  77621. */
  77622. loadAsync(byteLength: number): Promise<void>;
  77623. /**
  77624. * Read a unsigned 32-bit integer from the currently loaded data range.
  77625. * @returns The 32-bit integer read
  77626. */
  77627. readUint32(): number;
  77628. /**
  77629. * Read a byte array from the currently loaded data range.
  77630. * @param byteLength The byte length to read
  77631. * @returns The byte array read
  77632. */
  77633. readUint8Array(byteLength: number): Uint8Array;
  77634. /**
  77635. * Read a string from the currently loaded data range.
  77636. * @param byteLength The byte length to read
  77637. * @returns The string read
  77638. */
  77639. readString(byteLength: number): string;
  77640. /**
  77641. * Skips the given byte length the currently loaded data range.
  77642. * @param byteLength The byte length to skip
  77643. */
  77644. skipBytes(byteLength: number): void;
  77645. }
  77646. }
  77647. declare module "babylonjs/Misc/dataStorage" {
  77648. /**
  77649. * Class for storing data to local storage if available or in-memory storage otherwise
  77650. */
  77651. export class DataStorage {
  77652. private static _Storage;
  77653. private static _GetStorage;
  77654. /**
  77655. * Reads a string from the data storage
  77656. * @param key The key to read
  77657. * @param defaultValue The value if the key doesn't exist
  77658. * @returns The string value
  77659. */
  77660. static ReadString(key: string, defaultValue: string): string;
  77661. /**
  77662. * Writes a string to the data storage
  77663. * @param key The key to write
  77664. * @param value The value to write
  77665. */
  77666. static WriteString(key: string, value: string): void;
  77667. /**
  77668. * Reads a boolean from the data storage
  77669. * @param key The key to read
  77670. * @param defaultValue The value if the key doesn't exist
  77671. * @returns The boolean value
  77672. */
  77673. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77674. /**
  77675. * Writes a boolean to the data storage
  77676. * @param key The key to write
  77677. * @param value The value to write
  77678. */
  77679. static WriteBoolean(key: string, value: boolean): void;
  77680. /**
  77681. * Reads a number from the data storage
  77682. * @param key The key to read
  77683. * @param defaultValue The value if the key doesn't exist
  77684. * @returns The number value
  77685. */
  77686. static ReadNumber(key: string, defaultValue: number): number;
  77687. /**
  77688. * Writes a number to the data storage
  77689. * @param key The key to write
  77690. * @param value The value to write
  77691. */
  77692. static WriteNumber(key: string, value: number): void;
  77693. }
  77694. }
  77695. declare module "babylonjs/Misc/sceneRecorder" {
  77696. import { Scene } from "babylonjs/scene";
  77697. /**
  77698. * Class used to record delta files between 2 scene states
  77699. */
  77700. export class SceneRecorder {
  77701. private _trackedScene;
  77702. private _savedJSON;
  77703. /**
  77704. * Track a given scene. This means the current scene state will be considered the original state
  77705. * @param scene defines the scene to track
  77706. */
  77707. track(scene: Scene): void;
  77708. /**
  77709. * Get the delta between current state and original state
  77710. * @returns a string containing the delta
  77711. */
  77712. getDelta(): any;
  77713. private _compareArray;
  77714. private _compareObjects;
  77715. private _compareCollections;
  77716. private static GetShadowGeneratorById;
  77717. /**
  77718. * Apply a given delta to a given scene
  77719. * @param deltaJSON defines the JSON containing the delta
  77720. * @param scene defines the scene to apply the delta to
  77721. */
  77722. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  77723. private static _ApplyPropertiesToEntity;
  77724. private static _ApplyDeltaForEntity;
  77725. }
  77726. }
  77727. declare module "babylonjs/Misc/index" {
  77728. export * from "babylonjs/Misc/andOrNotEvaluator";
  77729. export * from "babylonjs/Misc/assetsManager";
  77730. export * from "babylonjs/Misc/basis";
  77731. export * from "babylonjs/Misc/dds";
  77732. export * from "babylonjs/Misc/decorators";
  77733. export * from "babylonjs/Misc/deferred";
  77734. export * from "babylonjs/Misc/environmentTextureTools";
  77735. export * from "babylonjs/Misc/meshExploder";
  77736. export * from "babylonjs/Misc/filesInput";
  77737. export * from "babylonjs/Misc/HighDynamicRange/index";
  77738. export * from "babylonjs/Misc/khronosTextureContainer";
  77739. export * from "babylonjs/Misc/observable";
  77740. export * from "babylonjs/Misc/performanceMonitor";
  77741. export * from "babylonjs/Misc/promise";
  77742. export * from "babylonjs/Misc/sceneOptimizer";
  77743. export * from "babylonjs/Misc/sceneSerializer";
  77744. export * from "babylonjs/Misc/smartArray";
  77745. export * from "babylonjs/Misc/stringDictionary";
  77746. export * from "babylonjs/Misc/tags";
  77747. export * from "babylonjs/Misc/textureTools";
  77748. export * from "babylonjs/Misc/tga";
  77749. export * from "babylonjs/Misc/tools";
  77750. export * from "babylonjs/Misc/videoRecorder";
  77751. export * from "babylonjs/Misc/virtualJoystick";
  77752. export * from "babylonjs/Misc/workerPool";
  77753. export * from "babylonjs/Misc/logger";
  77754. export * from "babylonjs/Misc/typeStore";
  77755. export * from "babylonjs/Misc/filesInputStore";
  77756. export * from "babylonjs/Misc/deepCopier";
  77757. export * from "babylonjs/Misc/pivotTools";
  77758. export * from "babylonjs/Misc/precisionDate";
  77759. export * from "babylonjs/Misc/screenshotTools";
  77760. export * from "babylonjs/Misc/typeStore";
  77761. export * from "babylonjs/Misc/webRequest";
  77762. export * from "babylonjs/Misc/iInspectable";
  77763. export * from "babylonjs/Misc/brdfTextureTools";
  77764. export * from "babylonjs/Misc/rgbdTextureTools";
  77765. export * from "babylonjs/Misc/gradients";
  77766. export * from "babylonjs/Misc/perfCounter";
  77767. export * from "babylonjs/Misc/fileRequest";
  77768. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77769. export * from "babylonjs/Misc/retryStrategy";
  77770. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77771. export * from "babylonjs/Misc/canvasGenerator";
  77772. export * from "babylonjs/Misc/fileTools";
  77773. export * from "babylonjs/Misc/stringTools";
  77774. export * from "babylonjs/Misc/dataReader";
  77775. export * from "babylonjs/Misc/minMaxReducer";
  77776. export * from "babylonjs/Misc/depthReducer";
  77777. export * from "babylonjs/Misc/dataStorage";
  77778. export * from "babylonjs/Misc/sceneRecorder";
  77779. }
  77780. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77781. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77782. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77783. import { Observable } from "babylonjs/Misc/observable";
  77784. import { Matrix } from "babylonjs/Maths/math.vector";
  77785. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77786. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77787. /**
  77788. * An interface for all Hit test features
  77789. */
  77790. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77791. /**
  77792. * Triggered when new babylon (transformed) hit test results are available
  77793. */
  77794. onHitTestResultObservable: Observable<T[]>;
  77795. }
  77796. /**
  77797. * Options used for hit testing
  77798. */
  77799. export interface IWebXRLegacyHitTestOptions {
  77800. /**
  77801. * Only test when user interacted with the scene. Default - hit test every frame
  77802. */
  77803. testOnPointerDownOnly?: boolean;
  77804. /**
  77805. * The node to use to transform the local results to world coordinates
  77806. */
  77807. worldParentNode?: TransformNode;
  77808. }
  77809. /**
  77810. * Interface defining the babylon result of raycasting/hit-test
  77811. */
  77812. export interface IWebXRLegacyHitResult {
  77813. /**
  77814. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77815. */
  77816. transformationMatrix: Matrix;
  77817. /**
  77818. * The native hit test result
  77819. */
  77820. xrHitResult: XRHitResult | XRHitTestResult;
  77821. }
  77822. /**
  77823. * The currently-working hit-test module.
  77824. * Hit test (or Ray-casting) is used to interact with the real world.
  77825. * For further information read here - https://github.com/immersive-web/hit-test
  77826. */
  77827. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77828. /**
  77829. * options to use when constructing this feature
  77830. */
  77831. readonly options: IWebXRLegacyHitTestOptions;
  77832. private _direction;
  77833. private _mat;
  77834. private _onSelectEnabled;
  77835. private _origin;
  77836. /**
  77837. * The module's name
  77838. */
  77839. static readonly Name: string;
  77840. /**
  77841. * The (Babylon) version of this module.
  77842. * This is an integer representing the implementation version.
  77843. * This number does not correspond to the WebXR specs version
  77844. */
  77845. static readonly Version: number;
  77846. /**
  77847. * Populated with the last native XR Hit Results
  77848. */
  77849. lastNativeXRHitResults: XRHitResult[];
  77850. /**
  77851. * Triggered when new babylon (transformed) hit test results are available
  77852. */
  77853. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77854. /**
  77855. * Creates a new instance of the (legacy version) hit test feature
  77856. * @param _xrSessionManager an instance of WebXRSessionManager
  77857. * @param options options to use when constructing this feature
  77858. */
  77859. constructor(_xrSessionManager: WebXRSessionManager,
  77860. /**
  77861. * options to use when constructing this feature
  77862. */
  77863. options?: IWebXRLegacyHitTestOptions);
  77864. /**
  77865. * execute a hit test with an XR Ray
  77866. *
  77867. * @param xrSession a native xrSession that will execute this hit test
  77868. * @param xrRay the ray (position and direction) to use for ray-casting
  77869. * @param referenceSpace native XR reference space to use for the hit-test
  77870. * @param filter filter function that will filter the results
  77871. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77872. */
  77873. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77874. /**
  77875. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77876. * @param event the (select) event to use to select with
  77877. * @param referenceSpace the reference space to use for this hit test
  77878. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77879. */
  77880. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77881. /**
  77882. * attach this feature
  77883. * Will usually be called by the features manager
  77884. *
  77885. * @returns true if successful.
  77886. */
  77887. attach(): boolean;
  77888. /**
  77889. * detach this feature.
  77890. * Will usually be called by the features manager
  77891. *
  77892. * @returns true if successful.
  77893. */
  77894. detach(): boolean;
  77895. /**
  77896. * Dispose this feature and all of the resources attached
  77897. */
  77898. dispose(): void;
  77899. protected _onXRFrame(frame: XRFrame): void;
  77900. private _onHitTestResults;
  77901. private _onSelect;
  77902. }
  77903. }
  77904. declare module "babylonjs/XR/features/WebXRHitTest" {
  77905. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77906. import { Observable } from "babylonjs/Misc/observable";
  77907. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77908. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77909. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77910. /**
  77911. * Options used for hit testing (version 2)
  77912. */
  77913. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77914. /**
  77915. * Do not create a permanent hit test. Will usually be used when only
  77916. * transient inputs are needed.
  77917. */
  77918. disablePermanentHitTest?: boolean;
  77919. /**
  77920. * Enable transient (for example touch-based) hit test inspections
  77921. */
  77922. enableTransientHitTest?: boolean;
  77923. /**
  77924. * Offset ray for the permanent hit test
  77925. */
  77926. offsetRay?: Vector3;
  77927. /**
  77928. * Offset ray for the transient hit test
  77929. */
  77930. transientOffsetRay?: Vector3;
  77931. /**
  77932. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77933. */
  77934. useReferenceSpace?: boolean;
  77935. }
  77936. /**
  77937. * Interface defining the babylon result of hit-test
  77938. */
  77939. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77940. /**
  77941. * The input source that generated this hit test (if transient)
  77942. */
  77943. inputSource?: XRInputSource;
  77944. /**
  77945. * Is this a transient hit test
  77946. */
  77947. isTransient?: boolean;
  77948. /**
  77949. * Position of the hit test result
  77950. */
  77951. position: Vector3;
  77952. /**
  77953. * Rotation of the hit test result
  77954. */
  77955. rotationQuaternion: Quaternion;
  77956. /**
  77957. * The native hit test result
  77958. */
  77959. xrHitResult: XRHitTestResult;
  77960. }
  77961. /**
  77962. * The currently-working hit-test module.
  77963. * Hit test (or Ray-casting) is used to interact with the real world.
  77964. * For further information read here - https://github.com/immersive-web/hit-test
  77965. *
  77966. * Tested on chrome (mobile) 80.
  77967. */
  77968. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77969. /**
  77970. * options to use when constructing this feature
  77971. */
  77972. readonly options: IWebXRHitTestOptions;
  77973. private _tmpMat;
  77974. private _tmpPos;
  77975. private _tmpQuat;
  77976. private _transientXrHitTestSource;
  77977. private _xrHitTestSource;
  77978. private initHitTestSource;
  77979. /**
  77980. * The module's name
  77981. */
  77982. static readonly Name: string;
  77983. /**
  77984. * The (Babylon) version of this module.
  77985. * This is an integer representing the implementation version.
  77986. * This number does not correspond to the WebXR specs version
  77987. */
  77988. static readonly Version: number;
  77989. /**
  77990. * When set to true, each hit test will have its own position/rotation objects
  77991. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77992. * the developers will clone them or copy them as they see fit.
  77993. */
  77994. autoCloneTransformation: boolean;
  77995. /**
  77996. * Triggered when new babylon (transformed) hit test results are available
  77997. */
  77998. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77999. /**
  78000. * Use this to temporarily pause hit test checks.
  78001. */
  78002. paused: boolean;
  78003. /**
  78004. * Creates a new instance of the hit test feature
  78005. * @param _xrSessionManager an instance of WebXRSessionManager
  78006. * @param options options to use when constructing this feature
  78007. */
  78008. constructor(_xrSessionManager: WebXRSessionManager,
  78009. /**
  78010. * options to use when constructing this feature
  78011. */
  78012. options?: IWebXRHitTestOptions);
  78013. /**
  78014. * attach this feature
  78015. * Will usually be called by the features manager
  78016. *
  78017. * @returns true if successful.
  78018. */
  78019. attach(): boolean;
  78020. /**
  78021. * detach this feature.
  78022. * Will usually be called by the features manager
  78023. *
  78024. * @returns true if successful.
  78025. */
  78026. detach(): boolean;
  78027. /**
  78028. * Dispose this feature and all of the resources attached
  78029. */
  78030. dispose(): void;
  78031. protected _onXRFrame(frame: XRFrame): void;
  78032. private _processWebXRHitTestResult;
  78033. }
  78034. }
  78035. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78036. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78037. import { Observable } from "babylonjs/Misc/observable";
  78038. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78039. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78040. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78041. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78042. /**
  78043. * Configuration options of the anchor system
  78044. */
  78045. export interface IWebXRAnchorSystemOptions {
  78046. /**
  78047. * a node that will be used to convert local to world coordinates
  78048. */
  78049. worldParentNode?: TransformNode;
  78050. /**
  78051. * If set to true a reference of the created anchors will be kept until the next session starts
  78052. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78053. */
  78054. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78055. }
  78056. /**
  78057. * A babylon container for an XR Anchor
  78058. */
  78059. export interface IWebXRAnchor {
  78060. /**
  78061. * A babylon-assigned ID for this anchor
  78062. */
  78063. id: number;
  78064. /**
  78065. * Transformation matrix to apply to an object attached to this anchor
  78066. */
  78067. transformationMatrix: Matrix;
  78068. /**
  78069. * The native anchor object
  78070. */
  78071. xrAnchor: XRAnchor;
  78072. /**
  78073. * if defined, this object will be constantly updated by the anchor's position and rotation
  78074. */
  78075. attachedNode?: TransformNode;
  78076. }
  78077. /**
  78078. * An implementation of the anchor system for WebXR.
  78079. * For further information see https://github.com/immersive-web/anchors/
  78080. */
  78081. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78082. private _options;
  78083. private _lastFrameDetected;
  78084. private _trackedAnchors;
  78085. private _referenceSpaceForFrameAnchors;
  78086. private _futureAnchors;
  78087. /**
  78088. * The module's name
  78089. */
  78090. static readonly Name: string;
  78091. /**
  78092. * The (Babylon) version of this module.
  78093. * This is an integer representing the implementation version.
  78094. * This number does not correspond to the WebXR specs version
  78095. */
  78096. static readonly Version: number;
  78097. /**
  78098. * Observers registered here will be executed when a new anchor was added to the session
  78099. */
  78100. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78101. /**
  78102. * Observers registered here will be executed when an anchor was removed from the session
  78103. */
  78104. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78105. /**
  78106. * Observers registered here will be executed when an existing anchor updates
  78107. * This can execute N times every frame
  78108. */
  78109. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78110. /**
  78111. * Set the reference space to use for anchor creation, when not using a hit test.
  78112. * Will default to the session's reference space if not defined
  78113. */
  78114. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78115. /**
  78116. * constructs a new anchor system
  78117. * @param _xrSessionManager an instance of WebXRSessionManager
  78118. * @param _options configuration object for this feature
  78119. */
  78120. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78121. private _tmpVector;
  78122. private _tmpQuaternion;
  78123. private _populateTmpTransformation;
  78124. /**
  78125. * Create a new anchor point using a hit test result at a specific point in the scene
  78126. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78127. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78128. *
  78129. * @param hitTestResult The hit test result to use for this anchor creation
  78130. * @param position an optional position offset for this anchor
  78131. * @param rotationQuaternion an optional rotation offset for this anchor
  78132. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78133. */
  78134. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78135. /**
  78136. * Add a new anchor at a specific position and rotation
  78137. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78138. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78139. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78140. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78141. *
  78142. * @param position the position in which to add an anchor
  78143. * @param rotationQuaternion an optional rotation for the anchor transformation
  78144. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78145. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78146. */
  78147. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78148. /**
  78149. * detach this feature.
  78150. * Will usually be called by the features manager
  78151. *
  78152. * @returns true if successful.
  78153. */
  78154. detach(): boolean;
  78155. /**
  78156. * Dispose this feature and all of the resources attached
  78157. */
  78158. dispose(): void;
  78159. protected _onXRFrame(frame: XRFrame): void;
  78160. /**
  78161. * avoiding using Array.find for global support.
  78162. * @param xrAnchor the plane to find in the array
  78163. */
  78164. private _findIndexInAnchorArray;
  78165. private _updateAnchorWithXRFrame;
  78166. private _createAnchorAtTransformation;
  78167. }
  78168. }
  78169. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78170. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78171. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78172. import { Observable } from "babylonjs/Misc/observable";
  78173. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78174. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78175. /**
  78176. * Options used in the plane detector module
  78177. */
  78178. export interface IWebXRPlaneDetectorOptions {
  78179. /**
  78180. * The node to use to transform the local results to world coordinates
  78181. */
  78182. worldParentNode?: TransformNode;
  78183. /**
  78184. * If set to true a reference of the created planes will be kept until the next session starts
  78185. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78186. */
  78187. doNotRemovePlanesOnSessionEnded?: boolean;
  78188. }
  78189. /**
  78190. * A babylon interface for a WebXR plane.
  78191. * A Plane is actually a polygon, built from N points in space
  78192. *
  78193. * Supported in chrome 79, not supported in canary 81 ATM
  78194. */
  78195. export interface IWebXRPlane {
  78196. /**
  78197. * a babylon-assigned ID for this polygon
  78198. */
  78199. id: number;
  78200. /**
  78201. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78202. */
  78203. polygonDefinition: Array<Vector3>;
  78204. /**
  78205. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78206. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78207. */
  78208. transformationMatrix: Matrix;
  78209. /**
  78210. * the native xr-plane object
  78211. */
  78212. xrPlane: XRPlane;
  78213. }
  78214. /**
  78215. * The plane detector is used to detect planes in the real world when in AR
  78216. * For more information see https://github.com/immersive-web/real-world-geometry/
  78217. */
  78218. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78219. private _options;
  78220. private _detectedPlanes;
  78221. private _enabled;
  78222. private _lastFrameDetected;
  78223. /**
  78224. * The module's name
  78225. */
  78226. static readonly Name: string;
  78227. /**
  78228. * The (Babylon) version of this module.
  78229. * This is an integer representing the implementation version.
  78230. * This number does not correspond to the WebXR specs version
  78231. */
  78232. static readonly Version: number;
  78233. /**
  78234. * Observers registered here will be executed when a new plane was added to the session
  78235. */
  78236. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78237. /**
  78238. * Observers registered here will be executed when a plane is no longer detected in the session
  78239. */
  78240. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78241. /**
  78242. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78243. * This can execute N times every frame
  78244. */
  78245. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78246. /**
  78247. * construct a new Plane Detector
  78248. * @param _xrSessionManager an instance of xr Session manager
  78249. * @param _options configuration to use when constructing this feature
  78250. */
  78251. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78252. /**
  78253. * detach this feature.
  78254. * Will usually be called by the features manager
  78255. *
  78256. * @returns true if successful.
  78257. */
  78258. detach(): boolean;
  78259. /**
  78260. * Dispose this feature and all of the resources attached
  78261. */
  78262. dispose(): void;
  78263. protected _onXRFrame(frame: XRFrame): void;
  78264. private _init;
  78265. private _updatePlaneWithXRPlane;
  78266. /**
  78267. * avoiding using Array.find for global support.
  78268. * @param xrPlane the plane to find in the array
  78269. */
  78270. private findIndexInPlaneArray;
  78271. }
  78272. }
  78273. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78274. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78276. import { Observable } from "babylonjs/Misc/observable";
  78277. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78278. /**
  78279. * Options interface for the background remover plugin
  78280. */
  78281. export interface IWebXRBackgroundRemoverOptions {
  78282. /**
  78283. * Further background meshes to disable when entering AR
  78284. */
  78285. backgroundMeshes?: AbstractMesh[];
  78286. /**
  78287. * flags to configure the removal of the environment helper.
  78288. * If not set, the entire background will be removed. If set, flags should be set as well.
  78289. */
  78290. environmentHelperRemovalFlags?: {
  78291. /**
  78292. * Should the skybox be removed (default false)
  78293. */
  78294. skyBox?: boolean;
  78295. /**
  78296. * Should the ground be removed (default false)
  78297. */
  78298. ground?: boolean;
  78299. };
  78300. /**
  78301. * don't disable the environment helper
  78302. */
  78303. ignoreEnvironmentHelper?: boolean;
  78304. }
  78305. /**
  78306. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78307. */
  78308. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78309. /**
  78310. * read-only options to be used in this module
  78311. */
  78312. readonly options: IWebXRBackgroundRemoverOptions;
  78313. /**
  78314. * The module's name
  78315. */
  78316. static readonly Name: string;
  78317. /**
  78318. * The (Babylon) version of this module.
  78319. * This is an integer representing the implementation version.
  78320. * This number does not correspond to the WebXR specs version
  78321. */
  78322. static readonly Version: number;
  78323. /**
  78324. * registered observers will be triggered when the background state changes
  78325. */
  78326. onBackgroundStateChangedObservable: Observable<boolean>;
  78327. /**
  78328. * constructs a new background remover module
  78329. * @param _xrSessionManager the session manager for this module
  78330. * @param options read-only options to be used in this module
  78331. */
  78332. constructor(_xrSessionManager: WebXRSessionManager,
  78333. /**
  78334. * read-only options to be used in this module
  78335. */
  78336. options?: IWebXRBackgroundRemoverOptions);
  78337. /**
  78338. * attach this feature
  78339. * Will usually be called by the features manager
  78340. *
  78341. * @returns true if successful.
  78342. */
  78343. attach(): boolean;
  78344. /**
  78345. * detach this feature.
  78346. * Will usually be called by the features manager
  78347. *
  78348. * @returns true if successful.
  78349. */
  78350. detach(): boolean;
  78351. /**
  78352. * Dispose this feature and all of the resources attached
  78353. */
  78354. dispose(): void;
  78355. protected _onXRFrame(_xrFrame: XRFrame): void;
  78356. private _setBackgroundState;
  78357. }
  78358. }
  78359. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78360. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78361. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78362. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78363. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78364. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78365. import { Nullable } from "babylonjs/types";
  78366. /**
  78367. * Options for the controller physics feature
  78368. */
  78369. export class IWebXRControllerPhysicsOptions {
  78370. /**
  78371. * Should the headset get its own impostor
  78372. */
  78373. enableHeadsetImpostor?: boolean;
  78374. /**
  78375. * Optional parameters for the headset impostor
  78376. */
  78377. headsetImpostorParams?: {
  78378. /**
  78379. * The type of impostor to create. Default is sphere
  78380. */
  78381. impostorType: number;
  78382. /**
  78383. * the size of the impostor. Defaults to 10cm
  78384. */
  78385. impostorSize?: number | {
  78386. width: number;
  78387. height: number;
  78388. depth: number;
  78389. };
  78390. /**
  78391. * Friction definitions
  78392. */
  78393. friction?: number;
  78394. /**
  78395. * Restitution
  78396. */
  78397. restitution?: number;
  78398. };
  78399. /**
  78400. * The physics properties of the future impostors
  78401. */
  78402. physicsProperties?: {
  78403. /**
  78404. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78405. * Note that this requires a physics engine that supports mesh impostors!
  78406. */
  78407. useControllerMesh?: boolean;
  78408. /**
  78409. * The type of impostor to create. Default is sphere
  78410. */
  78411. impostorType?: number;
  78412. /**
  78413. * the size of the impostor. Defaults to 10cm
  78414. */
  78415. impostorSize?: number | {
  78416. width: number;
  78417. height: number;
  78418. depth: number;
  78419. };
  78420. /**
  78421. * Friction definitions
  78422. */
  78423. friction?: number;
  78424. /**
  78425. * Restitution
  78426. */
  78427. restitution?: number;
  78428. };
  78429. /**
  78430. * the xr input to use with this pointer selection
  78431. */
  78432. xrInput: WebXRInput;
  78433. }
  78434. /**
  78435. * Add physics impostor to your webxr controllers,
  78436. * including naive calculation of their linear and angular velocity
  78437. */
  78438. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78439. private readonly _options;
  78440. private _attachController;
  78441. private _controllers;
  78442. private _debugMode;
  78443. private _delta;
  78444. private _headsetImpostor?;
  78445. private _headsetMesh?;
  78446. private _lastTimestamp;
  78447. private _tmpQuaternion;
  78448. private _tmpVector;
  78449. /**
  78450. * The module's name
  78451. */
  78452. static readonly Name: string;
  78453. /**
  78454. * The (Babylon) version of this module.
  78455. * This is an integer representing the implementation version.
  78456. * This number does not correspond to the webxr specs version
  78457. */
  78458. static readonly Version: number;
  78459. /**
  78460. * Construct a new Controller Physics Feature
  78461. * @param _xrSessionManager the corresponding xr session manager
  78462. * @param _options options to create this feature with
  78463. */
  78464. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78465. /**
  78466. * @hidden
  78467. * enable debugging - will show console outputs and the impostor mesh
  78468. */
  78469. _enablePhysicsDebug(): void;
  78470. /**
  78471. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78472. * @param xrController the controller to add
  78473. */
  78474. addController(xrController: WebXRInputSource): void;
  78475. /**
  78476. * attach this feature
  78477. * Will usually be called by the features manager
  78478. *
  78479. * @returns true if successful.
  78480. */
  78481. attach(): boolean;
  78482. /**
  78483. * detach this feature.
  78484. * Will usually be called by the features manager
  78485. *
  78486. * @returns true if successful.
  78487. */
  78488. detach(): boolean;
  78489. /**
  78490. * Get the headset impostor, if enabled
  78491. * @returns the impostor
  78492. */
  78493. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78494. /**
  78495. * Get the physics impostor of a specific controller.
  78496. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78497. * @param controller the controller or the controller id of which to get the impostor
  78498. * @returns the impostor or null
  78499. */
  78500. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78501. /**
  78502. * Update the physics properties provided in the constructor
  78503. * @param newProperties the new properties object
  78504. */
  78505. setPhysicsProperties(newProperties: {
  78506. impostorType?: number;
  78507. impostorSize?: number | {
  78508. width: number;
  78509. height: number;
  78510. depth: number;
  78511. };
  78512. friction?: number;
  78513. restitution?: number;
  78514. }): void;
  78515. protected _onXRFrame(_xrFrame: any): void;
  78516. private _detachController;
  78517. }
  78518. }
  78519. declare module "babylonjs/XR/features/index" {
  78520. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78521. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78522. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78523. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78524. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78525. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78526. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78527. export * from "babylonjs/XR/features/WebXRHitTest";
  78528. }
  78529. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78530. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78532. import { Scene } from "babylonjs/scene";
  78533. /**
  78534. * The motion controller class for all microsoft mixed reality controllers
  78535. */
  78536. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78537. protected readonly _mapping: {
  78538. defaultButton: {
  78539. valueNodeName: string;
  78540. unpressedNodeName: string;
  78541. pressedNodeName: string;
  78542. };
  78543. defaultAxis: {
  78544. valueNodeName: string;
  78545. minNodeName: string;
  78546. maxNodeName: string;
  78547. };
  78548. buttons: {
  78549. "xr-standard-trigger": {
  78550. rootNodeName: string;
  78551. componentProperty: string;
  78552. states: string[];
  78553. };
  78554. "xr-standard-squeeze": {
  78555. rootNodeName: string;
  78556. componentProperty: string;
  78557. states: string[];
  78558. };
  78559. "xr-standard-touchpad": {
  78560. rootNodeName: string;
  78561. labelAnchorNodeName: string;
  78562. touchPointNodeName: string;
  78563. };
  78564. "xr-standard-thumbstick": {
  78565. rootNodeName: string;
  78566. componentProperty: string;
  78567. states: string[];
  78568. };
  78569. };
  78570. axes: {
  78571. "xr-standard-touchpad": {
  78572. "x-axis": {
  78573. rootNodeName: string;
  78574. };
  78575. "y-axis": {
  78576. rootNodeName: string;
  78577. };
  78578. };
  78579. "xr-standard-thumbstick": {
  78580. "x-axis": {
  78581. rootNodeName: string;
  78582. };
  78583. "y-axis": {
  78584. rootNodeName: string;
  78585. };
  78586. };
  78587. };
  78588. };
  78589. /**
  78590. * The base url used to load the left and right controller models
  78591. */
  78592. static MODEL_BASE_URL: string;
  78593. /**
  78594. * The name of the left controller model file
  78595. */
  78596. static MODEL_LEFT_FILENAME: string;
  78597. /**
  78598. * The name of the right controller model file
  78599. */
  78600. static MODEL_RIGHT_FILENAME: string;
  78601. profileId: string;
  78602. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78603. protected _getFilenameAndPath(): {
  78604. filename: string;
  78605. path: string;
  78606. };
  78607. protected _getModelLoadingConstraints(): boolean;
  78608. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78609. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78610. protected _updateModel(): void;
  78611. }
  78612. }
  78613. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78614. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78616. import { Scene } from "babylonjs/scene";
  78617. /**
  78618. * The motion controller class for oculus touch (quest, rift).
  78619. * This class supports legacy mapping as well the standard xr mapping
  78620. */
  78621. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78622. private _forceLegacyControllers;
  78623. private _modelRootNode;
  78624. /**
  78625. * The base url used to load the left and right controller models
  78626. */
  78627. static MODEL_BASE_URL: string;
  78628. /**
  78629. * The name of the left controller model file
  78630. */
  78631. static MODEL_LEFT_FILENAME: string;
  78632. /**
  78633. * The name of the right controller model file
  78634. */
  78635. static MODEL_RIGHT_FILENAME: string;
  78636. /**
  78637. * Base Url for the Quest controller model.
  78638. */
  78639. static QUEST_MODEL_BASE_URL: string;
  78640. profileId: string;
  78641. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78642. protected _getFilenameAndPath(): {
  78643. filename: string;
  78644. path: string;
  78645. };
  78646. protected _getModelLoadingConstraints(): boolean;
  78647. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78648. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78649. protected _updateModel(): void;
  78650. /**
  78651. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78652. * between the touch and touch 2.
  78653. */
  78654. private _isQuest;
  78655. }
  78656. }
  78657. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78658. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78659. import { Scene } from "babylonjs/scene";
  78660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78661. /**
  78662. * The motion controller class for the standard HTC-Vive controllers
  78663. */
  78664. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78665. private _modelRootNode;
  78666. /**
  78667. * The base url used to load the left and right controller models
  78668. */
  78669. static MODEL_BASE_URL: string;
  78670. /**
  78671. * File name for the controller model.
  78672. */
  78673. static MODEL_FILENAME: string;
  78674. profileId: string;
  78675. /**
  78676. * Create a new Vive motion controller object
  78677. * @param scene the scene to use to create this controller
  78678. * @param gamepadObject the corresponding gamepad object
  78679. * @param handedness the handedness of the controller
  78680. */
  78681. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78682. protected _getFilenameAndPath(): {
  78683. filename: string;
  78684. path: string;
  78685. };
  78686. protected _getModelLoadingConstraints(): boolean;
  78687. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78688. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78689. protected _updateModel(): void;
  78690. }
  78691. }
  78692. declare module "babylonjs/XR/motionController/index" {
  78693. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78694. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78695. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78696. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78697. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78698. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78699. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78700. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78701. }
  78702. declare module "babylonjs/XR/index" {
  78703. export * from "babylonjs/XR/webXRCamera";
  78704. export * from "babylonjs/XR/webXREnterExitUI";
  78705. export * from "babylonjs/XR/webXRExperienceHelper";
  78706. export * from "babylonjs/XR/webXRInput";
  78707. export * from "babylonjs/XR/webXRInputSource";
  78708. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78709. export * from "babylonjs/XR/webXRTypes";
  78710. export * from "babylonjs/XR/webXRSessionManager";
  78711. export * from "babylonjs/XR/webXRDefaultExperience";
  78712. export * from "babylonjs/XR/webXRFeaturesManager";
  78713. export * from "babylonjs/XR/features/index";
  78714. export * from "babylonjs/XR/motionController/index";
  78715. }
  78716. declare module "babylonjs/index" {
  78717. export * from "babylonjs/abstractScene";
  78718. export * from "babylonjs/Actions/index";
  78719. export * from "babylonjs/Animations/index";
  78720. export * from "babylonjs/assetContainer";
  78721. export * from "babylonjs/Audio/index";
  78722. export * from "babylonjs/Behaviors/index";
  78723. export * from "babylonjs/Bones/index";
  78724. export * from "babylonjs/Cameras/index";
  78725. export * from "babylonjs/Collisions/index";
  78726. export * from "babylonjs/Culling/index";
  78727. export * from "babylonjs/Debug/index";
  78728. export * from "babylonjs/DeviceInput/index";
  78729. export * from "babylonjs/Engines/index";
  78730. export * from "babylonjs/Events/index";
  78731. export * from "babylonjs/Gamepads/index";
  78732. export * from "babylonjs/Gizmos/index";
  78733. export * from "babylonjs/Helpers/index";
  78734. export * from "babylonjs/Instrumentation/index";
  78735. export * from "babylonjs/Layers/index";
  78736. export * from "babylonjs/LensFlares/index";
  78737. export * from "babylonjs/Lights/index";
  78738. export * from "babylonjs/Loading/index";
  78739. export * from "babylonjs/Materials/index";
  78740. export * from "babylonjs/Maths/index";
  78741. export * from "babylonjs/Meshes/index";
  78742. export * from "babylonjs/Morph/index";
  78743. export * from "babylonjs/Navigation/index";
  78744. export * from "babylonjs/node";
  78745. export * from "babylonjs/Offline/index";
  78746. export * from "babylonjs/Particles/index";
  78747. export * from "babylonjs/Physics/index";
  78748. export * from "babylonjs/PostProcesses/index";
  78749. export * from "babylonjs/Probes/index";
  78750. export * from "babylonjs/Rendering/index";
  78751. export * from "babylonjs/scene";
  78752. export * from "babylonjs/sceneComponent";
  78753. export * from "babylonjs/Sprites/index";
  78754. export * from "babylonjs/States/index";
  78755. export * from "babylonjs/Misc/index";
  78756. export * from "babylonjs/XR/index";
  78757. export * from "babylonjs/types";
  78758. }
  78759. declare module "babylonjs/Animations/pathCursor" {
  78760. import { Vector3 } from "babylonjs/Maths/math.vector";
  78761. import { Path2 } from "babylonjs/Maths/math.path";
  78762. /**
  78763. * A cursor which tracks a point on a path
  78764. */
  78765. export class PathCursor {
  78766. private path;
  78767. /**
  78768. * Stores path cursor callbacks for when an onchange event is triggered
  78769. */
  78770. private _onchange;
  78771. /**
  78772. * The value of the path cursor
  78773. */
  78774. value: number;
  78775. /**
  78776. * The animation array of the path cursor
  78777. */
  78778. animations: Animation[];
  78779. /**
  78780. * Initializes the path cursor
  78781. * @param path The path to track
  78782. */
  78783. constructor(path: Path2);
  78784. /**
  78785. * Gets the cursor point on the path
  78786. * @returns A point on the path cursor at the cursor location
  78787. */
  78788. getPoint(): Vector3;
  78789. /**
  78790. * Moves the cursor ahead by the step amount
  78791. * @param step The amount to move the cursor forward
  78792. * @returns This path cursor
  78793. */
  78794. moveAhead(step?: number): PathCursor;
  78795. /**
  78796. * Moves the cursor behind by the step amount
  78797. * @param step The amount to move the cursor back
  78798. * @returns This path cursor
  78799. */
  78800. moveBack(step?: number): PathCursor;
  78801. /**
  78802. * Moves the cursor by the step amount
  78803. * If the step amount is greater than one, an exception is thrown
  78804. * @param step The amount to move the cursor
  78805. * @returns This path cursor
  78806. */
  78807. move(step: number): PathCursor;
  78808. /**
  78809. * Ensures that the value is limited between zero and one
  78810. * @returns This path cursor
  78811. */
  78812. private ensureLimits;
  78813. /**
  78814. * Runs onchange callbacks on change (used by the animation engine)
  78815. * @returns This path cursor
  78816. */
  78817. private raiseOnChange;
  78818. /**
  78819. * Executes a function on change
  78820. * @param f A path cursor onchange callback
  78821. * @returns This path cursor
  78822. */
  78823. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78824. }
  78825. }
  78826. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78827. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78828. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78829. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78830. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78831. }
  78832. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78833. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78834. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78835. }
  78836. declare module "babylonjs/Engines/Processors/index" {
  78837. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78838. export * from "babylonjs/Engines/Processors/Expressions/index";
  78839. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78840. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78841. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78842. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78843. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78844. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78845. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78846. }
  78847. declare module "babylonjs/Legacy/legacy" {
  78848. import * as Babylon from "babylonjs/index";
  78849. export * from "babylonjs/index";
  78850. }
  78851. declare module "babylonjs/Shaders/blur.fragment" {
  78852. /** @hidden */
  78853. export var blurPixelShader: {
  78854. name: string;
  78855. shader: string;
  78856. };
  78857. }
  78858. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78859. /** @hidden */
  78860. export var pointCloudVertexDeclaration: {
  78861. name: string;
  78862. shader: string;
  78863. };
  78864. }
  78865. declare module "babylonjs" {
  78866. export * from "babylonjs/Legacy/legacy";
  78867. }
  78868. declare module BABYLON {
  78869. /** Alias type for value that can be null */
  78870. export type Nullable<T> = T | null;
  78871. /**
  78872. * Alias type for number that are floats
  78873. * @ignorenaming
  78874. */
  78875. export type float = number;
  78876. /**
  78877. * Alias type for number that are doubles.
  78878. * @ignorenaming
  78879. */
  78880. export type double = number;
  78881. /**
  78882. * Alias type for number that are integer
  78883. * @ignorenaming
  78884. */
  78885. export type int = number;
  78886. /** Alias type for number array or Float32Array */
  78887. export type FloatArray = number[] | Float32Array;
  78888. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78889. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78890. /**
  78891. * Alias for types that can be used by a Buffer or VertexBuffer.
  78892. */
  78893. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78894. /**
  78895. * Alias type for primitive types
  78896. * @ignorenaming
  78897. */
  78898. type Primitive = undefined | null | boolean | string | number | Function;
  78899. /**
  78900. * Type modifier to make all the properties of an object Readonly
  78901. */
  78902. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78903. /**
  78904. * Type modifier to make all the properties of an object Readonly recursively
  78905. */
  78906. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78907. /**
  78908. * Type modifier to make object properties readonly.
  78909. */
  78910. export type DeepImmutableObject<T> = {
  78911. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78912. };
  78913. /** @hidden */
  78914. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78915. }
  78916. }
  78917. declare module BABYLON {
  78918. /**
  78919. * A class serves as a medium between the observable and its observers
  78920. */
  78921. export class EventState {
  78922. /**
  78923. * Create a new EventState
  78924. * @param mask defines the mask associated with this state
  78925. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78926. * @param target defines the original target of the state
  78927. * @param currentTarget defines the current target of the state
  78928. */
  78929. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78930. /**
  78931. * Initialize the current event state
  78932. * @param mask defines the mask associated with this state
  78933. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78934. * @param target defines the original target of the state
  78935. * @param currentTarget defines the current target of the state
  78936. * @returns the current event state
  78937. */
  78938. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78939. /**
  78940. * An Observer can set this property to true to prevent subsequent observers of being notified
  78941. */
  78942. skipNextObservers: boolean;
  78943. /**
  78944. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78945. */
  78946. mask: number;
  78947. /**
  78948. * The object that originally notified the event
  78949. */
  78950. target?: any;
  78951. /**
  78952. * The current object in the bubbling phase
  78953. */
  78954. currentTarget?: any;
  78955. /**
  78956. * This will be populated with the return value of the last function that was executed.
  78957. * If it is the first function in the callback chain it will be the event data.
  78958. */
  78959. lastReturnValue?: any;
  78960. }
  78961. /**
  78962. * Represent an Observer registered to a given Observable object.
  78963. */
  78964. export class Observer<T> {
  78965. /**
  78966. * Defines the callback to call when the observer is notified
  78967. */
  78968. callback: (eventData: T, eventState: EventState) => void;
  78969. /**
  78970. * Defines the mask of the observer (used to filter notifications)
  78971. */
  78972. mask: number;
  78973. /**
  78974. * Defines the current scope used to restore the JS context
  78975. */
  78976. scope: any;
  78977. /** @hidden */
  78978. _willBeUnregistered: boolean;
  78979. /**
  78980. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78981. */
  78982. unregisterOnNextCall: boolean;
  78983. /**
  78984. * Creates a new observer
  78985. * @param callback defines the callback to call when the observer is notified
  78986. * @param mask defines the mask of the observer (used to filter notifications)
  78987. * @param scope defines the current scope used to restore the JS context
  78988. */
  78989. constructor(
  78990. /**
  78991. * Defines the callback to call when the observer is notified
  78992. */
  78993. callback: (eventData: T, eventState: EventState) => void,
  78994. /**
  78995. * Defines the mask of the observer (used to filter notifications)
  78996. */
  78997. mask: number,
  78998. /**
  78999. * Defines the current scope used to restore the JS context
  79000. */
  79001. scope?: any);
  79002. }
  79003. /**
  79004. * Represent a list of observers registered to multiple Observables object.
  79005. */
  79006. export class MultiObserver<T> {
  79007. private _observers;
  79008. private _observables;
  79009. /**
  79010. * Release associated resources
  79011. */
  79012. dispose(): void;
  79013. /**
  79014. * Raise a callback when one of the observable will notify
  79015. * @param observables defines a list of observables to watch
  79016. * @param callback defines the callback to call on notification
  79017. * @param mask defines the mask used to filter notifications
  79018. * @param scope defines the current scope used to restore the JS context
  79019. * @returns the new MultiObserver
  79020. */
  79021. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79022. }
  79023. /**
  79024. * The Observable class is a simple implementation of the Observable pattern.
  79025. *
  79026. * 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.
  79027. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79028. * 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).
  79029. * 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.
  79030. */
  79031. export class Observable<T> {
  79032. private _observers;
  79033. private _eventState;
  79034. private _onObserverAdded;
  79035. /**
  79036. * Gets the list of observers
  79037. */
  79038. get observers(): Array<Observer<T>>;
  79039. /**
  79040. * Creates a new observable
  79041. * @param onObserverAdded defines a callback to call when a new observer is added
  79042. */
  79043. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79044. /**
  79045. * Create a new Observer with the specified callback
  79046. * @param callback the callback that will be executed for that Observer
  79047. * @param mask the mask used to filter observers
  79048. * @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.
  79049. * @param scope optional scope for the callback to be called from
  79050. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79051. * @returns the new observer created for the callback
  79052. */
  79053. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79054. /**
  79055. * Create a new Observer with the specified callback and unregisters after the next notification
  79056. * @param callback the callback that will be executed for that Observer
  79057. * @returns the new observer created for the callback
  79058. */
  79059. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79060. /**
  79061. * Remove an Observer from the Observable object
  79062. * @param observer the instance of the Observer to remove
  79063. * @returns false if it doesn't belong to this Observable
  79064. */
  79065. remove(observer: Nullable<Observer<T>>): boolean;
  79066. /**
  79067. * Remove a callback from the Observable object
  79068. * @param callback the callback to remove
  79069. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79070. * @returns false if it doesn't belong to this Observable
  79071. */
  79072. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79073. private _deferUnregister;
  79074. private _remove;
  79075. /**
  79076. * Moves the observable to the top of the observer list making it get called first when notified
  79077. * @param observer the observer to move
  79078. */
  79079. makeObserverTopPriority(observer: Observer<T>): void;
  79080. /**
  79081. * Moves the observable to the bottom of the observer list making it get called last when notified
  79082. * @param observer the observer to move
  79083. */
  79084. makeObserverBottomPriority(observer: Observer<T>): void;
  79085. /**
  79086. * Notify all Observers by calling their respective callback with the given data
  79087. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79088. * @param eventData defines the data to send to all observers
  79089. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79090. * @param target defines the original target of the state
  79091. * @param currentTarget defines the current target of the state
  79092. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79093. */
  79094. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79095. /**
  79096. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79097. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79098. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79099. * and it is crucial that all callbacks will be executed.
  79100. * The order of the callbacks is kept, callbacks are not executed parallel.
  79101. *
  79102. * @param eventData The data to be sent to each callback
  79103. * @param mask is used to filter observers defaults to -1
  79104. * @param target defines the callback target (see EventState)
  79105. * @param currentTarget defines he current object in the bubbling phase
  79106. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79107. */
  79108. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79109. /**
  79110. * Notify a specific observer
  79111. * @param observer defines the observer to notify
  79112. * @param eventData defines the data to be sent to each callback
  79113. * @param mask is used to filter observers defaults to -1
  79114. */
  79115. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79116. /**
  79117. * Gets a boolean indicating if the observable has at least one observer
  79118. * @returns true is the Observable has at least one Observer registered
  79119. */
  79120. hasObservers(): boolean;
  79121. /**
  79122. * Clear the list of observers
  79123. */
  79124. clear(): void;
  79125. /**
  79126. * Clone the current observable
  79127. * @returns a new observable
  79128. */
  79129. clone(): Observable<T>;
  79130. /**
  79131. * Does this observable handles observer registered with a given mask
  79132. * @param mask defines the mask to be tested
  79133. * @return whether or not one observer registered with the given mask is handeled
  79134. **/
  79135. hasSpecificMask(mask?: number): boolean;
  79136. }
  79137. }
  79138. declare module BABYLON {
  79139. /**
  79140. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79141. * Babylon.js
  79142. */
  79143. export class DomManagement {
  79144. /**
  79145. * Checks if the window object exists
  79146. * @returns true if the window object exists
  79147. */
  79148. static IsWindowObjectExist(): boolean;
  79149. /**
  79150. * Checks if the navigator object exists
  79151. * @returns true if the navigator object exists
  79152. */
  79153. static IsNavigatorAvailable(): boolean;
  79154. /**
  79155. * Check if the document object exists
  79156. * @returns true if the document object exists
  79157. */
  79158. static IsDocumentAvailable(): boolean;
  79159. /**
  79160. * Extracts text content from a DOM element hierarchy
  79161. * @param element defines the root element
  79162. * @returns a string
  79163. */
  79164. static GetDOMTextContent(element: HTMLElement): string;
  79165. }
  79166. }
  79167. declare module BABYLON {
  79168. /**
  79169. * Logger used througouht the application to allow configuration of
  79170. * the log level required for the messages.
  79171. */
  79172. export class Logger {
  79173. /**
  79174. * No log
  79175. */
  79176. static readonly NoneLogLevel: number;
  79177. /**
  79178. * Only message logs
  79179. */
  79180. static readonly MessageLogLevel: number;
  79181. /**
  79182. * Only warning logs
  79183. */
  79184. static readonly WarningLogLevel: number;
  79185. /**
  79186. * Only error logs
  79187. */
  79188. static readonly ErrorLogLevel: number;
  79189. /**
  79190. * All logs
  79191. */
  79192. static readonly AllLogLevel: number;
  79193. private static _LogCache;
  79194. /**
  79195. * Gets a value indicating the number of loading errors
  79196. * @ignorenaming
  79197. */
  79198. static errorsCount: number;
  79199. /**
  79200. * Callback called when a new log is added
  79201. */
  79202. static OnNewCacheEntry: (entry: string) => void;
  79203. private static _AddLogEntry;
  79204. private static _FormatMessage;
  79205. private static _LogDisabled;
  79206. private static _LogEnabled;
  79207. private static _WarnDisabled;
  79208. private static _WarnEnabled;
  79209. private static _ErrorDisabled;
  79210. private static _ErrorEnabled;
  79211. /**
  79212. * Log a message to the console
  79213. */
  79214. static Log: (message: string) => void;
  79215. /**
  79216. * Write a warning message to the console
  79217. */
  79218. static Warn: (message: string) => void;
  79219. /**
  79220. * Write an error message to the console
  79221. */
  79222. static Error: (message: string) => void;
  79223. /**
  79224. * Gets current log cache (list of logs)
  79225. */
  79226. static get LogCache(): string;
  79227. /**
  79228. * Clears the log cache
  79229. */
  79230. static ClearLogCache(): void;
  79231. /**
  79232. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79233. */
  79234. static set LogLevels(level: number);
  79235. }
  79236. }
  79237. declare module BABYLON {
  79238. /** @hidden */
  79239. export class _TypeStore {
  79240. /** @hidden */
  79241. static RegisteredTypes: {
  79242. [key: string]: Object;
  79243. };
  79244. /** @hidden */
  79245. static GetClass(fqdn: string): any;
  79246. }
  79247. }
  79248. declare module BABYLON {
  79249. /**
  79250. * Helper to manipulate strings
  79251. */
  79252. export class StringTools {
  79253. /**
  79254. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  79255. * @param str Source string
  79256. * @param suffix Suffix to search for in the source string
  79257. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79258. */
  79259. static EndsWith(str: string, suffix: string): boolean;
  79260. /**
  79261. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  79262. * @param str Source string
  79263. * @param suffix Suffix to search for in the source string
  79264. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79265. */
  79266. static StartsWith(str: string, suffix: string): boolean;
  79267. /**
  79268. * Decodes a buffer into a string
  79269. * @param buffer The buffer to decode
  79270. * @returns The decoded string
  79271. */
  79272. static Decode(buffer: Uint8Array | Uint16Array): string;
  79273. /**
  79274. * Encode a buffer to a base64 string
  79275. * @param buffer defines the buffer to encode
  79276. * @returns the encoded string
  79277. */
  79278. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  79279. /**
  79280. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  79281. * @param num the number to convert and pad
  79282. * @param length the expected length of the string
  79283. * @returns the padded string
  79284. */
  79285. static PadNumber(num: number, length: number): string;
  79286. }
  79287. }
  79288. declare module BABYLON {
  79289. /**
  79290. * Class containing a set of static utilities functions for deep copy.
  79291. */
  79292. export class DeepCopier {
  79293. /**
  79294. * Tries to copy an object by duplicating every property
  79295. * @param source defines the source object
  79296. * @param destination defines the target object
  79297. * @param doNotCopyList defines a list of properties to avoid
  79298. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  79299. */
  79300. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  79301. }
  79302. }
  79303. declare module BABYLON {
  79304. /**
  79305. * Class containing a set of static utilities functions for precision date
  79306. */
  79307. export class PrecisionDate {
  79308. /**
  79309. * Gets either window.performance.now() if supported or Date.now() else
  79310. */
  79311. static get Now(): number;
  79312. }
  79313. }
  79314. declare module BABYLON {
  79315. /** @hidden */
  79316. export class _DevTools {
  79317. static WarnImport(name: string): string;
  79318. }
  79319. }
  79320. declare module BABYLON {
  79321. /**
  79322. * Interface used to define the mechanism to get data from the network
  79323. */
  79324. export interface IWebRequest {
  79325. /**
  79326. * Returns client's response url
  79327. */
  79328. responseURL: string;
  79329. /**
  79330. * Returns client's status
  79331. */
  79332. status: number;
  79333. /**
  79334. * Returns client's status as a text
  79335. */
  79336. statusText: string;
  79337. }
  79338. }
  79339. declare module BABYLON {
  79340. /**
  79341. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79342. */
  79343. export class WebRequest implements IWebRequest {
  79344. private _xhr;
  79345. /**
  79346. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79347. * i.e. when loading files, where the server/service expects an Authorization header
  79348. */
  79349. static CustomRequestHeaders: {
  79350. [key: string]: string;
  79351. };
  79352. /**
  79353. * Add callback functions in this array to update all the requests before they get sent to the network
  79354. */
  79355. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79356. private _injectCustomRequestHeaders;
  79357. /**
  79358. * Gets or sets a function to be called when loading progress changes
  79359. */
  79360. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79361. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79362. /**
  79363. * Returns client's state
  79364. */
  79365. get readyState(): number;
  79366. /**
  79367. * Returns client's status
  79368. */
  79369. get status(): number;
  79370. /**
  79371. * Returns client's status as a text
  79372. */
  79373. get statusText(): string;
  79374. /**
  79375. * Returns client's response
  79376. */
  79377. get response(): any;
  79378. /**
  79379. * Returns client's response url
  79380. */
  79381. get responseURL(): string;
  79382. /**
  79383. * Returns client's response as text
  79384. */
  79385. get responseText(): string;
  79386. /**
  79387. * Gets or sets the expected response type
  79388. */
  79389. get responseType(): XMLHttpRequestResponseType;
  79390. set responseType(value: XMLHttpRequestResponseType);
  79391. /** @hidden */
  79392. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79393. /** @hidden */
  79394. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79395. /**
  79396. * Cancels any network activity
  79397. */
  79398. abort(): void;
  79399. /**
  79400. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79401. * @param body defines an optional request body
  79402. */
  79403. send(body?: Document | BodyInit | null): void;
  79404. /**
  79405. * Sets the request method, request URL
  79406. * @param method defines the method to use (GET, POST, etc..)
  79407. * @param url defines the url to connect with
  79408. */
  79409. open(method: string, url: string): void;
  79410. /**
  79411. * Sets the value of a request header.
  79412. * @param name The name of the header whose value is to be set
  79413. * @param value The value to set as the body of the header
  79414. */
  79415. setRequestHeader(name: string, value: string): void;
  79416. /**
  79417. * Get the string containing the text of a particular header's value.
  79418. * @param name The name of the header
  79419. * @returns The string containing the text of the given header name
  79420. */
  79421. getResponseHeader(name: string): Nullable<string>;
  79422. }
  79423. }
  79424. declare module BABYLON {
  79425. /**
  79426. * File request interface
  79427. */
  79428. export interface IFileRequest {
  79429. /**
  79430. * Raised when the request is complete (success or error).
  79431. */
  79432. onCompleteObservable: Observable<IFileRequest>;
  79433. /**
  79434. * Aborts the request for a file.
  79435. */
  79436. abort: () => void;
  79437. }
  79438. }
  79439. declare module BABYLON {
  79440. /**
  79441. * Define options used to create a render target texture
  79442. */
  79443. export class RenderTargetCreationOptions {
  79444. /**
  79445. * Specifies is mipmaps must be generated
  79446. */
  79447. generateMipMaps?: boolean;
  79448. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79449. generateDepthBuffer?: boolean;
  79450. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79451. generateStencilBuffer?: boolean;
  79452. /** Defines texture type (int by default) */
  79453. type?: number;
  79454. /** Defines sampling mode (trilinear by default) */
  79455. samplingMode?: number;
  79456. /** Defines format (RGBA by default) */
  79457. format?: number;
  79458. }
  79459. }
  79460. declare module BABYLON {
  79461. /** Defines the cross module used constants to avoid circular dependncies */
  79462. export class Constants {
  79463. /** Defines that alpha blending is disabled */
  79464. static readonly ALPHA_DISABLE: number;
  79465. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79466. static readonly ALPHA_ADD: number;
  79467. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79468. static readonly ALPHA_COMBINE: number;
  79469. /** Defines that alpha blending is DEST - SRC * DEST */
  79470. static readonly ALPHA_SUBTRACT: number;
  79471. /** Defines that alpha blending is SRC * DEST */
  79472. static readonly ALPHA_MULTIPLY: number;
  79473. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79474. static readonly ALPHA_MAXIMIZED: number;
  79475. /** Defines that alpha blending is SRC + DEST */
  79476. static readonly ALPHA_ONEONE: number;
  79477. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79478. static readonly ALPHA_PREMULTIPLIED: number;
  79479. /**
  79480. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79481. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79482. */
  79483. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79484. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79485. static readonly ALPHA_INTERPOLATE: number;
  79486. /**
  79487. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79488. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79489. */
  79490. static readonly ALPHA_SCREENMODE: number;
  79491. /**
  79492. * Defines that alpha blending is SRC + DST
  79493. * Alpha will be set to SRC ALPHA + DST ALPHA
  79494. */
  79495. static readonly ALPHA_ONEONE_ONEONE: number;
  79496. /**
  79497. * Defines that alpha blending is SRC * DST ALPHA + DST
  79498. * Alpha will be set to 0
  79499. */
  79500. static readonly ALPHA_ALPHATOCOLOR: number;
  79501. /**
  79502. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79503. */
  79504. static readonly ALPHA_REVERSEONEMINUS: number;
  79505. /**
  79506. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79507. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79508. */
  79509. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79510. /**
  79511. * Defines that alpha blending is SRC + DST
  79512. * Alpha will be set to SRC ALPHA
  79513. */
  79514. static readonly ALPHA_ONEONE_ONEZERO: number;
  79515. /**
  79516. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79517. * Alpha will be set to DST ALPHA
  79518. */
  79519. static readonly ALPHA_EXCLUSION: number;
  79520. /** Defines that alpha blending equation a SUM */
  79521. static readonly ALPHA_EQUATION_ADD: number;
  79522. /** Defines that alpha blending equation a SUBSTRACTION */
  79523. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79524. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79525. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79526. /** Defines that alpha blending equation a MAX operation */
  79527. static readonly ALPHA_EQUATION_MAX: number;
  79528. /** Defines that alpha blending equation a MIN operation */
  79529. static readonly ALPHA_EQUATION_MIN: number;
  79530. /**
  79531. * Defines that alpha blending equation a DARKEN operation:
  79532. * It takes the min of the src and sums the alpha channels.
  79533. */
  79534. static readonly ALPHA_EQUATION_DARKEN: number;
  79535. /** Defines that the ressource is not delayed*/
  79536. static readonly DELAYLOADSTATE_NONE: number;
  79537. /** Defines that the ressource was successfully delay loaded */
  79538. static readonly DELAYLOADSTATE_LOADED: number;
  79539. /** Defines that the ressource is currently delay loading */
  79540. static readonly DELAYLOADSTATE_LOADING: number;
  79541. /** Defines that the ressource is delayed and has not started loading */
  79542. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79543. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79544. static readonly NEVER: number;
  79545. /** 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 */
  79546. static readonly ALWAYS: number;
  79547. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79548. static readonly LESS: number;
  79549. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79550. static readonly EQUAL: number;
  79551. /** 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 */
  79552. static readonly LEQUAL: number;
  79553. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79554. static readonly GREATER: number;
  79555. /** 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 */
  79556. static readonly GEQUAL: number;
  79557. /** 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 */
  79558. static readonly NOTEQUAL: number;
  79559. /** Passed to stencilOperation to specify that stencil value must be kept */
  79560. static readonly KEEP: number;
  79561. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79562. static readonly REPLACE: number;
  79563. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79564. static readonly INCR: number;
  79565. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79566. static readonly DECR: number;
  79567. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79568. static readonly INVERT: number;
  79569. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79570. static readonly INCR_WRAP: number;
  79571. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79572. static readonly DECR_WRAP: number;
  79573. /** Texture is not repeating outside of 0..1 UVs */
  79574. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79575. /** Texture is repeating outside of 0..1 UVs */
  79576. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79577. /** Texture is repeating and mirrored */
  79578. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79579. /** ALPHA */
  79580. static readonly TEXTUREFORMAT_ALPHA: number;
  79581. /** LUMINANCE */
  79582. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79583. /** LUMINANCE_ALPHA */
  79584. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79585. /** RGB */
  79586. static readonly TEXTUREFORMAT_RGB: number;
  79587. /** RGBA */
  79588. static readonly TEXTUREFORMAT_RGBA: number;
  79589. /** RED */
  79590. static readonly TEXTUREFORMAT_RED: number;
  79591. /** RED (2nd reference) */
  79592. static readonly TEXTUREFORMAT_R: number;
  79593. /** RG */
  79594. static readonly TEXTUREFORMAT_RG: number;
  79595. /** RED_INTEGER */
  79596. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79597. /** RED_INTEGER (2nd reference) */
  79598. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79599. /** RG_INTEGER */
  79600. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79601. /** RGB_INTEGER */
  79602. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79603. /** RGBA_INTEGER */
  79604. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79605. /** UNSIGNED_BYTE */
  79606. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79607. /** UNSIGNED_BYTE (2nd reference) */
  79608. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79609. /** FLOAT */
  79610. static readonly TEXTURETYPE_FLOAT: number;
  79611. /** HALF_FLOAT */
  79612. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79613. /** BYTE */
  79614. static readonly TEXTURETYPE_BYTE: number;
  79615. /** SHORT */
  79616. static readonly TEXTURETYPE_SHORT: number;
  79617. /** UNSIGNED_SHORT */
  79618. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79619. /** INT */
  79620. static readonly TEXTURETYPE_INT: number;
  79621. /** UNSIGNED_INT */
  79622. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79623. /** UNSIGNED_SHORT_4_4_4_4 */
  79624. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79625. /** UNSIGNED_SHORT_5_5_5_1 */
  79626. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79627. /** UNSIGNED_SHORT_5_6_5 */
  79628. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79629. /** UNSIGNED_INT_2_10_10_10_REV */
  79630. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79631. /** UNSIGNED_INT_24_8 */
  79632. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79633. /** UNSIGNED_INT_10F_11F_11F_REV */
  79634. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79635. /** UNSIGNED_INT_5_9_9_9_REV */
  79636. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79637. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79638. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79639. /** nearest is mag = nearest and min = nearest and no mip */
  79640. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79641. /** mag = nearest and min = nearest and mip = none */
  79642. static readonly TEXTURE_NEAREST_NEAREST: number;
  79643. /** Bilinear is mag = linear and min = linear and no mip */
  79644. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79645. /** mag = linear and min = linear and mip = none */
  79646. static readonly TEXTURE_LINEAR_LINEAR: number;
  79647. /** Trilinear is mag = linear and min = linear and mip = linear */
  79648. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79649. /** Trilinear is mag = linear and min = linear and mip = linear */
  79650. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79651. /** mag = nearest and min = nearest and mip = nearest */
  79652. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79653. /** mag = nearest and min = linear and mip = nearest */
  79654. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79655. /** mag = nearest and min = linear and mip = linear */
  79656. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79657. /** mag = nearest and min = linear and mip = none */
  79658. static readonly TEXTURE_NEAREST_LINEAR: number;
  79659. /** nearest is mag = nearest and min = nearest and mip = linear */
  79660. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79661. /** mag = linear and min = nearest and mip = nearest */
  79662. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79663. /** mag = linear and min = nearest and mip = linear */
  79664. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79665. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79666. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79667. /** mag = linear and min = nearest and mip = none */
  79668. static readonly TEXTURE_LINEAR_NEAREST: number;
  79669. /** Explicit coordinates mode */
  79670. static readonly TEXTURE_EXPLICIT_MODE: number;
  79671. /** Spherical coordinates mode */
  79672. static readonly TEXTURE_SPHERICAL_MODE: number;
  79673. /** Planar coordinates mode */
  79674. static readonly TEXTURE_PLANAR_MODE: number;
  79675. /** Cubic coordinates mode */
  79676. static readonly TEXTURE_CUBIC_MODE: number;
  79677. /** Projection coordinates mode */
  79678. static readonly TEXTURE_PROJECTION_MODE: number;
  79679. /** Skybox coordinates mode */
  79680. static readonly TEXTURE_SKYBOX_MODE: number;
  79681. /** Inverse Cubic coordinates mode */
  79682. static readonly TEXTURE_INVCUBIC_MODE: number;
  79683. /** Equirectangular coordinates mode */
  79684. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79685. /** Equirectangular Fixed coordinates mode */
  79686. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79687. /** Equirectangular Fixed Mirrored coordinates mode */
  79688. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79689. /** Offline (baking) quality for texture filtering */
  79690. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79691. /** High quality for texture filtering */
  79692. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79693. /** Medium quality for texture filtering */
  79694. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79695. /** Low quality for texture filtering */
  79696. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79697. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79698. static readonly SCALEMODE_FLOOR: number;
  79699. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79700. static readonly SCALEMODE_NEAREST: number;
  79701. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79702. static readonly SCALEMODE_CEILING: number;
  79703. /**
  79704. * The dirty texture flag value
  79705. */
  79706. static readonly MATERIAL_TextureDirtyFlag: number;
  79707. /**
  79708. * The dirty light flag value
  79709. */
  79710. static readonly MATERIAL_LightDirtyFlag: number;
  79711. /**
  79712. * The dirty fresnel flag value
  79713. */
  79714. static readonly MATERIAL_FresnelDirtyFlag: number;
  79715. /**
  79716. * The dirty attribute flag value
  79717. */
  79718. static readonly MATERIAL_AttributesDirtyFlag: number;
  79719. /**
  79720. * The dirty misc flag value
  79721. */
  79722. static readonly MATERIAL_MiscDirtyFlag: number;
  79723. /**
  79724. * The all dirty flag value
  79725. */
  79726. static readonly MATERIAL_AllDirtyFlag: number;
  79727. /**
  79728. * Returns the triangle fill mode
  79729. */
  79730. static readonly MATERIAL_TriangleFillMode: number;
  79731. /**
  79732. * Returns the wireframe mode
  79733. */
  79734. static readonly MATERIAL_WireFrameFillMode: number;
  79735. /**
  79736. * Returns the point fill mode
  79737. */
  79738. static readonly MATERIAL_PointFillMode: number;
  79739. /**
  79740. * Returns the point list draw mode
  79741. */
  79742. static readonly MATERIAL_PointListDrawMode: number;
  79743. /**
  79744. * Returns the line list draw mode
  79745. */
  79746. static readonly MATERIAL_LineListDrawMode: number;
  79747. /**
  79748. * Returns the line loop draw mode
  79749. */
  79750. static readonly MATERIAL_LineLoopDrawMode: number;
  79751. /**
  79752. * Returns the line strip draw mode
  79753. */
  79754. static readonly MATERIAL_LineStripDrawMode: number;
  79755. /**
  79756. * Returns the triangle strip draw mode
  79757. */
  79758. static readonly MATERIAL_TriangleStripDrawMode: number;
  79759. /**
  79760. * Returns the triangle fan draw mode
  79761. */
  79762. static readonly MATERIAL_TriangleFanDrawMode: number;
  79763. /**
  79764. * Stores the clock-wise side orientation
  79765. */
  79766. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79767. /**
  79768. * Stores the counter clock-wise side orientation
  79769. */
  79770. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79771. /**
  79772. * Nothing
  79773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79774. */
  79775. static readonly ACTION_NothingTrigger: number;
  79776. /**
  79777. * On pick
  79778. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79779. */
  79780. static readonly ACTION_OnPickTrigger: number;
  79781. /**
  79782. * On left pick
  79783. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79784. */
  79785. static readonly ACTION_OnLeftPickTrigger: number;
  79786. /**
  79787. * On right pick
  79788. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79789. */
  79790. static readonly ACTION_OnRightPickTrigger: number;
  79791. /**
  79792. * On center pick
  79793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79794. */
  79795. static readonly ACTION_OnCenterPickTrigger: number;
  79796. /**
  79797. * On pick down
  79798. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79799. */
  79800. static readonly ACTION_OnPickDownTrigger: number;
  79801. /**
  79802. * On double pick
  79803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79804. */
  79805. static readonly ACTION_OnDoublePickTrigger: number;
  79806. /**
  79807. * On pick up
  79808. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79809. */
  79810. static readonly ACTION_OnPickUpTrigger: number;
  79811. /**
  79812. * On pick out.
  79813. * This trigger will only be raised if you also declared a OnPickDown
  79814. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79815. */
  79816. static readonly ACTION_OnPickOutTrigger: number;
  79817. /**
  79818. * On long press
  79819. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79820. */
  79821. static readonly ACTION_OnLongPressTrigger: number;
  79822. /**
  79823. * On pointer over
  79824. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79825. */
  79826. static readonly ACTION_OnPointerOverTrigger: number;
  79827. /**
  79828. * On pointer out
  79829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79830. */
  79831. static readonly ACTION_OnPointerOutTrigger: number;
  79832. /**
  79833. * On every frame
  79834. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79835. */
  79836. static readonly ACTION_OnEveryFrameTrigger: number;
  79837. /**
  79838. * On intersection enter
  79839. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79840. */
  79841. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79842. /**
  79843. * On intersection exit
  79844. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79845. */
  79846. static readonly ACTION_OnIntersectionExitTrigger: number;
  79847. /**
  79848. * On key down
  79849. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79850. */
  79851. static readonly ACTION_OnKeyDownTrigger: number;
  79852. /**
  79853. * On key up
  79854. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79855. */
  79856. static readonly ACTION_OnKeyUpTrigger: number;
  79857. /**
  79858. * Billboard mode will only apply to Y axis
  79859. */
  79860. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79861. /**
  79862. * Billboard mode will apply to all axes
  79863. */
  79864. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79865. /**
  79866. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79867. */
  79868. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79869. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79870. * Test order :
  79871. * Is the bounding sphere outside the frustum ?
  79872. * If not, are the bounding box vertices outside the frustum ?
  79873. * It not, then the cullable object is in the frustum.
  79874. */
  79875. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79876. /** Culling strategy : Bounding Sphere Only.
  79877. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79878. * It's also less accurate than the standard because some not visible objects can still be selected.
  79879. * Test : is the bounding sphere outside the frustum ?
  79880. * If not, then the cullable object is in the frustum.
  79881. */
  79882. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79883. /** Culling strategy : Optimistic Inclusion.
  79884. * This in an inclusion test first, then the standard exclusion test.
  79885. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79886. * 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.
  79887. * Anyway, it's as accurate as the standard strategy.
  79888. * Test :
  79889. * Is the cullable object bounding sphere center in the frustum ?
  79890. * If not, apply the default culling strategy.
  79891. */
  79892. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79893. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79894. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79895. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79896. * 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.
  79897. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79898. * Test :
  79899. * Is the cullable object bounding sphere center in the frustum ?
  79900. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79901. */
  79902. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79903. /**
  79904. * No logging while loading
  79905. */
  79906. static readonly SCENELOADER_NO_LOGGING: number;
  79907. /**
  79908. * Minimal logging while loading
  79909. */
  79910. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79911. /**
  79912. * Summary logging while loading
  79913. */
  79914. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79915. /**
  79916. * Detailled logging while loading
  79917. */
  79918. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79919. /**
  79920. * Prepass texture index for color
  79921. */
  79922. static readonly PREPASS_COLOR_INDEX: number;
  79923. /**
  79924. * Prepass texture index for irradiance
  79925. */
  79926. static readonly PREPASS_IRRADIANCE_INDEX: number;
  79927. /**
  79928. * Prepass texture index for depth + normal
  79929. */
  79930. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  79931. /**
  79932. * Prepass texture index for albedo
  79933. */
  79934. static readonly PREPASS_ALBEDO_INDEX: number;
  79935. }
  79936. }
  79937. declare module BABYLON {
  79938. /**
  79939. * This represents the required contract to create a new type of texture loader.
  79940. */
  79941. export interface IInternalTextureLoader {
  79942. /**
  79943. * Defines wether the loader supports cascade loading the different faces.
  79944. */
  79945. supportCascades: boolean;
  79946. /**
  79947. * This returns if the loader support the current file information.
  79948. * @param extension defines the file extension of the file being loaded
  79949. * @param mimeType defines the optional mime type of the file being loaded
  79950. * @returns true if the loader can load the specified file
  79951. */
  79952. canLoad(extension: string, mimeType?: string): boolean;
  79953. /**
  79954. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79955. * @param data contains the texture data
  79956. * @param texture defines the BabylonJS internal texture
  79957. * @param createPolynomials will be true if polynomials have been requested
  79958. * @param onLoad defines the callback to trigger once the texture is ready
  79959. * @param onError defines the callback to trigger in case of error
  79960. */
  79961. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79962. /**
  79963. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79964. * @param data contains the texture data
  79965. * @param texture defines the BabylonJS internal texture
  79966. * @param callback defines the method to call once ready to upload
  79967. */
  79968. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79969. }
  79970. }
  79971. declare module BABYLON {
  79972. /**
  79973. * Class used to store and describe the pipeline context associated with an effect
  79974. */
  79975. export interface IPipelineContext {
  79976. /**
  79977. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79978. */
  79979. isAsync: boolean;
  79980. /**
  79981. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79982. */
  79983. isReady: boolean;
  79984. /** @hidden */
  79985. _getVertexShaderCode(): string | null;
  79986. /** @hidden */
  79987. _getFragmentShaderCode(): string | null;
  79988. /** @hidden */
  79989. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79990. }
  79991. }
  79992. declare module BABYLON {
  79993. /**
  79994. * Class used to store gfx data (like WebGLBuffer)
  79995. */
  79996. export class DataBuffer {
  79997. /**
  79998. * Gets or sets the number of objects referencing this buffer
  79999. */
  80000. references: number;
  80001. /** Gets or sets the size of the underlying buffer */
  80002. capacity: number;
  80003. /**
  80004. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80005. */
  80006. is32Bits: boolean;
  80007. /**
  80008. * Gets the underlying buffer
  80009. */
  80010. get underlyingResource(): any;
  80011. }
  80012. }
  80013. declare module BABYLON {
  80014. /** @hidden */
  80015. export interface IShaderProcessor {
  80016. attributeProcessor?: (attribute: string) => string;
  80017. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80018. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80019. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80020. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80021. lineProcessor?: (line: string, isFragment: boolean) => string;
  80022. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80023. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80024. }
  80025. }
  80026. declare module BABYLON {
  80027. /** @hidden */
  80028. export interface ProcessingOptions {
  80029. defines: string[];
  80030. indexParameters: any;
  80031. isFragment: boolean;
  80032. shouldUseHighPrecisionShader: boolean;
  80033. supportsUniformBuffers: boolean;
  80034. shadersRepository: string;
  80035. includesShadersStore: {
  80036. [key: string]: string;
  80037. };
  80038. processor?: IShaderProcessor;
  80039. version: string;
  80040. platformName: string;
  80041. lookForClosingBracketForUniformBuffer?: boolean;
  80042. }
  80043. }
  80044. declare module BABYLON {
  80045. /** @hidden */
  80046. export class ShaderCodeNode {
  80047. line: string;
  80048. children: ShaderCodeNode[];
  80049. additionalDefineKey?: string;
  80050. additionalDefineValue?: string;
  80051. isValid(preprocessors: {
  80052. [key: string]: string;
  80053. }): boolean;
  80054. process(preprocessors: {
  80055. [key: string]: string;
  80056. }, options: ProcessingOptions): string;
  80057. }
  80058. }
  80059. declare module BABYLON {
  80060. /** @hidden */
  80061. export class ShaderCodeCursor {
  80062. private _lines;
  80063. lineIndex: number;
  80064. get currentLine(): string;
  80065. get canRead(): boolean;
  80066. set lines(value: string[]);
  80067. }
  80068. }
  80069. declare module BABYLON {
  80070. /** @hidden */
  80071. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80072. process(preprocessors: {
  80073. [key: string]: string;
  80074. }, options: ProcessingOptions): string;
  80075. }
  80076. }
  80077. declare module BABYLON {
  80078. /** @hidden */
  80079. export class ShaderDefineExpression {
  80080. isTrue(preprocessors: {
  80081. [key: string]: string;
  80082. }): boolean;
  80083. private static _OperatorPriority;
  80084. private static _Stack;
  80085. static postfixToInfix(postfix: string[]): string;
  80086. static infixToPostfix(infix: string): string[];
  80087. }
  80088. }
  80089. declare module BABYLON {
  80090. /** @hidden */
  80091. export class ShaderCodeTestNode extends ShaderCodeNode {
  80092. testExpression: ShaderDefineExpression;
  80093. isValid(preprocessors: {
  80094. [key: string]: string;
  80095. }): boolean;
  80096. }
  80097. }
  80098. declare module BABYLON {
  80099. /** @hidden */
  80100. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80101. define: string;
  80102. not: boolean;
  80103. constructor(define: string, not?: boolean);
  80104. isTrue(preprocessors: {
  80105. [key: string]: string;
  80106. }): boolean;
  80107. }
  80108. }
  80109. declare module BABYLON {
  80110. /** @hidden */
  80111. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80112. leftOperand: ShaderDefineExpression;
  80113. rightOperand: ShaderDefineExpression;
  80114. isTrue(preprocessors: {
  80115. [key: string]: string;
  80116. }): boolean;
  80117. }
  80118. }
  80119. declare module BABYLON {
  80120. /** @hidden */
  80121. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80122. leftOperand: ShaderDefineExpression;
  80123. rightOperand: ShaderDefineExpression;
  80124. isTrue(preprocessors: {
  80125. [key: string]: string;
  80126. }): boolean;
  80127. }
  80128. }
  80129. declare module BABYLON {
  80130. /** @hidden */
  80131. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80132. define: string;
  80133. operand: string;
  80134. testValue: string;
  80135. constructor(define: string, operand: string, testValue: string);
  80136. isTrue(preprocessors: {
  80137. [key: string]: string;
  80138. }): boolean;
  80139. }
  80140. }
  80141. declare module BABYLON {
  80142. /**
  80143. * Class used to enable access to offline support
  80144. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80145. */
  80146. export interface IOfflineProvider {
  80147. /**
  80148. * Gets a boolean indicating if scene must be saved in the database
  80149. */
  80150. enableSceneOffline: boolean;
  80151. /**
  80152. * Gets a boolean indicating if textures must be saved in the database
  80153. */
  80154. enableTexturesOffline: boolean;
  80155. /**
  80156. * Open the offline support and make it available
  80157. * @param successCallback defines the callback to call on success
  80158. * @param errorCallback defines the callback to call on error
  80159. */
  80160. open(successCallback: () => void, errorCallback: () => void): void;
  80161. /**
  80162. * Loads an image from the offline support
  80163. * @param url defines the url to load from
  80164. * @param image defines the target DOM image
  80165. */
  80166. loadImage(url: string, image: HTMLImageElement): void;
  80167. /**
  80168. * Loads a file from offline support
  80169. * @param url defines the URL to load from
  80170. * @param sceneLoaded defines a callback to call on success
  80171. * @param progressCallBack defines a callback to call when progress changed
  80172. * @param errorCallback defines a callback to call on error
  80173. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80174. */
  80175. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80176. }
  80177. }
  80178. declare module BABYLON {
  80179. /**
  80180. * Class used to help managing file picking and drag'n'drop
  80181. * File Storage
  80182. */
  80183. export class FilesInputStore {
  80184. /**
  80185. * List of files ready to be loaded
  80186. */
  80187. static FilesToLoad: {
  80188. [key: string]: File;
  80189. };
  80190. }
  80191. }
  80192. declare module BABYLON {
  80193. /**
  80194. * Class used to define a retry strategy when error happens while loading assets
  80195. */
  80196. export class RetryStrategy {
  80197. /**
  80198. * Function used to defines an exponential back off strategy
  80199. * @param maxRetries defines the maximum number of retries (3 by default)
  80200. * @param baseInterval defines the interval between retries
  80201. * @returns the strategy function to use
  80202. */
  80203. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80204. }
  80205. }
  80206. declare module BABYLON {
  80207. /**
  80208. * @ignore
  80209. * Application error to support additional information when loading a file
  80210. */
  80211. export abstract class BaseError extends Error {
  80212. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80213. }
  80214. }
  80215. declare module BABYLON {
  80216. /** @ignore */
  80217. export class LoadFileError extends BaseError {
  80218. request?: WebRequest;
  80219. file?: File;
  80220. /**
  80221. * Creates a new LoadFileError
  80222. * @param message defines the message of the error
  80223. * @param request defines the optional web request
  80224. * @param file defines the optional file
  80225. */
  80226. constructor(message: string, object?: WebRequest | File);
  80227. }
  80228. /** @ignore */
  80229. export class RequestFileError extends BaseError {
  80230. request: WebRequest;
  80231. /**
  80232. * Creates a new LoadFileError
  80233. * @param message defines the message of the error
  80234. * @param request defines the optional web request
  80235. */
  80236. constructor(message: string, request: WebRequest);
  80237. }
  80238. /** @ignore */
  80239. export class ReadFileError extends BaseError {
  80240. file: File;
  80241. /**
  80242. * Creates a new ReadFileError
  80243. * @param message defines the message of the error
  80244. * @param file defines the optional file
  80245. */
  80246. constructor(message: string, file: File);
  80247. }
  80248. /**
  80249. * @hidden
  80250. */
  80251. export class FileTools {
  80252. /**
  80253. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  80254. */
  80255. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  80256. /**
  80257. * Gets or sets the base URL to use to load assets
  80258. */
  80259. static BaseUrl: string;
  80260. /**
  80261. * Default behaviour for cors in the application.
  80262. * It can be a string if the expected behavior is identical in the entire app.
  80263. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  80264. */
  80265. static CorsBehavior: string | ((url: string | string[]) => string);
  80266. /**
  80267. * Gets or sets a function used to pre-process url before using them to load assets
  80268. */
  80269. static PreprocessUrl: (url: string) => string;
  80270. /**
  80271. * Removes unwanted characters from an url
  80272. * @param url defines the url to clean
  80273. * @returns the cleaned url
  80274. */
  80275. private static _CleanUrl;
  80276. /**
  80277. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  80278. * @param url define the url we are trying
  80279. * @param element define the dom element where to configure the cors policy
  80280. */
  80281. static SetCorsBehavior(url: string | string[], element: {
  80282. crossOrigin: string | null;
  80283. }): void;
  80284. /**
  80285. * Loads an image as an HTMLImageElement.
  80286. * @param input url string, ArrayBuffer, or Blob to load
  80287. * @param onLoad callback called when the image successfully loads
  80288. * @param onError callback called when the image fails to load
  80289. * @param offlineProvider offline provider for caching
  80290. * @param mimeType optional mime type
  80291. * @returns the HTMLImageElement of the loaded image
  80292. */
  80293. 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>;
  80294. /**
  80295. * Reads a file from a File object
  80296. * @param file defines the file to load
  80297. * @param onSuccess defines the callback to call when data is loaded
  80298. * @param onProgress defines the callback to call during loading process
  80299. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  80300. * @param onError defines the callback to call when an error occurs
  80301. * @returns a file request object
  80302. */
  80303. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  80304. /**
  80305. * Loads a file from a url
  80306. * @param url url to load
  80307. * @param onSuccess callback called when the file successfully loads
  80308. * @param onProgress callback called while file is loading (if the server supports this mode)
  80309. * @param offlineProvider defines the offline provider for caching
  80310. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80311. * @param onError callback called when the file fails to load
  80312. * @returns a file request object
  80313. */
  80314. 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;
  80315. /**
  80316. * Loads a file
  80317. * @param url url to load
  80318. * @param onSuccess callback called when the file successfully loads
  80319. * @param onProgress callback called while file is loading (if the server supports this mode)
  80320. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80321. * @param onError callback called when the file fails to load
  80322. * @param onOpened callback called when the web request is opened
  80323. * @returns a file request object
  80324. */
  80325. 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;
  80326. /**
  80327. * Checks if the loaded document was accessed via `file:`-Protocol.
  80328. * @returns boolean
  80329. */
  80330. static IsFileURL(): boolean;
  80331. }
  80332. }
  80333. declare module BABYLON {
  80334. /** @hidden */
  80335. export class ShaderProcessor {
  80336. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80337. private static _ProcessPrecision;
  80338. private static _ExtractOperation;
  80339. private static _BuildSubExpression;
  80340. private static _BuildExpression;
  80341. private static _MoveCursorWithinIf;
  80342. private static _MoveCursor;
  80343. private static _EvaluatePreProcessors;
  80344. private static _PreparePreProcessors;
  80345. private static _ProcessShaderConversion;
  80346. private static _ProcessIncludes;
  80347. /**
  80348. * Loads a file from a url
  80349. * @param url url to load
  80350. * @param onSuccess callback called when the file successfully loads
  80351. * @param onProgress callback called while file is loading (if the server supports this mode)
  80352. * @param offlineProvider defines the offline provider for caching
  80353. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80354. * @param onError callback called when the file fails to load
  80355. * @returns a file request object
  80356. * @hidden
  80357. */
  80358. 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;
  80359. }
  80360. }
  80361. declare module BABYLON {
  80362. /**
  80363. * @hidden
  80364. */
  80365. export interface IColor4Like {
  80366. r: float;
  80367. g: float;
  80368. b: float;
  80369. a: float;
  80370. }
  80371. /**
  80372. * @hidden
  80373. */
  80374. export interface IColor3Like {
  80375. r: float;
  80376. g: float;
  80377. b: float;
  80378. }
  80379. /**
  80380. * @hidden
  80381. */
  80382. export interface IVector4Like {
  80383. x: float;
  80384. y: float;
  80385. z: float;
  80386. w: float;
  80387. }
  80388. /**
  80389. * @hidden
  80390. */
  80391. export interface IVector3Like {
  80392. x: float;
  80393. y: float;
  80394. z: float;
  80395. }
  80396. /**
  80397. * @hidden
  80398. */
  80399. export interface IVector2Like {
  80400. x: float;
  80401. y: float;
  80402. }
  80403. /**
  80404. * @hidden
  80405. */
  80406. export interface IMatrixLike {
  80407. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80408. updateFlag: int;
  80409. }
  80410. /**
  80411. * @hidden
  80412. */
  80413. export interface IViewportLike {
  80414. x: float;
  80415. y: float;
  80416. width: float;
  80417. height: float;
  80418. }
  80419. /**
  80420. * @hidden
  80421. */
  80422. export interface IPlaneLike {
  80423. normal: IVector3Like;
  80424. d: float;
  80425. normalize(): void;
  80426. }
  80427. }
  80428. declare module BABYLON {
  80429. /**
  80430. * Interface used to define common properties for effect fallbacks
  80431. */
  80432. export interface IEffectFallbacks {
  80433. /**
  80434. * Removes the defines that should be removed when falling back.
  80435. * @param currentDefines defines the current define statements for the shader.
  80436. * @param effect defines the current effect we try to compile
  80437. * @returns The resulting defines with defines of the current rank removed.
  80438. */
  80439. reduce(currentDefines: string, effect: Effect): string;
  80440. /**
  80441. * Removes the fallback from the bound mesh.
  80442. */
  80443. unBindMesh(): void;
  80444. /**
  80445. * Checks to see if more fallbacks are still availible.
  80446. */
  80447. hasMoreFallbacks: boolean;
  80448. }
  80449. }
  80450. declare module BABYLON {
  80451. /**
  80452. * Class used to evalaute queries containing `and` and `or` operators
  80453. */
  80454. export class AndOrNotEvaluator {
  80455. /**
  80456. * Evaluate a query
  80457. * @param query defines the query to evaluate
  80458. * @param evaluateCallback defines the callback used to filter result
  80459. * @returns true if the query matches
  80460. */
  80461. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80462. private static _HandleParenthesisContent;
  80463. private static _SimplifyNegation;
  80464. }
  80465. }
  80466. declare module BABYLON {
  80467. /**
  80468. * Class used to store custom tags
  80469. */
  80470. export class Tags {
  80471. /**
  80472. * Adds support for tags on the given object
  80473. * @param obj defines the object to use
  80474. */
  80475. static EnableFor(obj: any): void;
  80476. /**
  80477. * Removes tags support
  80478. * @param obj defines the object to use
  80479. */
  80480. static DisableFor(obj: any): void;
  80481. /**
  80482. * Gets a boolean indicating if the given object has tags
  80483. * @param obj defines the object to use
  80484. * @returns a boolean
  80485. */
  80486. static HasTags(obj: any): boolean;
  80487. /**
  80488. * Gets the tags available on a given object
  80489. * @param obj defines the object to use
  80490. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80491. * @returns the tags
  80492. */
  80493. static GetTags(obj: any, asString?: boolean): any;
  80494. /**
  80495. * Adds tags to an object
  80496. * @param obj defines the object to use
  80497. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80498. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80499. */
  80500. static AddTagsTo(obj: any, tagsString: string): void;
  80501. /**
  80502. * @hidden
  80503. */
  80504. static _AddTagTo(obj: any, tag: string): void;
  80505. /**
  80506. * Removes specific tags from a specific object
  80507. * @param obj defines the object to use
  80508. * @param tagsString defines the tags to remove
  80509. */
  80510. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80511. /**
  80512. * @hidden
  80513. */
  80514. static _RemoveTagFrom(obj: any, tag: string): void;
  80515. /**
  80516. * Defines if tags hosted on an object match a given query
  80517. * @param obj defines the object to use
  80518. * @param tagsQuery defines the tag query
  80519. * @returns a boolean
  80520. */
  80521. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80522. }
  80523. }
  80524. declare module BABYLON {
  80525. /**
  80526. * Scalar computation library
  80527. */
  80528. export class Scalar {
  80529. /**
  80530. * Two pi constants convenient for computation.
  80531. */
  80532. static TwoPi: number;
  80533. /**
  80534. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80535. * @param a number
  80536. * @param b number
  80537. * @param epsilon (default = 1.401298E-45)
  80538. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80539. */
  80540. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80541. /**
  80542. * Returns a string : the upper case translation of the number i to hexadecimal.
  80543. * @param i number
  80544. * @returns the upper case translation of the number i to hexadecimal.
  80545. */
  80546. static ToHex(i: number): string;
  80547. /**
  80548. * Returns -1 if value is negative and +1 is value is positive.
  80549. * @param value the value
  80550. * @returns the value itself if it's equal to zero.
  80551. */
  80552. static Sign(value: number): number;
  80553. /**
  80554. * Returns the value itself if it's between min and max.
  80555. * Returns min if the value is lower than min.
  80556. * Returns max if the value is greater than max.
  80557. * @param value the value to clmap
  80558. * @param min the min value to clamp to (default: 0)
  80559. * @param max the max value to clamp to (default: 1)
  80560. * @returns the clamped value
  80561. */
  80562. static Clamp(value: number, min?: number, max?: number): number;
  80563. /**
  80564. * the log2 of value.
  80565. * @param value the value to compute log2 of
  80566. * @returns the log2 of value.
  80567. */
  80568. static Log2(value: number): number;
  80569. /**
  80570. * Loops the value, so that it is never larger than length and never smaller than 0.
  80571. *
  80572. * This is similar to the modulo operator but it works with floating point numbers.
  80573. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80574. * With t = 5 and length = 2.5, the result would be 0.0.
  80575. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80576. * @param value the value
  80577. * @param length the length
  80578. * @returns the looped value
  80579. */
  80580. static Repeat(value: number, length: number): number;
  80581. /**
  80582. * Normalize the value between 0.0 and 1.0 using min and max values
  80583. * @param value value to normalize
  80584. * @param min max to normalize between
  80585. * @param max min to normalize between
  80586. * @returns the normalized value
  80587. */
  80588. static Normalize(value: number, min: number, max: number): number;
  80589. /**
  80590. * Denormalize the value from 0.0 and 1.0 using min and max values
  80591. * @param normalized value to denormalize
  80592. * @param min max to denormalize between
  80593. * @param max min to denormalize between
  80594. * @returns the denormalized value
  80595. */
  80596. static Denormalize(normalized: number, min: number, max: number): number;
  80597. /**
  80598. * Calculates the shortest difference between two given angles given in degrees.
  80599. * @param current current angle in degrees
  80600. * @param target target angle in degrees
  80601. * @returns the delta
  80602. */
  80603. static DeltaAngle(current: number, target: number): number;
  80604. /**
  80605. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80606. * @param tx value
  80607. * @param length length
  80608. * @returns The returned value will move back and forth between 0 and length
  80609. */
  80610. static PingPong(tx: number, length: number): number;
  80611. /**
  80612. * Interpolates between min and max with smoothing at the limits.
  80613. *
  80614. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80615. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80616. * @param from from
  80617. * @param to to
  80618. * @param tx value
  80619. * @returns the smooth stepped value
  80620. */
  80621. static SmoothStep(from: number, to: number, tx: number): number;
  80622. /**
  80623. * Moves a value current towards target.
  80624. *
  80625. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80626. * Negative values of maxDelta pushes the value away from target.
  80627. * @param current current value
  80628. * @param target target value
  80629. * @param maxDelta max distance to move
  80630. * @returns resulting value
  80631. */
  80632. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80633. /**
  80634. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80635. *
  80636. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80637. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80638. * @param current current value
  80639. * @param target target value
  80640. * @param maxDelta max distance to move
  80641. * @returns resulting angle
  80642. */
  80643. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80644. /**
  80645. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80646. * @param start start value
  80647. * @param end target value
  80648. * @param amount amount to lerp between
  80649. * @returns the lerped value
  80650. */
  80651. static Lerp(start: number, end: number, amount: number): number;
  80652. /**
  80653. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80654. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80655. * @param start start value
  80656. * @param end target value
  80657. * @param amount amount to lerp between
  80658. * @returns the lerped value
  80659. */
  80660. static LerpAngle(start: number, end: number, amount: number): number;
  80661. /**
  80662. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80663. * @param a start value
  80664. * @param b target value
  80665. * @param value value between a and b
  80666. * @returns the inverseLerp value
  80667. */
  80668. static InverseLerp(a: number, b: number, value: number): number;
  80669. /**
  80670. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80671. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80672. * @param value1 spline value
  80673. * @param tangent1 spline value
  80674. * @param value2 spline value
  80675. * @param tangent2 spline value
  80676. * @param amount input value
  80677. * @returns hermite result
  80678. */
  80679. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80680. /**
  80681. * Returns a random float number between and min and max values
  80682. * @param min min value of random
  80683. * @param max max value of random
  80684. * @returns random value
  80685. */
  80686. static RandomRange(min: number, max: number): number;
  80687. /**
  80688. * This function returns percentage of a number in a given range.
  80689. *
  80690. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80691. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80692. * @param number to convert to percentage
  80693. * @param min min range
  80694. * @param max max range
  80695. * @returns the percentage
  80696. */
  80697. static RangeToPercent(number: number, min: number, max: number): number;
  80698. /**
  80699. * This function returns number that corresponds to the percentage in a given range.
  80700. *
  80701. * PercentToRange(0.34,0,100) will return 34.
  80702. * @param percent to convert to number
  80703. * @param min min range
  80704. * @param max max range
  80705. * @returns the number
  80706. */
  80707. static PercentToRange(percent: number, min: number, max: number): number;
  80708. /**
  80709. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80710. * @param angle The angle to normalize in radian.
  80711. * @return The converted angle.
  80712. */
  80713. static NormalizeRadians(angle: number): number;
  80714. }
  80715. }
  80716. declare module BABYLON {
  80717. /**
  80718. * Constant used to convert a value to gamma space
  80719. * @ignorenaming
  80720. */
  80721. export const ToGammaSpace: number;
  80722. /**
  80723. * Constant used to convert a value to linear space
  80724. * @ignorenaming
  80725. */
  80726. export const ToLinearSpace = 2.2;
  80727. /**
  80728. * Constant used to define the minimal number value in Babylon.js
  80729. * @ignorenaming
  80730. */
  80731. let Epsilon: number;
  80732. }
  80733. declare module BABYLON {
  80734. /**
  80735. * Class used to represent a viewport on screen
  80736. */
  80737. export class Viewport {
  80738. /** viewport left coordinate */
  80739. x: number;
  80740. /** viewport top coordinate */
  80741. y: number;
  80742. /**viewport width */
  80743. width: number;
  80744. /** viewport height */
  80745. height: number;
  80746. /**
  80747. * Creates a Viewport object located at (x, y) and sized (width, height)
  80748. * @param x defines viewport left coordinate
  80749. * @param y defines viewport top coordinate
  80750. * @param width defines the viewport width
  80751. * @param height defines the viewport height
  80752. */
  80753. constructor(
  80754. /** viewport left coordinate */
  80755. x: number,
  80756. /** viewport top coordinate */
  80757. y: number,
  80758. /**viewport width */
  80759. width: number,
  80760. /** viewport height */
  80761. height: number);
  80762. /**
  80763. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80764. * @param renderWidth defines the rendering width
  80765. * @param renderHeight defines the rendering height
  80766. * @returns a new Viewport
  80767. */
  80768. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80769. /**
  80770. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80771. * @param renderWidth defines the rendering width
  80772. * @param renderHeight defines the rendering height
  80773. * @param ref defines the target viewport
  80774. * @returns the current viewport
  80775. */
  80776. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80777. /**
  80778. * Returns a new Viewport copied from the current one
  80779. * @returns a new Viewport
  80780. */
  80781. clone(): Viewport;
  80782. }
  80783. }
  80784. declare module BABYLON {
  80785. /**
  80786. * Class containing a set of static utilities functions for arrays.
  80787. */
  80788. export class ArrayTools {
  80789. /**
  80790. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80791. * @param size the number of element to construct and put in the array
  80792. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80793. * @returns a new array filled with new objects
  80794. */
  80795. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80796. }
  80797. }
  80798. declare module BABYLON {
  80799. /**
  80800. * Represents a plane by the equation ax + by + cz + d = 0
  80801. */
  80802. export class Plane {
  80803. private static _TmpMatrix;
  80804. /**
  80805. * Normal of the plane (a,b,c)
  80806. */
  80807. normal: Vector3;
  80808. /**
  80809. * d component of the plane
  80810. */
  80811. d: number;
  80812. /**
  80813. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80814. * @param a a component of the plane
  80815. * @param b b component of the plane
  80816. * @param c c component of the plane
  80817. * @param d d component of the plane
  80818. */
  80819. constructor(a: number, b: number, c: number, d: number);
  80820. /**
  80821. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80822. */
  80823. asArray(): number[];
  80824. /**
  80825. * @returns a new plane copied from the current Plane.
  80826. */
  80827. clone(): Plane;
  80828. /**
  80829. * @returns the string "Plane".
  80830. */
  80831. getClassName(): string;
  80832. /**
  80833. * @returns the Plane hash code.
  80834. */
  80835. getHashCode(): number;
  80836. /**
  80837. * Normalize the current Plane in place.
  80838. * @returns the updated Plane.
  80839. */
  80840. normalize(): Plane;
  80841. /**
  80842. * Applies a transformation the plane and returns the result
  80843. * @param transformation the transformation matrix to be applied to the plane
  80844. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80845. */
  80846. transform(transformation: DeepImmutable<Matrix>): Plane;
  80847. /**
  80848. * Compute the dot product between the point and the plane normal
  80849. * @param point point to calculate the dot product with
  80850. * @returns the dot product (float) of the point coordinates and the plane normal.
  80851. */
  80852. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80853. /**
  80854. * Updates the current Plane from the plane defined by the three given points.
  80855. * @param point1 one of the points used to contruct the plane
  80856. * @param point2 one of the points used to contruct the plane
  80857. * @param point3 one of the points used to contruct the plane
  80858. * @returns the updated Plane.
  80859. */
  80860. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80861. /**
  80862. * Checks if the plane is facing a given direction
  80863. * @param direction the direction to check if the plane is facing
  80864. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80865. * @returns True is the vector "direction" is the same side than the plane normal.
  80866. */
  80867. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80868. /**
  80869. * Calculates the distance to a point
  80870. * @param point point to calculate distance to
  80871. * @returns the signed distance (float) from the given point to the Plane.
  80872. */
  80873. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80874. /**
  80875. * Creates a plane from an array
  80876. * @param array the array to create a plane from
  80877. * @returns a new Plane from the given array.
  80878. */
  80879. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80880. /**
  80881. * Creates a plane from three points
  80882. * @param point1 point used to create the plane
  80883. * @param point2 point used to create the plane
  80884. * @param point3 point used to create the plane
  80885. * @returns a new Plane defined by the three given points.
  80886. */
  80887. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80888. /**
  80889. * Creates a plane from an origin point and a normal
  80890. * @param origin origin of the plane to be constructed
  80891. * @param normal normal of the plane to be constructed
  80892. * @returns a new Plane the normal vector to this plane at the given origin point.
  80893. * Note : the vector "normal" is updated because normalized.
  80894. */
  80895. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80896. /**
  80897. * Calculates the distance from a plane and a point
  80898. * @param origin origin of the plane to be constructed
  80899. * @param normal normal of the plane to be constructed
  80900. * @param point point to calculate distance to
  80901. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80902. */
  80903. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80904. }
  80905. }
  80906. declare module BABYLON {
  80907. /** @hidden */
  80908. export class PerformanceConfigurator {
  80909. /** @hidden */
  80910. static MatrixUse64Bits: boolean;
  80911. /** @hidden */
  80912. static MatrixTrackPrecisionChange: boolean;
  80913. /** @hidden */
  80914. static MatrixCurrentType: any;
  80915. /** @hidden */
  80916. static MatrixTrackedMatrices: Array<any> | null;
  80917. /** @hidden */
  80918. static SetMatrixPrecision(use64bits: boolean): void;
  80919. }
  80920. }
  80921. declare module BABYLON {
  80922. /**
  80923. * Class representing a vector containing 2 coordinates
  80924. */
  80925. export class Vector2 {
  80926. /** defines the first coordinate */
  80927. x: number;
  80928. /** defines the second coordinate */
  80929. y: number;
  80930. /**
  80931. * Creates a new Vector2 from the given x and y coordinates
  80932. * @param x defines the first coordinate
  80933. * @param y defines the second coordinate
  80934. */
  80935. constructor(
  80936. /** defines the first coordinate */
  80937. x?: number,
  80938. /** defines the second coordinate */
  80939. y?: number);
  80940. /**
  80941. * Gets a string with the Vector2 coordinates
  80942. * @returns a string with the Vector2 coordinates
  80943. */
  80944. toString(): string;
  80945. /**
  80946. * Gets class name
  80947. * @returns the string "Vector2"
  80948. */
  80949. getClassName(): string;
  80950. /**
  80951. * Gets current vector hash code
  80952. * @returns the Vector2 hash code as a number
  80953. */
  80954. getHashCode(): number;
  80955. /**
  80956. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80957. * @param array defines the source array
  80958. * @param index defines the offset in source array
  80959. * @returns the current Vector2
  80960. */
  80961. toArray(array: FloatArray, index?: number): Vector2;
  80962. /**
  80963. * Update the current vector from an array
  80964. * @param array defines the destination array
  80965. * @param index defines the offset in the destination array
  80966. * @returns the current Vector3
  80967. */
  80968. fromArray(array: FloatArray, index?: number): Vector2;
  80969. /**
  80970. * Copy the current vector to an array
  80971. * @returns a new array with 2 elements: the Vector2 coordinates.
  80972. */
  80973. asArray(): number[];
  80974. /**
  80975. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80976. * @param source defines the source Vector2
  80977. * @returns the current updated Vector2
  80978. */
  80979. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80980. /**
  80981. * Sets the Vector2 coordinates with the given floats
  80982. * @param x defines the first coordinate
  80983. * @param y defines the second coordinate
  80984. * @returns the current updated Vector2
  80985. */
  80986. copyFromFloats(x: number, y: number): Vector2;
  80987. /**
  80988. * Sets the Vector2 coordinates with the given floats
  80989. * @param x defines the first coordinate
  80990. * @param y defines the second coordinate
  80991. * @returns the current updated Vector2
  80992. */
  80993. set(x: number, y: number): Vector2;
  80994. /**
  80995. * Add another vector with the current one
  80996. * @param otherVector defines the other vector
  80997. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80998. */
  80999. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81000. /**
  81001. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81002. * @param otherVector defines the other vector
  81003. * @param result defines the target vector
  81004. * @returns the unmodified current Vector2
  81005. */
  81006. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81007. /**
  81008. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81009. * @param otherVector defines the other vector
  81010. * @returns the current updated Vector2
  81011. */
  81012. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81013. /**
  81014. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81015. * @param otherVector defines the other vector
  81016. * @returns a new Vector2
  81017. */
  81018. addVector3(otherVector: Vector3): Vector2;
  81019. /**
  81020. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81021. * @param otherVector defines the other vector
  81022. * @returns a new Vector2
  81023. */
  81024. subtract(otherVector: Vector2): Vector2;
  81025. /**
  81026. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81027. * @param otherVector defines the other vector
  81028. * @param result defines the target vector
  81029. * @returns the unmodified current Vector2
  81030. */
  81031. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81032. /**
  81033. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81034. * @param otherVector defines the other vector
  81035. * @returns the current updated Vector2
  81036. */
  81037. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81038. /**
  81039. * Multiplies in place the current Vector2 coordinates by the given ones
  81040. * @param otherVector defines the other vector
  81041. * @returns the current updated Vector2
  81042. */
  81043. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81044. /**
  81045. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81046. * @param otherVector defines the other vector
  81047. * @returns a new Vector2
  81048. */
  81049. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81050. /**
  81051. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81052. * @param otherVector defines the other vector
  81053. * @param result defines the target vector
  81054. * @returns the unmodified current Vector2
  81055. */
  81056. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81057. /**
  81058. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81059. * @param x defines the first coordinate
  81060. * @param y defines the second coordinate
  81061. * @returns a new Vector2
  81062. */
  81063. multiplyByFloats(x: number, y: number): Vector2;
  81064. /**
  81065. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81066. * @param otherVector defines the other vector
  81067. * @returns a new Vector2
  81068. */
  81069. divide(otherVector: Vector2): Vector2;
  81070. /**
  81071. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81072. * @param otherVector defines the other vector
  81073. * @param result defines the target vector
  81074. * @returns the unmodified current Vector2
  81075. */
  81076. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81077. /**
  81078. * Divides the current Vector2 coordinates by the given ones
  81079. * @param otherVector defines the other vector
  81080. * @returns the current updated Vector2
  81081. */
  81082. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81083. /**
  81084. * Gets a new Vector2 with current Vector2 negated coordinates
  81085. * @returns a new Vector2
  81086. */
  81087. negate(): Vector2;
  81088. /**
  81089. * Negate this vector in place
  81090. * @returns this
  81091. */
  81092. negateInPlace(): Vector2;
  81093. /**
  81094. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81095. * @param result defines the Vector3 object where to store the result
  81096. * @returns the current Vector2
  81097. */
  81098. negateToRef(result: Vector2): Vector2;
  81099. /**
  81100. * Multiply the Vector2 coordinates by scale
  81101. * @param scale defines the scaling factor
  81102. * @returns the current updated Vector2
  81103. */
  81104. scaleInPlace(scale: number): Vector2;
  81105. /**
  81106. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81107. * @param scale defines the scaling factor
  81108. * @returns a new Vector2
  81109. */
  81110. scale(scale: number): Vector2;
  81111. /**
  81112. * Scale the current Vector2 values by a factor to a given Vector2
  81113. * @param scale defines the scale factor
  81114. * @param result defines the Vector2 object where to store the result
  81115. * @returns the unmodified current Vector2
  81116. */
  81117. scaleToRef(scale: number, result: Vector2): Vector2;
  81118. /**
  81119. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81120. * @param scale defines the scale factor
  81121. * @param result defines the Vector2 object where to store the result
  81122. * @returns the unmodified current Vector2
  81123. */
  81124. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81125. /**
  81126. * Gets a boolean if two vectors are equals
  81127. * @param otherVector defines the other vector
  81128. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81129. */
  81130. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81131. /**
  81132. * Gets a boolean if two vectors are equals (using an epsilon value)
  81133. * @param otherVector defines the other vector
  81134. * @param epsilon defines the minimal distance to consider equality
  81135. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81136. */
  81137. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81138. /**
  81139. * Gets a new Vector2 from current Vector2 floored values
  81140. * @returns a new Vector2
  81141. */
  81142. floor(): Vector2;
  81143. /**
  81144. * Gets a new Vector2 from current Vector2 floored values
  81145. * @returns a new Vector2
  81146. */
  81147. fract(): Vector2;
  81148. /**
  81149. * Gets the length of the vector
  81150. * @returns the vector length (float)
  81151. */
  81152. length(): number;
  81153. /**
  81154. * Gets the vector squared length
  81155. * @returns the vector squared length (float)
  81156. */
  81157. lengthSquared(): number;
  81158. /**
  81159. * Normalize the vector
  81160. * @returns the current updated Vector2
  81161. */
  81162. normalize(): Vector2;
  81163. /**
  81164. * Gets a new Vector2 copied from the Vector2
  81165. * @returns a new Vector2
  81166. */
  81167. clone(): Vector2;
  81168. /**
  81169. * Gets a new Vector2(0, 0)
  81170. * @returns a new Vector2
  81171. */
  81172. static Zero(): Vector2;
  81173. /**
  81174. * Gets a new Vector2(1, 1)
  81175. * @returns a new Vector2
  81176. */
  81177. static One(): Vector2;
  81178. /**
  81179. * Gets a new Vector2 set from the given index element of the given array
  81180. * @param array defines the data source
  81181. * @param offset defines the offset in the data source
  81182. * @returns a new Vector2
  81183. */
  81184. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81185. /**
  81186. * Sets "result" from the given index element of the given array
  81187. * @param array defines the data source
  81188. * @param offset defines the offset in the data source
  81189. * @param result defines the target vector
  81190. */
  81191. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81192. /**
  81193. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81194. * @param value1 defines 1st point of control
  81195. * @param value2 defines 2nd point of control
  81196. * @param value3 defines 3rd point of control
  81197. * @param value4 defines 4th point of control
  81198. * @param amount defines the interpolation factor
  81199. * @returns a new Vector2
  81200. */
  81201. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81202. /**
  81203. * 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".
  81204. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81205. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81206. * @param value defines the value to clamp
  81207. * @param min defines the lower limit
  81208. * @param max defines the upper limit
  81209. * @returns a new Vector2
  81210. */
  81211. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81212. /**
  81213. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81214. * @param value1 defines the 1st control point
  81215. * @param tangent1 defines the outgoing tangent
  81216. * @param value2 defines the 2nd control point
  81217. * @param tangent2 defines the incoming tangent
  81218. * @param amount defines the interpolation factor
  81219. * @returns a new Vector2
  81220. */
  81221. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81222. /**
  81223. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81224. * @param start defines the start vector
  81225. * @param end defines the end vector
  81226. * @param amount defines the interpolation factor
  81227. * @returns a new Vector2
  81228. */
  81229. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81230. /**
  81231. * Gets the dot product of the vector "left" and the vector "right"
  81232. * @param left defines first vector
  81233. * @param right defines second vector
  81234. * @returns the dot product (float)
  81235. */
  81236. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81237. /**
  81238. * Returns a new Vector2 equal to the normalized given vector
  81239. * @param vector defines the vector to normalize
  81240. * @returns a new Vector2
  81241. */
  81242. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81243. /**
  81244. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81245. * @param left defines 1st vector
  81246. * @param right defines 2nd vector
  81247. * @returns a new Vector2
  81248. */
  81249. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81250. /**
  81251. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  81252. * @param left defines 1st vector
  81253. * @param right defines 2nd vector
  81254. * @returns a new Vector2
  81255. */
  81256. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81257. /**
  81258. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  81259. * @param vector defines the vector to transform
  81260. * @param transformation defines the matrix to apply
  81261. * @returns a new Vector2
  81262. */
  81263. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  81264. /**
  81265. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  81266. * @param vector defines the vector to transform
  81267. * @param transformation defines the matrix to apply
  81268. * @param result defines the target vector
  81269. */
  81270. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  81271. /**
  81272. * Determines if a given vector is included in a triangle
  81273. * @param p defines the vector to test
  81274. * @param p0 defines 1st triangle point
  81275. * @param p1 defines 2nd triangle point
  81276. * @param p2 defines 3rd triangle point
  81277. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  81278. */
  81279. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  81280. /**
  81281. * Gets the distance between the vectors "value1" and "value2"
  81282. * @param value1 defines first vector
  81283. * @param value2 defines second vector
  81284. * @returns the distance between vectors
  81285. */
  81286. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81287. /**
  81288. * Returns the squared distance between the vectors "value1" and "value2"
  81289. * @param value1 defines first vector
  81290. * @param value2 defines second vector
  81291. * @returns the squared distance between vectors
  81292. */
  81293. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81294. /**
  81295. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  81296. * @param value1 defines first vector
  81297. * @param value2 defines second vector
  81298. * @returns a new Vector2
  81299. */
  81300. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  81301. /**
  81302. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  81303. * @param p defines the middle point
  81304. * @param segA defines one point of the segment
  81305. * @param segB defines the other point of the segment
  81306. * @returns the shortest distance
  81307. */
  81308. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  81309. }
  81310. /**
  81311. * Class used to store (x,y,z) vector representation
  81312. * A Vector3 is the main object used in 3D geometry
  81313. * It can represent etiher the coordinates of a point the space, either a direction
  81314. * Reminder: js uses a left handed forward facing system
  81315. */
  81316. export class Vector3 {
  81317. private static _UpReadOnly;
  81318. private static _ZeroReadOnly;
  81319. /** @hidden */
  81320. _x: number;
  81321. /** @hidden */
  81322. _y: number;
  81323. /** @hidden */
  81324. _z: number;
  81325. /** @hidden */
  81326. _isDirty: boolean;
  81327. /** Gets or sets the x coordinate */
  81328. get x(): number;
  81329. set x(value: number);
  81330. /** Gets or sets the y coordinate */
  81331. get y(): number;
  81332. set y(value: number);
  81333. /** Gets or sets the z coordinate */
  81334. get z(): number;
  81335. set z(value: number);
  81336. /**
  81337. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81338. * @param x defines the first coordinates (on X axis)
  81339. * @param y defines the second coordinates (on Y axis)
  81340. * @param z defines the third coordinates (on Z axis)
  81341. */
  81342. constructor(x?: number, y?: number, z?: number);
  81343. /**
  81344. * Creates a string representation of the Vector3
  81345. * @returns a string with the Vector3 coordinates.
  81346. */
  81347. toString(): string;
  81348. /**
  81349. * Gets the class name
  81350. * @returns the string "Vector3"
  81351. */
  81352. getClassName(): string;
  81353. /**
  81354. * Creates the Vector3 hash code
  81355. * @returns a number which tends to be unique between Vector3 instances
  81356. */
  81357. getHashCode(): number;
  81358. /**
  81359. * Creates an array containing three elements : the coordinates of the Vector3
  81360. * @returns a new array of numbers
  81361. */
  81362. asArray(): number[];
  81363. /**
  81364. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81365. * @param array defines the destination array
  81366. * @param index defines the offset in the destination array
  81367. * @returns the current Vector3
  81368. */
  81369. toArray(array: FloatArray, index?: number): Vector3;
  81370. /**
  81371. * Update the current vector from an array
  81372. * @param array defines the destination array
  81373. * @param index defines the offset in the destination array
  81374. * @returns the current Vector3
  81375. */
  81376. fromArray(array: FloatArray, index?: number): Vector3;
  81377. /**
  81378. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81379. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81380. */
  81381. toQuaternion(): Quaternion;
  81382. /**
  81383. * Adds the given vector to the current Vector3
  81384. * @param otherVector defines the second operand
  81385. * @returns the current updated Vector3
  81386. */
  81387. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81388. /**
  81389. * Adds the given coordinates to the current Vector3
  81390. * @param x defines the x coordinate of the operand
  81391. * @param y defines the y coordinate of the operand
  81392. * @param z defines the z coordinate of the operand
  81393. * @returns the current updated Vector3
  81394. */
  81395. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81396. /**
  81397. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81398. * @param otherVector defines the second operand
  81399. * @returns the resulting Vector3
  81400. */
  81401. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81402. /**
  81403. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81404. * @param otherVector defines the second operand
  81405. * @param result defines the Vector3 object where to store the result
  81406. * @returns the current Vector3
  81407. */
  81408. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81409. /**
  81410. * Subtract the given vector from the current Vector3
  81411. * @param otherVector defines the second operand
  81412. * @returns the current updated Vector3
  81413. */
  81414. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81415. /**
  81416. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81417. * @param otherVector defines the second operand
  81418. * @returns the resulting Vector3
  81419. */
  81420. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81421. /**
  81422. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81423. * @param otherVector defines the second operand
  81424. * @param result defines the Vector3 object where to store the result
  81425. * @returns the current Vector3
  81426. */
  81427. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81428. /**
  81429. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81430. * @param x defines the x coordinate of the operand
  81431. * @param y defines the y coordinate of the operand
  81432. * @param z defines the z coordinate of the operand
  81433. * @returns the resulting Vector3
  81434. */
  81435. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81436. /**
  81437. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81438. * @param x defines the x coordinate of the operand
  81439. * @param y defines the y coordinate of the operand
  81440. * @param z defines the z coordinate of the operand
  81441. * @param result defines the Vector3 object where to store the result
  81442. * @returns the current Vector3
  81443. */
  81444. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81445. /**
  81446. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81447. * @returns a new Vector3
  81448. */
  81449. negate(): Vector3;
  81450. /**
  81451. * Negate this vector in place
  81452. * @returns this
  81453. */
  81454. negateInPlace(): Vector3;
  81455. /**
  81456. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81457. * @param result defines the Vector3 object where to store the result
  81458. * @returns the current Vector3
  81459. */
  81460. negateToRef(result: Vector3): Vector3;
  81461. /**
  81462. * Multiplies the Vector3 coordinates by the float "scale"
  81463. * @param scale defines the multiplier factor
  81464. * @returns the current updated Vector3
  81465. */
  81466. scaleInPlace(scale: number): Vector3;
  81467. /**
  81468. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81469. * @param scale defines the multiplier factor
  81470. * @returns a new Vector3
  81471. */
  81472. scale(scale: number): Vector3;
  81473. /**
  81474. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81475. * @param scale defines the multiplier factor
  81476. * @param result defines the Vector3 object where to store the result
  81477. * @returns the current Vector3
  81478. */
  81479. scaleToRef(scale: number, result: Vector3): Vector3;
  81480. /**
  81481. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81482. * @param scale defines the scale factor
  81483. * @param result defines the Vector3 object where to store the result
  81484. * @returns the unmodified current Vector3
  81485. */
  81486. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81487. /**
  81488. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81489. * @param origin defines the origin of the projection ray
  81490. * @param plane defines the plane to project to
  81491. * @returns the projected vector3
  81492. */
  81493. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81494. /**
  81495. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81496. * @param origin defines the origin of the projection ray
  81497. * @param plane defines the plane to project to
  81498. * @param result defines the Vector3 where to store the result
  81499. */
  81500. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81501. /**
  81502. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81503. * @param otherVector defines the second operand
  81504. * @returns true if both vectors are equals
  81505. */
  81506. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81507. /**
  81508. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81509. * @param otherVector defines the second operand
  81510. * @param epsilon defines the minimal distance to define values as equals
  81511. * @returns true if both vectors are distant less than epsilon
  81512. */
  81513. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81514. /**
  81515. * Returns true if the current Vector3 coordinates equals the given floats
  81516. * @param x defines the x coordinate of the operand
  81517. * @param y defines the y coordinate of the operand
  81518. * @param z defines the z coordinate of the operand
  81519. * @returns true if both vectors are equals
  81520. */
  81521. equalsToFloats(x: number, y: number, z: number): boolean;
  81522. /**
  81523. * Multiplies the current Vector3 coordinates by the given ones
  81524. * @param otherVector defines the second operand
  81525. * @returns the current updated Vector3
  81526. */
  81527. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81528. /**
  81529. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81530. * @param otherVector defines the second operand
  81531. * @returns the new Vector3
  81532. */
  81533. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81534. /**
  81535. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81536. * @param otherVector defines the second operand
  81537. * @param result defines the Vector3 object where to store the result
  81538. * @returns the current Vector3
  81539. */
  81540. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81541. /**
  81542. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81543. * @param x defines the x coordinate of the operand
  81544. * @param y defines the y coordinate of the operand
  81545. * @param z defines the z coordinate of the operand
  81546. * @returns the new Vector3
  81547. */
  81548. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81549. /**
  81550. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81551. * @param otherVector defines the second operand
  81552. * @returns the new Vector3
  81553. */
  81554. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81555. /**
  81556. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81557. * @param otherVector defines the second operand
  81558. * @param result defines the Vector3 object where to store the result
  81559. * @returns the current Vector3
  81560. */
  81561. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81562. /**
  81563. * Divides the current Vector3 coordinates by the given ones.
  81564. * @param otherVector defines the second operand
  81565. * @returns the current updated Vector3
  81566. */
  81567. divideInPlace(otherVector: Vector3): Vector3;
  81568. /**
  81569. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81570. * @param other defines the second operand
  81571. * @returns the current updated Vector3
  81572. */
  81573. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81574. /**
  81575. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81576. * @param other defines the second operand
  81577. * @returns the current updated Vector3
  81578. */
  81579. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81580. /**
  81581. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81582. * @param x defines the x coordinate of the operand
  81583. * @param y defines the y coordinate of the operand
  81584. * @param z defines the z coordinate of the operand
  81585. * @returns the current updated Vector3
  81586. */
  81587. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81588. /**
  81589. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81590. * @param x defines the x coordinate of the operand
  81591. * @param y defines the y coordinate of the operand
  81592. * @param z defines the z coordinate of the operand
  81593. * @returns the current updated Vector3
  81594. */
  81595. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81596. /**
  81597. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81598. * Check if is non uniform within a certain amount of decimal places to account for this
  81599. * @param epsilon the amount the values can differ
  81600. * @returns if the the vector is non uniform to a certain number of decimal places
  81601. */
  81602. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81603. /**
  81604. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81605. */
  81606. get isNonUniform(): boolean;
  81607. /**
  81608. * Gets a new Vector3 from current Vector3 floored values
  81609. * @returns a new Vector3
  81610. */
  81611. floor(): Vector3;
  81612. /**
  81613. * Gets a new Vector3 from current Vector3 floored values
  81614. * @returns a new Vector3
  81615. */
  81616. fract(): Vector3;
  81617. /**
  81618. * Gets the length of the Vector3
  81619. * @returns the length of the Vector3
  81620. */
  81621. length(): number;
  81622. /**
  81623. * Gets the squared length of the Vector3
  81624. * @returns squared length of the Vector3
  81625. */
  81626. lengthSquared(): number;
  81627. /**
  81628. * Normalize the current Vector3.
  81629. * Please note that this is an in place operation.
  81630. * @returns the current updated Vector3
  81631. */
  81632. normalize(): Vector3;
  81633. /**
  81634. * Reorders the x y z properties of the vector in place
  81635. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81636. * @returns the current updated vector
  81637. */
  81638. reorderInPlace(order: string): this;
  81639. /**
  81640. * Rotates the vector around 0,0,0 by a quaternion
  81641. * @param quaternion the rotation quaternion
  81642. * @param result vector to store the result
  81643. * @returns the resulting vector
  81644. */
  81645. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81646. /**
  81647. * Rotates a vector around a given point
  81648. * @param quaternion the rotation quaternion
  81649. * @param point the point to rotate around
  81650. * @param result vector to store the result
  81651. * @returns the resulting vector
  81652. */
  81653. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81654. /**
  81655. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81656. * The cross product is then orthogonal to both current and "other"
  81657. * @param other defines the right operand
  81658. * @returns the cross product
  81659. */
  81660. cross(other: Vector3): Vector3;
  81661. /**
  81662. * Normalize the current Vector3 with the given input length.
  81663. * Please note that this is an in place operation.
  81664. * @param len the length of the vector
  81665. * @returns the current updated Vector3
  81666. */
  81667. normalizeFromLength(len: number): Vector3;
  81668. /**
  81669. * Normalize the current Vector3 to a new vector
  81670. * @returns the new Vector3
  81671. */
  81672. normalizeToNew(): Vector3;
  81673. /**
  81674. * Normalize the current Vector3 to the reference
  81675. * @param reference define the Vector3 to update
  81676. * @returns the updated Vector3
  81677. */
  81678. normalizeToRef(reference: Vector3): Vector3;
  81679. /**
  81680. * Creates a new Vector3 copied from the current Vector3
  81681. * @returns the new Vector3
  81682. */
  81683. clone(): Vector3;
  81684. /**
  81685. * Copies the given vector coordinates to the current Vector3 ones
  81686. * @param source defines the source Vector3
  81687. * @returns the current updated Vector3
  81688. */
  81689. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81690. /**
  81691. * Copies the given floats to the current Vector3 coordinates
  81692. * @param x defines the x coordinate of the operand
  81693. * @param y defines the y coordinate of the operand
  81694. * @param z defines the z coordinate of the operand
  81695. * @returns the current updated Vector3
  81696. */
  81697. copyFromFloats(x: number, y: number, z: number): Vector3;
  81698. /**
  81699. * Copies the given floats to the current Vector3 coordinates
  81700. * @param x defines the x coordinate of the operand
  81701. * @param y defines the y coordinate of the operand
  81702. * @param z defines the z coordinate of the operand
  81703. * @returns the current updated Vector3
  81704. */
  81705. set(x: number, y: number, z: number): Vector3;
  81706. /**
  81707. * Copies the given float to the current Vector3 coordinates
  81708. * @param v defines the x, y and z coordinates of the operand
  81709. * @returns the current updated Vector3
  81710. */
  81711. setAll(v: number): Vector3;
  81712. /**
  81713. * Get the clip factor between two vectors
  81714. * @param vector0 defines the first operand
  81715. * @param vector1 defines the second operand
  81716. * @param axis defines the axis to use
  81717. * @param size defines the size along the axis
  81718. * @returns the clip factor
  81719. */
  81720. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81721. /**
  81722. * Get angle between two vectors
  81723. * @param vector0 angle between vector0 and vector1
  81724. * @param vector1 angle between vector0 and vector1
  81725. * @param normal direction of the normal
  81726. * @return the angle between vector0 and vector1
  81727. */
  81728. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81729. /**
  81730. * Returns a new Vector3 set from the index "offset" of the given array
  81731. * @param array defines the source array
  81732. * @param offset defines the offset in the source array
  81733. * @returns the new Vector3
  81734. */
  81735. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81736. /**
  81737. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81738. * @param array defines the source array
  81739. * @param offset defines the offset in the source array
  81740. * @returns the new Vector3
  81741. * @deprecated Please use FromArray instead.
  81742. */
  81743. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81744. /**
  81745. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81746. * @param array defines the source array
  81747. * @param offset defines the offset in the source array
  81748. * @param result defines the Vector3 where to store the result
  81749. */
  81750. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81751. /**
  81752. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81753. * @param array defines the source array
  81754. * @param offset defines the offset in the source array
  81755. * @param result defines the Vector3 where to store the result
  81756. * @deprecated Please use FromArrayToRef instead.
  81757. */
  81758. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81759. /**
  81760. * Sets the given vector "result" with the given floats.
  81761. * @param x defines the x coordinate of the source
  81762. * @param y defines the y coordinate of the source
  81763. * @param z defines the z coordinate of the source
  81764. * @param result defines the Vector3 where to store the result
  81765. */
  81766. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81767. /**
  81768. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81769. * @returns a new empty Vector3
  81770. */
  81771. static Zero(): Vector3;
  81772. /**
  81773. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81774. * @returns a new unit Vector3
  81775. */
  81776. static One(): Vector3;
  81777. /**
  81778. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81779. * @returns a new up Vector3
  81780. */
  81781. static Up(): Vector3;
  81782. /**
  81783. * Gets a up Vector3 that must not be updated
  81784. */
  81785. static get UpReadOnly(): DeepImmutable<Vector3>;
  81786. /**
  81787. * Gets a zero Vector3 that must not be updated
  81788. */
  81789. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81790. /**
  81791. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81792. * @returns a new down Vector3
  81793. */
  81794. static Down(): Vector3;
  81795. /**
  81796. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81797. * @param rightHandedSystem is the scene right-handed (negative z)
  81798. * @returns a new forward Vector3
  81799. */
  81800. static Forward(rightHandedSystem?: boolean): Vector3;
  81801. /**
  81802. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81803. * @param rightHandedSystem is the scene right-handed (negative-z)
  81804. * @returns a new forward Vector3
  81805. */
  81806. static Backward(rightHandedSystem?: boolean): Vector3;
  81807. /**
  81808. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81809. * @returns a new right Vector3
  81810. */
  81811. static Right(): Vector3;
  81812. /**
  81813. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81814. * @returns a new left Vector3
  81815. */
  81816. static Left(): Vector3;
  81817. /**
  81818. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81819. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81820. * @param vector defines the Vector3 to transform
  81821. * @param transformation defines the transformation matrix
  81822. * @returns the transformed Vector3
  81823. */
  81824. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81825. /**
  81826. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81827. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81828. * @param vector defines the Vector3 to transform
  81829. * @param transformation defines the transformation matrix
  81830. * @param result defines the Vector3 where to store the result
  81831. */
  81832. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81833. /**
  81834. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81835. * This method computes tranformed coordinates only, not transformed direction vectors
  81836. * @param x define the x coordinate of the source vector
  81837. * @param y define the y coordinate of the source vector
  81838. * @param z define the z coordinate of the source vector
  81839. * @param transformation defines the transformation matrix
  81840. * @param result defines the Vector3 where to store the result
  81841. */
  81842. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81843. /**
  81844. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81845. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81846. * @param vector defines the Vector3 to transform
  81847. * @param transformation defines the transformation matrix
  81848. * @returns the new Vector3
  81849. */
  81850. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81851. /**
  81852. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81853. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81854. * @param vector defines the Vector3 to transform
  81855. * @param transformation defines the transformation matrix
  81856. * @param result defines the Vector3 where to store the result
  81857. */
  81858. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81859. /**
  81860. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81861. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81862. * @param x define the x coordinate of the source vector
  81863. * @param y define the y coordinate of the source vector
  81864. * @param z define the z coordinate of the source vector
  81865. * @param transformation defines the transformation matrix
  81866. * @param result defines the Vector3 where to store the result
  81867. */
  81868. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81869. /**
  81870. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81871. * @param value1 defines the first control point
  81872. * @param value2 defines the second control point
  81873. * @param value3 defines the third control point
  81874. * @param value4 defines the fourth control point
  81875. * @param amount defines the amount on the spline to use
  81876. * @returns the new Vector3
  81877. */
  81878. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81879. /**
  81880. * 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"
  81881. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81882. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81883. * @param value defines the current value
  81884. * @param min defines the lower range value
  81885. * @param max defines the upper range value
  81886. * @returns the new Vector3
  81887. */
  81888. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81889. /**
  81890. * 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"
  81891. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81892. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81893. * @param value defines the current value
  81894. * @param min defines the lower range value
  81895. * @param max defines the upper range value
  81896. * @param result defines the Vector3 where to store the result
  81897. */
  81898. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81899. /**
  81900. * Checks if a given vector is inside a specific range
  81901. * @param v defines the vector to test
  81902. * @param min defines the minimum range
  81903. * @param max defines the maximum range
  81904. */
  81905. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81906. /**
  81907. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81908. * @param value1 defines the first control point
  81909. * @param tangent1 defines the first tangent vector
  81910. * @param value2 defines the second control point
  81911. * @param tangent2 defines the second tangent vector
  81912. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81913. * @returns the new Vector3
  81914. */
  81915. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81916. /**
  81917. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81918. * @param start defines the start value
  81919. * @param end defines the end value
  81920. * @param amount max defines amount between both (between 0 and 1)
  81921. * @returns the new Vector3
  81922. */
  81923. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81924. /**
  81925. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81926. * @param start defines the start value
  81927. * @param end defines the end value
  81928. * @param amount max defines amount between both (between 0 and 1)
  81929. * @param result defines the Vector3 where to store the result
  81930. */
  81931. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81932. /**
  81933. * Returns the dot product (float) between the vectors "left" and "right"
  81934. * @param left defines the left operand
  81935. * @param right defines the right operand
  81936. * @returns the dot product
  81937. */
  81938. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81939. /**
  81940. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81941. * The cross product is then orthogonal to both "left" and "right"
  81942. * @param left defines the left operand
  81943. * @param right defines the right operand
  81944. * @returns the cross product
  81945. */
  81946. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81947. /**
  81948. * Sets the given vector "result" with the cross product of "left" and "right"
  81949. * The cross product is then orthogonal to both "left" and "right"
  81950. * @param left defines the left operand
  81951. * @param right defines the right operand
  81952. * @param result defines the Vector3 where to store the result
  81953. */
  81954. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81955. /**
  81956. * Returns a new Vector3 as the normalization of the given vector
  81957. * @param vector defines the Vector3 to normalize
  81958. * @returns the new Vector3
  81959. */
  81960. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81961. /**
  81962. * Sets the given vector "result" with the normalization of the given first vector
  81963. * @param vector defines the Vector3 to normalize
  81964. * @param result defines the Vector3 where to store the result
  81965. */
  81966. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81967. /**
  81968. * Project a Vector3 onto screen space
  81969. * @param vector defines the Vector3 to project
  81970. * @param world defines the world matrix to use
  81971. * @param transform defines the transform (view x projection) matrix to use
  81972. * @param viewport defines the screen viewport to use
  81973. * @returns the new Vector3
  81974. */
  81975. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81976. /** @hidden */
  81977. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81978. /**
  81979. * Unproject from screen space to object space
  81980. * @param source defines the screen space Vector3 to use
  81981. * @param viewportWidth defines the current width of the viewport
  81982. * @param viewportHeight defines the current height of the viewport
  81983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81984. * @param transform defines the transform (view x projection) matrix to use
  81985. * @returns the new Vector3
  81986. */
  81987. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81988. /**
  81989. * Unproject from screen space to object space
  81990. * @param source defines the screen space Vector3 to use
  81991. * @param viewportWidth defines the current width of the viewport
  81992. * @param viewportHeight defines the current height of the viewport
  81993. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81994. * @param view defines the view matrix to use
  81995. * @param projection defines the projection matrix to use
  81996. * @returns the new Vector3
  81997. */
  81998. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81999. /**
  82000. * Unproject from screen space to object space
  82001. * @param source defines the screen space Vector3 to use
  82002. * @param viewportWidth defines the current width of the viewport
  82003. * @param viewportHeight defines the current height of the viewport
  82004. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82005. * @param view defines the view matrix to use
  82006. * @param projection defines the projection matrix to use
  82007. * @param result defines the Vector3 where to store the result
  82008. */
  82009. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82010. /**
  82011. * Unproject from screen space to object space
  82012. * @param sourceX defines the screen space x coordinate to use
  82013. * @param sourceY defines the screen space y coordinate to use
  82014. * @param sourceZ defines the screen space z coordinate to use
  82015. * @param viewportWidth defines the current width of the viewport
  82016. * @param viewportHeight defines the current height of the viewport
  82017. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82018. * @param view defines the view matrix to use
  82019. * @param projection defines the projection matrix to use
  82020. * @param result defines the Vector3 where to store the result
  82021. */
  82022. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82023. /**
  82024. * Gets the minimal coordinate values between two Vector3
  82025. * @param left defines the first operand
  82026. * @param right defines the second operand
  82027. * @returns the new Vector3
  82028. */
  82029. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82030. /**
  82031. * Gets the maximal coordinate values between two Vector3
  82032. * @param left defines the first operand
  82033. * @param right defines the second operand
  82034. * @returns the new Vector3
  82035. */
  82036. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82037. /**
  82038. * Returns the distance between the vectors "value1" and "value2"
  82039. * @param value1 defines the first operand
  82040. * @param value2 defines the second operand
  82041. * @returns the distance
  82042. */
  82043. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82044. /**
  82045. * Returns the squared distance between the vectors "value1" and "value2"
  82046. * @param value1 defines the first operand
  82047. * @param value2 defines the second operand
  82048. * @returns the squared distance
  82049. */
  82050. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82051. /**
  82052. * Returns a new Vector3 located at the center between "value1" and "value2"
  82053. * @param value1 defines the first operand
  82054. * @param value2 defines the second operand
  82055. * @returns the new Vector3
  82056. */
  82057. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82058. /**
  82059. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82060. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82061. * to something in order to rotate it from its local system to the given target system
  82062. * Note: axis1, axis2 and axis3 are normalized during this operation
  82063. * @param axis1 defines the first axis
  82064. * @param axis2 defines the second axis
  82065. * @param axis3 defines the third axis
  82066. * @returns a new Vector3
  82067. */
  82068. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82069. /**
  82070. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82071. * @param axis1 defines the first axis
  82072. * @param axis2 defines the second axis
  82073. * @param axis3 defines the third axis
  82074. * @param ref defines the Vector3 where to store the result
  82075. */
  82076. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82077. }
  82078. /**
  82079. * Vector4 class created for EulerAngle class conversion to Quaternion
  82080. */
  82081. export class Vector4 {
  82082. /** x value of the vector */
  82083. x: number;
  82084. /** y value of the vector */
  82085. y: number;
  82086. /** z value of the vector */
  82087. z: number;
  82088. /** w value of the vector */
  82089. w: number;
  82090. /**
  82091. * Creates a Vector4 object from the given floats.
  82092. * @param x x value of the vector
  82093. * @param y y value of the vector
  82094. * @param z z value of the vector
  82095. * @param w w value of the vector
  82096. */
  82097. constructor(
  82098. /** x value of the vector */
  82099. x: number,
  82100. /** y value of the vector */
  82101. y: number,
  82102. /** z value of the vector */
  82103. z: number,
  82104. /** w value of the vector */
  82105. w: number);
  82106. /**
  82107. * Returns the string with the Vector4 coordinates.
  82108. * @returns a string containing all the vector values
  82109. */
  82110. toString(): string;
  82111. /**
  82112. * Returns the string "Vector4".
  82113. * @returns "Vector4"
  82114. */
  82115. getClassName(): string;
  82116. /**
  82117. * Returns the Vector4 hash code.
  82118. * @returns a unique hash code
  82119. */
  82120. getHashCode(): number;
  82121. /**
  82122. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82123. * @returns the resulting array
  82124. */
  82125. asArray(): number[];
  82126. /**
  82127. * Populates the given array from the given index with the Vector4 coordinates.
  82128. * @param array array to populate
  82129. * @param index index of the array to start at (default: 0)
  82130. * @returns the Vector4.
  82131. */
  82132. toArray(array: FloatArray, index?: number): Vector4;
  82133. /**
  82134. * Update the current vector from an array
  82135. * @param array defines the destination array
  82136. * @param index defines the offset in the destination array
  82137. * @returns the current Vector3
  82138. */
  82139. fromArray(array: FloatArray, index?: number): Vector4;
  82140. /**
  82141. * Adds the given vector to the current Vector4.
  82142. * @param otherVector the vector to add
  82143. * @returns the updated Vector4.
  82144. */
  82145. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82146. /**
  82147. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82148. * @param otherVector the vector to add
  82149. * @returns the resulting vector
  82150. */
  82151. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82152. /**
  82153. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82154. * @param otherVector the vector to add
  82155. * @param result the vector to store the result
  82156. * @returns the current Vector4.
  82157. */
  82158. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82159. /**
  82160. * Subtract in place the given vector from the current Vector4.
  82161. * @param otherVector the vector to subtract
  82162. * @returns the updated Vector4.
  82163. */
  82164. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82165. /**
  82166. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82167. * @param otherVector the vector to add
  82168. * @returns the new vector with the result
  82169. */
  82170. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82171. /**
  82172. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82173. * @param otherVector the vector to subtract
  82174. * @param result the vector to store the result
  82175. * @returns the current Vector4.
  82176. */
  82177. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82178. /**
  82179. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82180. */
  82181. /**
  82182. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82183. * @param x value to subtract
  82184. * @param y value to subtract
  82185. * @param z value to subtract
  82186. * @param w value to subtract
  82187. * @returns new vector containing the result
  82188. */
  82189. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82190. /**
  82191. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82192. * @param x value to subtract
  82193. * @param y value to subtract
  82194. * @param z value to subtract
  82195. * @param w value to subtract
  82196. * @param result the vector to store the result in
  82197. * @returns the current Vector4.
  82198. */
  82199. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82200. /**
  82201. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82202. * @returns a new vector with the negated values
  82203. */
  82204. negate(): Vector4;
  82205. /**
  82206. * Negate this vector in place
  82207. * @returns this
  82208. */
  82209. negateInPlace(): Vector4;
  82210. /**
  82211. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82212. * @param result defines the Vector3 object where to store the result
  82213. * @returns the current Vector4
  82214. */
  82215. negateToRef(result: Vector4): Vector4;
  82216. /**
  82217. * Multiplies the current Vector4 coordinates by scale (float).
  82218. * @param scale the number to scale with
  82219. * @returns the updated Vector4.
  82220. */
  82221. scaleInPlace(scale: number): Vector4;
  82222. /**
  82223. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82224. * @param scale the number to scale with
  82225. * @returns a new vector with the result
  82226. */
  82227. scale(scale: number): Vector4;
  82228. /**
  82229. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82230. * @param scale the number to scale with
  82231. * @param result a vector to store the result in
  82232. * @returns the current Vector4.
  82233. */
  82234. scaleToRef(scale: number, result: Vector4): Vector4;
  82235. /**
  82236. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82237. * @param scale defines the scale factor
  82238. * @param result defines the Vector4 object where to store the result
  82239. * @returns the unmodified current Vector4
  82240. */
  82241. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82242. /**
  82243. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82244. * @param otherVector the vector to compare against
  82245. * @returns true if they are equal
  82246. */
  82247. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82248. /**
  82249. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  82250. * @param otherVector vector to compare against
  82251. * @param epsilon (Default: very small number)
  82252. * @returns true if they are equal
  82253. */
  82254. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  82255. /**
  82256. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  82257. * @param x x value to compare against
  82258. * @param y y value to compare against
  82259. * @param z z value to compare against
  82260. * @param w w value to compare against
  82261. * @returns true if equal
  82262. */
  82263. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  82264. /**
  82265. * Multiplies in place the current Vector4 by the given one.
  82266. * @param otherVector vector to multiple with
  82267. * @returns the updated Vector4.
  82268. */
  82269. multiplyInPlace(otherVector: Vector4): Vector4;
  82270. /**
  82271. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  82272. * @param otherVector vector to multiple with
  82273. * @returns resulting new vector
  82274. */
  82275. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  82276. /**
  82277. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  82278. * @param otherVector vector to multiple with
  82279. * @param result vector to store the result
  82280. * @returns the current Vector4.
  82281. */
  82282. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82283. /**
  82284. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  82285. * @param x x value multiply with
  82286. * @param y y value multiply with
  82287. * @param z z value multiply with
  82288. * @param w w value multiply with
  82289. * @returns resulting new vector
  82290. */
  82291. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  82292. /**
  82293. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  82294. * @param otherVector vector to devide with
  82295. * @returns resulting new vector
  82296. */
  82297. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  82298. /**
  82299. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  82300. * @param otherVector vector to devide with
  82301. * @param result vector to store the result
  82302. * @returns the current Vector4.
  82303. */
  82304. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82305. /**
  82306. * Divides the current Vector3 coordinates by the given ones.
  82307. * @param otherVector vector to devide with
  82308. * @returns the updated Vector3.
  82309. */
  82310. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82311. /**
  82312. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  82313. * @param other defines the second operand
  82314. * @returns the current updated Vector4
  82315. */
  82316. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82317. /**
  82318. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  82319. * @param other defines the second operand
  82320. * @returns the current updated Vector4
  82321. */
  82322. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82323. /**
  82324. * Gets a new Vector4 from current Vector4 floored values
  82325. * @returns a new Vector4
  82326. */
  82327. floor(): Vector4;
  82328. /**
  82329. * Gets a new Vector4 from current Vector3 floored values
  82330. * @returns a new Vector4
  82331. */
  82332. fract(): Vector4;
  82333. /**
  82334. * Returns the Vector4 length (float).
  82335. * @returns the length
  82336. */
  82337. length(): number;
  82338. /**
  82339. * Returns the Vector4 squared length (float).
  82340. * @returns the length squared
  82341. */
  82342. lengthSquared(): number;
  82343. /**
  82344. * Normalizes in place the Vector4.
  82345. * @returns the updated Vector4.
  82346. */
  82347. normalize(): Vector4;
  82348. /**
  82349. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82350. * @returns this converted to a new vector3
  82351. */
  82352. toVector3(): Vector3;
  82353. /**
  82354. * Returns a new Vector4 copied from the current one.
  82355. * @returns the new cloned vector
  82356. */
  82357. clone(): Vector4;
  82358. /**
  82359. * Updates the current Vector4 with the given one coordinates.
  82360. * @param source the source vector to copy from
  82361. * @returns the updated Vector4.
  82362. */
  82363. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82364. /**
  82365. * Updates the current Vector4 coordinates with the given floats.
  82366. * @param x float to copy from
  82367. * @param y float to copy from
  82368. * @param z float to copy from
  82369. * @param w float to copy from
  82370. * @returns the updated Vector4.
  82371. */
  82372. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82373. /**
  82374. * Updates the current Vector4 coordinates with the given floats.
  82375. * @param x float to set from
  82376. * @param y float to set from
  82377. * @param z float to set from
  82378. * @param w float to set from
  82379. * @returns the updated Vector4.
  82380. */
  82381. set(x: number, y: number, z: number, w: number): Vector4;
  82382. /**
  82383. * Copies the given float to the current Vector3 coordinates
  82384. * @param v defines the x, y, z and w coordinates of the operand
  82385. * @returns the current updated Vector3
  82386. */
  82387. setAll(v: number): Vector4;
  82388. /**
  82389. * Returns a new Vector4 set from the starting index of the given array.
  82390. * @param array the array to pull values from
  82391. * @param offset the offset into the array to start at
  82392. * @returns the new vector
  82393. */
  82394. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82395. /**
  82396. * Updates the given vector "result" from the starting index of the given array.
  82397. * @param array the array to pull values from
  82398. * @param offset the offset into the array to start at
  82399. * @param result the vector to store the result in
  82400. */
  82401. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82402. /**
  82403. * Updates the given vector "result" from the starting index of the given Float32Array.
  82404. * @param array the array to pull values from
  82405. * @param offset the offset into the array to start at
  82406. * @param result the vector to store the result in
  82407. */
  82408. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82409. /**
  82410. * Updates the given vector "result" coordinates from the given floats.
  82411. * @param x float to set from
  82412. * @param y float to set from
  82413. * @param z float to set from
  82414. * @param w float to set from
  82415. * @param result the vector to the floats in
  82416. */
  82417. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82418. /**
  82419. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82420. * @returns the new vector
  82421. */
  82422. static Zero(): Vector4;
  82423. /**
  82424. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82425. * @returns the new vector
  82426. */
  82427. static One(): Vector4;
  82428. /**
  82429. * Returns a new normalized Vector4 from the given one.
  82430. * @param vector the vector to normalize
  82431. * @returns the vector
  82432. */
  82433. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82434. /**
  82435. * Updates the given vector "result" from the normalization of the given one.
  82436. * @param vector the vector to normalize
  82437. * @param result the vector to store the result in
  82438. */
  82439. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82440. /**
  82441. * Returns a vector with the minimum values from the left and right vectors
  82442. * @param left left vector to minimize
  82443. * @param right right vector to minimize
  82444. * @returns a new vector with the minimum of the left and right vector values
  82445. */
  82446. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82447. /**
  82448. * Returns a vector with the maximum values from the left and right vectors
  82449. * @param left left vector to maximize
  82450. * @param right right vector to maximize
  82451. * @returns a new vector with the maximum of the left and right vector values
  82452. */
  82453. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82454. /**
  82455. * Returns the distance (float) between the vectors "value1" and "value2".
  82456. * @param value1 value to calulate the distance between
  82457. * @param value2 value to calulate the distance between
  82458. * @return the distance between the two vectors
  82459. */
  82460. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82461. /**
  82462. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82463. * @param value1 value to calulate the distance between
  82464. * @param value2 value to calulate the distance between
  82465. * @return the distance between the two vectors squared
  82466. */
  82467. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82468. /**
  82469. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82470. * @param value1 value to calulate the center between
  82471. * @param value2 value to calulate the center between
  82472. * @return the center between the two vectors
  82473. */
  82474. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82475. /**
  82476. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82477. * This methods computes transformed normalized direction vectors only.
  82478. * @param vector the vector to transform
  82479. * @param transformation the transformation matrix to apply
  82480. * @returns the new vector
  82481. */
  82482. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82483. /**
  82484. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82485. * This methods computes transformed normalized direction vectors only.
  82486. * @param vector the vector to transform
  82487. * @param transformation the transformation matrix to apply
  82488. * @param result the vector to store the result in
  82489. */
  82490. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82491. /**
  82492. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82493. * This methods computes transformed normalized direction vectors only.
  82494. * @param x value to transform
  82495. * @param y value to transform
  82496. * @param z value to transform
  82497. * @param w value to transform
  82498. * @param transformation the transformation matrix to apply
  82499. * @param result the vector to store the results in
  82500. */
  82501. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82502. /**
  82503. * Creates a new Vector4 from a Vector3
  82504. * @param source defines the source data
  82505. * @param w defines the 4th component (default is 0)
  82506. * @returns a new Vector4
  82507. */
  82508. static FromVector3(source: Vector3, w?: number): Vector4;
  82509. }
  82510. /**
  82511. * Class used to store quaternion data
  82512. * @see https://en.wikipedia.org/wiki/Quaternion
  82513. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82514. */
  82515. export class Quaternion {
  82516. /** @hidden */
  82517. _x: number;
  82518. /** @hidden */
  82519. _y: number;
  82520. /** @hidden */
  82521. _z: number;
  82522. /** @hidden */
  82523. _w: number;
  82524. /** @hidden */
  82525. _isDirty: boolean;
  82526. /** Gets or sets the x coordinate */
  82527. get x(): number;
  82528. set x(value: number);
  82529. /** Gets or sets the y coordinate */
  82530. get y(): number;
  82531. set y(value: number);
  82532. /** Gets or sets the z coordinate */
  82533. get z(): number;
  82534. set z(value: number);
  82535. /** Gets or sets the w coordinate */
  82536. get w(): number;
  82537. set w(value: number);
  82538. /**
  82539. * Creates a new Quaternion from the given floats
  82540. * @param x defines the first component (0 by default)
  82541. * @param y defines the second component (0 by default)
  82542. * @param z defines the third component (0 by default)
  82543. * @param w defines the fourth component (1.0 by default)
  82544. */
  82545. constructor(x?: number, y?: number, z?: number, w?: number);
  82546. /**
  82547. * Gets a string representation for the current quaternion
  82548. * @returns a string with the Quaternion coordinates
  82549. */
  82550. toString(): string;
  82551. /**
  82552. * Gets the class name of the quaternion
  82553. * @returns the string "Quaternion"
  82554. */
  82555. getClassName(): string;
  82556. /**
  82557. * Gets a hash code for this quaternion
  82558. * @returns the quaternion hash code
  82559. */
  82560. getHashCode(): number;
  82561. /**
  82562. * Copy the quaternion to an array
  82563. * @returns a new array populated with 4 elements from the quaternion coordinates
  82564. */
  82565. asArray(): number[];
  82566. /**
  82567. * Check if two quaternions are equals
  82568. * @param otherQuaternion defines the second operand
  82569. * @return true if the current quaternion and the given one coordinates are strictly equals
  82570. */
  82571. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82572. /**
  82573. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82574. * @param otherQuaternion defines the other quaternion
  82575. * @param epsilon defines the minimal distance to consider equality
  82576. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82577. */
  82578. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82579. /**
  82580. * Clone the current quaternion
  82581. * @returns a new quaternion copied from the current one
  82582. */
  82583. clone(): Quaternion;
  82584. /**
  82585. * Copy a quaternion to the current one
  82586. * @param other defines the other quaternion
  82587. * @returns the updated current quaternion
  82588. */
  82589. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82590. /**
  82591. * Updates the current quaternion with the given float coordinates
  82592. * @param x defines the x coordinate
  82593. * @param y defines the y coordinate
  82594. * @param z defines the z coordinate
  82595. * @param w defines the w coordinate
  82596. * @returns the updated current quaternion
  82597. */
  82598. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82599. /**
  82600. * Updates the current quaternion from the given float coordinates
  82601. * @param x defines the x coordinate
  82602. * @param y defines the y coordinate
  82603. * @param z defines the z coordinate
  82604. * @param w defines the w coordinate
  82605. * @returns the updated current quaternion
  82606. */
  82607. set(x: number, y: number, z: number, w: number): Quaternion;
  82608. /**
  82609. * Adds two quaternions
  82610. * @param other defines the second operand
  82611. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82612. */
  82613. add(other: DeepImmutable<Quaternion>): Quaternion;
  82614. /**
  82615. * Add a quaternion to the current one
  82616. * @param other defines the quaternion to add
  82617. * @returns the current quaternion
  82618. */
  82619. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82620. /**
  82621. * Subtract two quaternions
  82622. * @param other defines the second operand
  82623. * @returns a new quaternion as the subtraction result of the given one from the current one
  82624. */
  82625. subtract(other: Quaternion): Quaternion;
  82626. /**
  82627. * Multiplies the current quaternion by a scale factor
  82628. * @param value defines the scale factor
  82629. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82630. */
  82631. scale(value: number): Quaternion;
  82632. /**
  82633. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82634. * @param scale defines the scale factor
  82635. * @param result defines the Quaternion object where to store the result
  82636. * @returns the unmodified current quaternion
  82637. */
  82638. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82639. /**
  82640. * Multiplies in place the current quaternion by a scale factor
  82641. * @param value defines the scale factor
  82642. * @returns the current modified quaternion
  82643. */
  82644. scaleInPlace(value: number): Quaternion;
  82645. /**
  82646. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82647. * @param scale defines the scale factor
  82648. * @param result defines the Quaternion object where to store the result
  82649. * @returns the unmodified current quaternion
  82650. */
  82651. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82652. /**
  82653. * Multiplies two quaternions
  82654. * @param q1 defines the second operand
  82655. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82656. */
  82657. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82658. /**
  82659. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82660. * @param q1 defines the second operand
  82661. * @param result defines the target quaternion
  82662. * @returns the current quaternion
  82663. */
  82664. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82665. /**
  82666. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82667. * @param q1 defines the second operand
  82668. * @returns the currentupdated quaternion
  82669. */
  82670. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82671. /**
  82672. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82673. * @param ref defines the target quaternion
  82674. * @returns the current quaternion
  82675. */
  82676. conjugateToRef(ref: Quaternion): Quaternion;
  82677. /**
  82678. * Conjugates in place (1-q) the current quaternion
  82679. * @returns the current updated quaternion
  82680. */
  82681. conjugateInPlace(): Quaternion;
  82682. /**
  82683. * Conjugates in place (1-q) the current quaternion
  82684. * @returns a new quaternion
  82685. */
  82686. conjugate(): Quaternion;
  82687. /**
  82688. * Gets length of current quaternion
  82689. * @returns the quaternion length (float)
  82690. */
  82691. length(): number;
  82692. /**
  82693. * Normalize in place the current quaternion
  82694. * @returns the current updated quaternion
  82695. */
  82696. normalize(): Quaternion;
  82697. /**
  82698. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82699. * @param order is a reserved parameter and is ignore for now
  82700. * @returns a new Vector3 containing the Euler angles
  82701. */
  82702. toEulerAngles(order?: string): Vector3;
  82703. /**
  82704. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82705. * @param result defines the vector which will be filled with the Euler angles
  82706. * @param order is a reserved parameter and is ignore for now
  82707. * @returns the current unchanged quaternion
  82708. */
  82709. toEulerAnglesToRef(result: Vector3): Quaternion;
  82710. /**
  82711. * Updates the given rotation matrix with the current quaternion values
  82712. * @param result defines the target matrix
  82713. * @returns the current unchanged quaternion
  82714. */
  82715. toRotationMatrix(result: Matrix): Quaternion;
  82716. /**
  82717. * Updates the current quaternion from the given rotation matrix values
  82718. * @param matrix defines the source matrix
  82719. * @returns the current updated quaternion
  82720. */
  82721. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82722. /**
  82723. * Creates a new quaternion from a rotation matrix
  82724. * @param matrix defines the source matrix
  82725. * @returns a new quaternion created from the given rotation matrix values
  82726. */
  82727. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82728. /**
  82729. * Updates the given quaternion with the given rotation matrix values
  82730. * @param matrix defines the source matrix
  82731. * @param result defines the target quaternion
  82732. */
  82733. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82734. /**
  82735. * Returns the dot product (float) between the quaternions "left" and "right"
  82736. * @param left defines the left operand
  82737. * @param right defines the right operand
  82738. * @returns the dot product
  82739. */
  82740. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82741. /**
  82742. * Checks if the two quaternions are close to each other
  82743. * @param quat0 defines the first quaternion to check
  82744. * @param quat1 defines the second quaternion to check
  82745. * @returns true if the two quaternions are close to each other
  82746. */
  82747. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82748. /**
  82749. * Creates an empty quaternion
  82750. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82751. */
  82752. static Zero(): Quaternion;
  82753. /**
  82754. * Inverse a given quaternion
  82755. * @param q defines the source quaternion
  82756. * @returns a new quaternion as the inverted current quaternion
  82757. */
  82758. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82759. /**
  82760. * Inverse a given quaternion
  82761. * @param q defines the source quaternion
  82762. * @param result the quaternion the result will be stored in
  82763. * @returns the result quaternion
  82764. */
  82765. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82766. /**
  82767. * Creates an identity quaternion
  82768. * @returns the identity quaternion
  82769. */
  82770. static Identity(): Quaternion;
  82771. /**
  82772. * Gets a boolean indicating if the given quaternion is identity
  82773. * @param quaternion defines the quaternion to check
  82774. * @returns true if the quaternion is identity
  82775. */
  82776. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82777. /**
  82778. * Creates a quaternion from a rotation around an axis
  82779. * @param axis defines the axis to use
  82780. * @param angle defines the angle to use
  82781. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82782. */
  82783. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82784. /**
  82785. * Creates a rotation around an axis and stores it into the given quaternion
  82786. * @param axis defines the axis to use
  82787. * @param angle defines the angle to use
  82788. * @param result defines the target quaternion
  82789. * @returns the target quaternion
  82790. */
  82791. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82792. /**
  82793. * Creates a new quaternion from data stored into an array
  82794. * @param array defines the data source
  82795. * @param offset defines the offset in the source array where the data starts
  82796. * @returns a new quaternion
  82797. */
  82798. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82799. /**
  82800. * Updates the given quaternion "result" from the starting index of the given array.
  82801. * @param array the array to pull values from
  82802. * @param offset the offset into the array to start at
  82803. * @param result the quaternion to store the result in
  82804. */
  82805. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82806. /**
  82807. * Create a quaternion from Euler rotation angles
  82808. * @param x Pitch
  82809. * @param y Yaw
  82810. * @param z Roll
  82811. * @returns the new Quaternion
  82812. */
  82813. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82814. /**
  82815. * Updates a quaternion from Euler rotation angles
  82816. * @param x Pitch
  82817. * @param y Yaw
  82818. * @param z Roll
  82819. * @param result the quaternion to store the result
  82820. * @returns the updated quaternion
  82821. */
  82822. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82823. /**
  82824. * Create a quaternion from Euler rotation vector
  82825. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82826. * @returns the new Quaternion
  82827. */
  82828. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82829. /**
  82830. * Updates a quaternion from Euler rotation vector
  82831. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82832. * @param result the quaternion to store the result
  82833. * @returns the updated quaternion
  82834. */
  82835. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82836. /**
  82837. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82838. * @param yaw defines the rotation around Y axis
  82839. * @param pitch defines the rotation around X axis
  82840. * @param roll defines the rotation around Z axis
  82841. * @returns the new quaternion
  82842. */
  82843. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82844. /**
  82845. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82846. * @param yaw defines the rotation around Y axis
  82847. * @param pitch defines the rotation around X axis
  82848. * @param roll defines the rotation around Z axis
  82849. * @param result defines the target quaternion
  82850. */
  82851. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82852. /**
  82853. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82854. * @param alpha defines the rotation around first axis
  82855. * @param beta defines the rotation around second axis
  82856. * @param gamma defines the rotation around third axis
  82857. * @returns the new quaternion
  82858. */
  82859. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82860. /**
  82861. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82862. * @param alpha defines the rotation around first axis
  82863. * @param beta defines the rotation around second axis
  82864. * @param gamma defines the rotation around third axis
  82865. * @param result defines the target quaternion
  82866. */
  82867. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82868. /**
  82869. * 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)
  82870. * @param axis1 defines the first axis
  82871. * @param axis2 defines the second axis
  82872. * @param axis3 defines the third axis
  82873. * @returns the new quaternion
  82874. */
  82875. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82876. /**
  82877. * 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
  82878. * @param axis1 defines the first axis
  82879. * @param axis2 defines the second axis
  82880. * @param axis3 defines the third axis
  82881. * @param ref defines the target quaternion
  82882. */
  82883. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82884. /**
  82885. * Interpolates between two quaternions
  82886. * @param left defines first quaternion
  82887. * @param right defines second quaternion
  82888. * @param amount defines the gradient to use
  82889. * @returns the new interpolated quaternion
  82890. */
  82891. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82892. /**
  82893. * Interpolates between two quaternions and stores it into a target quaternion
  82894. * @param left defines first quaternion
  82895. * @param right defines second quaternion
  82896. * @param amount defines the gradient to use
  82897. * @param result defines the target quaternion
  82898. */
  82899. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82900. /**
  82901. * Interpolate between two quaternions using Hermite interpolation
  82902. * @param value1 defines first quaternion
  82903. * @param tangent1 defines the incoming tangent
  82904. * @param value2 defines second quaternion
  82905. * @param tangent2 defines the outgoing tangent
  82906. * @param amount defines the target quaternion
  82907. * @returns the new interpolated quaternion
  82908. */
  82909. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82910. }
  82911. /**
  82912. * Class used to store matrix data (4x4)
  82913. */
  82914. export class Matrix {
  82915. /**
  82916. * Gets the precision of matrix computations
  82917. */
  82918. static get Use64Bits(): boolean;
  82919. private static _updateFlagSeed;
  82920. private static _identityReadOnly;
  82921. private _isIdentity;
  82922. private _isIdentityDirty;
  82923. private _isIdentity3x2;
  82924. private _isIdentity3x2Dirty;
  82925. /**
  82926. * Gets the update flag of the matrix which is an unique number for the matrix.
  82927. * It will be incremented every time the matrix data change.
  82928. * You can use it to speed the comparison between two versions of the same matrix.
  82929. */
  82930. updateFlag: number;
  82931. private readonly _m;
  82932. /**
  82933. * Gets the internal data of the matrix
  82934. */
  82935. get m(): DeepImmutable<Float32Array | Array<number>>;
  82936. /** @hidden */
  82937. _markAsUpdated(): void;
  82938. /** @hidden */
  82939. private _updateIdentityStatus;
  82940. /**
  82941. * Creates an empty matrix (filled with zeros)
  82942. */
  82943. constructor();
  82944. /**
  82945. * Check if the current matrix is identity
  82946. * @returns true is the matrix is the identity matrix
  82947. */
  82948. isIdentity(): boolean;
  82949. /**
  82950. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82951. * @returns true is the matrix is the identity matrix
  82952. */
  82953. isIdentityAs3x2(): boolean;
  82954. /**
  82955. * Gets the determinant of the matrix
  82956. * @returns the matrix determinant
  82957. */
  82958. determinant(): number;
  82959. /**
  82960. * Returns the matrix as a Float32Array or Array<number>
  82961. * @returns the matrix underlying array
  82962. */
  82963. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82964. /**
  82965. * Returns the matrix as a Float32Array or Array<number>
  82966. * @returns the matrix underlying array.
  82967. */
  82968. asArray(): DeepImmutable<Float32Array | Array<number>>;
  82969. /**
  82970. * Inverts the current matrix in place
  82971. * @returns the current inverted matrix
  82972. */
  82973. invert(): Matrix;
  82974. /**
  82975. * Sets all the matrix elements to zero
  82976. * @returns the current matrix
  82977. */
  82978. reset(): Matrix;
  82979. /**
  82980. * Adds the current matrix with a second one
  82981. * @param other defines the matrix to add
  82982. * @returns a new matrix as the addition of the current matrix and the given one
  82983. */
  82984. add(other: DeepImmutable<Matrix>): Matrix;
  82985. /**
  82986. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82987. * @param other defines the matrix to add
  82988. * @param result defines the target matrix
  82989. * @returns the current matrix
  82990. */
  82991. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82992. /**
  82993. * Adds in place the given matrix to the current matrix
  82994. * @param other defines the second operand
  82995. * @returns the current updated matrix
  82996. */
  82997. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82998. /**
  82999. * Sets the given matrix to the current inverted Matrix
  83000. * @param other defines the target matrix
  83001. * @returns the unmodified current matrix
  83002. */
  83003. invertToRef(other: Matrix): Matrix;
  83004. /**
  83005. * add a value at the specified position in the current Matrix
  83006. * @param index the index of the value within the matrix. between 0 and 15.
  83007. * @param value the value to be added
  83008. * @returns the current updated matrix
  83009. */
  83010. addAtIndex(index: number, value: number): Matrix;
  83011. /**
  83012. * mutiply the specified position in the current Matrix by a value
  83013. * @param index the index of the value within the matrix. between 0 and 15.
  83014. * @param value the value to be added
  83015. * @returns the current updated matrix
  83016. */
  83017. multiplyAtIndex(index: number, value: number): Matrix;
  83018. /**
  83019. * Inserts the translation vector (using 3 floats) in the current matrix
  83020. * @param x defines the 1st component of the translation
  83021. * @param y defines the 2nd component of the translation
  83022. * @param z defines the 3rd component of the translation
  83023. * @returns the current updated matrix
  83024. */
  83025. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83026. /**
  83027. * Adds the translation vector (using 3 floats) in the current matrix
  83028. * @param x defines the 1st component of the translation
  83029. * @param y defines the 2nd component of the translation
  83030. * @param z defines the 3rd component of the translation
  83031. * @returns the current updated matrix
  83032. */
  83033. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83034. /**
  83035. * Inserts the translation vector in the current matrix
  83036. * @param vector3 defines the translation to insert
  83037. * @returns the current updated matrix
  83038. */
  83039. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83040. /**
  83041. * Gets the translation value of the current matrix
  83042. * @returns a new Vector3 as the extracted translation from the matrix
  83043. */
  83044. getTranslation(): Vector3;
  83045. /**
  83046. * Fill a Vector3 with the extracted translation from the matrix
  83047. * @param result defines the Vector3 where to store the translation
  83048. * @returns the current matrix
  83049. */
  83050. getTranslationToRef(result: Vector3): Matrix;
  83051. /**
  83052. * Remove rotation and scaling part from the matrix
  83053. * @returns the updated matrix
  83054. */
  83055. removeRotationAndScaling(): Matrix;
  83056. /**
  83057. * Multiply two matrices
  83058. * @param other defines the second operand
  83059. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83060. */
  83061. multiply(other: DeepImmutable<Matrix>): Matrix;
  83062. /**
  83063. * Copy the current matrix from the given one
  83064. * @param other defines the source matrix
  83065. * @returns the current updated matrix
  83066. */
  83067. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83068. /**
  83069. * Populates the given array from the starting index with the current matrix values
  83070. * @param array defines the target array
  83071. * @param offset defines the offset in the target array where to start storing values
  83072. * @returns the current matrix
  83073. */
  83074. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83075. /**
  83076. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83077. * @param other defines the second operand
  83078. * @param result defines the matrix where to store the multiplication
  83079. * @returns the current matrix
  83080. */
  83081. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83082. /**
  83083. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83084. * @param other defines the second operand
  83085. * @param result defines the array where to store the multiplication
  83086. * @param offset defines the offset in the target array where to start storing values
  83087. * @returns the current matrix
  83088. */
  83089. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83090. /**
  83091. * Check equality between this matrix and a second one
  83092. * @param value defines the second matrix to compare
  83093. * @returns true is the current matrix and the given one values are strictly equal
  83094. */
  83095. equals(value: DeepImmutable<Matrix>): boolean;
  83096. /**
  83097. * Clone the current matrix
  83098. * @returns a new matrix from the current matrix
  83099. */
  83100. clone(): Matrix;
  83101. /**
  83102. * Returns the name of the current matrix class
  83103. * @returns the string "Matrix"
  83104. */
  83105. getClassName(): string;
  83106. /**
  83107. * Gets the hash code of the current matrix
  83108. * @returns the hash code
  83109. */
  83110. getHashCode(): number;
  83111. /**
  83112. * Decomposes the current Matrix into a translation, rotation and scaling components
  83113. * @param scale defines the scale vector3 given as a reference to update
  83114. * @param rotation defines the rotation quaternion given as a reference to update
  83115. * @param translation defines the translation vector3 given as a reference to update
  83116. * @returns true if operation was successful
  83117. */
  83118. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83119. /**
  83120. * Gets specific row of the matrix
  83121. * @param index defines the number of the row to get
  83122. * @returns the index-th row of the current matrix as a new Vector4
  83123. */
  83124. getRow(index: number): Nullable<Vector4>;
  83125. /**
  83126. * Sets the index-th row of the current matrix to the vector4 values
  83127. * @param index defines the number of the row to set
  83128. * @param row defines the target vector4
  83129. * @returns the updated current matrix
  83130. */
  83131. setRow(index: number, row: Vector4): Matrix;
  83132. /**
  83133. * Compute the transpose of the matrix
  83134. * @returns the new transposed matrix
  83135. */
  83136. transpose(): Matrix;
  83137. /**
  83138. * Compute the transpose of the matrix and store it in a given matrix
  83139. * @param result defines the target matrix
  83140. * @returns the current matrix
  83141. */
  83142. transposeToRef(result: Matrix): Matrix;
  83143. /**
  83144. * Sets the index-th row of the current matrix with the given 4 x float values
  83145. * @param index defines the row index
  83146. * @param x defines the x component to set
  83147. * @param y defines the y component to set
  83148. * @param z defines the z component to set
  83149. * @param w defines the w component to set
  83150. * @returns the updated current matrix
  83151. */
  83152. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83153. /**
  83154. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83155. * @param scale defines the scale factor
  83156. * @returns a new matrix
  83157. */
  83158. scale(scale: number): Matrix;
  83159. /**
  83160. * Scale the current matrix values by a factor to a given result matrix
  83161. * @param scale defines the scale factor
  83162. * @param result defines the matrix to store the result
  83163. * @returns the current matrix
  83164. */
  83165. scaleToRef(scale: number, result: Matrix): Matrix;
  83166. /**
  83167. * Scale the current matrix values by a factor and add the result to a given matrix
  83168. * @param scale defines the scale factor
  83169. * @param result defines the Matrix to store the result
  83170. * @returns the current matrix
  83171. */
  83172. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83173. /**
  83174. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83175. * @param ref matrix to store the result
  83176. */
  83177. toNormalMatrix(ref: Matrix): void;
  83178. /**
  83179. * Gets only rotation part of the current matrix
  83180. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83181. */
  83182. getRotationMatrix(): Matrix;
  83183. /**
  83184. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83185. * @param result defines the target matrix to store data to
  83186. * @returns the current matrix
  83187. */
  83188. getRotationMatrixToRef(result: Matrix): Matrix;
  83189. /**
  83190. * Toggles model matrix from being right handed to left handed in place and vice versa
  83191. */
  83192. toggleModelMatrixHandInPlace(): void;
  83193. /**
  83194. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83195. */
  83196. toggleProjectionMatrixHandInPlace(): void;
  83197. /**
  83198. * Creates a matrix from an array
  83199. * @param array defines the source array
  83200. * @param offset defines an offset in the source array
  83201. * @returns a new Matrix set from the starting index of the given array
  83202. */
  83203. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83204. /**
  83205. * Copy the content of an array into a given matrix
  83206. * @param array defines the source array
  83207. * @param offset defines an offset in the source array
  83208. * @param result defines the target matrix
  83209. */
  83210. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83211. /**
  83212. * Stores an array into a matrix after having multiplied each component by a given factor
  83213. * @param array defines the source array
  83214. * @param offset defines the offset in the source array
  83215. * @param scale defines the scaling factor
  83216. * @param result defines the target matrix
  83217. */
  83218. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83219. /**
  83220. * Gets an identity matrix that must not be updated
  83221. */
  83222. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83223. /**
  83224. * Stores a list of values (16) inside a given matrix
  83225. * @param initialM11 defines 1st value of 1st row
  83226. * @param initialM12 defines 2nd value of 1st row
  83227. * @param initialM13 defines 3rd value of 1st row
  83228. * @param initialM14 defines 4th value of 1st row
  83229. * @param initialM21 defines 1st value of 2nd row
  83230. * @param initialM22 defines 2nd value of 2nd row
  83231. * @param initialM23 defines 3rd value of 2nd row
  83232. * @param initialM24 defines 4th value of 2nd row
  83233. * @param initialM31 defines 1st value of 3rd row
  83234. * @param initialM32 defines 2nd value of 3rd row
  83235. * @param initialM33 defines 3rd value of 3rd row
  83236. * @param initialM34 defines 4th value of 3rd row
  83237. * @param initialM41 defines 1st value of 4th row
  83238. * @param initialM42 defines 2nd value of 4th row
  83239. * @param initialM43 defines 3rd value of 4th row
  83240. * @param initialM44 defines 4th value of 4th row
  83241. * @param result defines the target matrix
  83242. */
  83243. 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;
  83244. /**
  83245. * Creates new matrix from a list of values (16)
  83246. * @param initialM11 defines 1st value of 1st row
  83247. * @param initialM12 defines 2nd value of 1st row
  83248. * @param initialM13 defines 3rd value of 1st row
  83249. * @param initialM14 defines 4th value of 1st row
  83250. * @param initialM21 defines 1st value of 2nd row
  83251. * @param initialM22 defines 2nd value of 2nd row
  83252. * @param initialM23 defines 3rd value of 2nd row
  83253. * @param initialM24 defines 4th value of 2nd row
  83254. * @param initialM31 defines 1st value of 3rd row
  83255. * @param initialM32 defines 2nd value of 3rd row
  83256. * @param initialM33 defines 3rd value of 3rd row
  83257. * @param initialM34 defines 4th value of 3rd row
  83258. * @param initialM41 defines 1st value of 4th row
  83259. * @param initialM42 defines 2nd value of 4th row
  83260. * @param initialM43 defines 3rd value of 4th row
  83261. * @param initialM44 defines 4th value of 4th row
  83262. * @returns the new matrix
  83263. */
  83264. 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;
  83265. /**
  83266. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83267. * @param scale defines the scale vector3
  83268. * @param rotation defines the rotation quaternion
  83269. * @param translation defines the translation vector3
  83270. * @returns a new matrix
  83271. */
  83272. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  83273. /**
  83274. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83275. * @param scale defines the scale vector3
  83276. * @param rotation defines the rotation quaternion
  83277. * @param translation defines the translation vector3
  83278. * @param result defines the target matrix
  83279. */
  83280. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  83281. /**
  83282. * Creates a new identity matrix
  83283. * @returns a new identity matrix
  83284. */
  83285. static Identity(): Matrix;
  83286. /**
  83287. * Creates a new identity matrix and stores the result in a given matrix
  83288. * @param result defines the target matrix
  83289. */
  83290. static IdentityToRef(result: Matrix): void;
  83291. /**
  83292. * Creates a new zero matrix
  83293. * @returns a new zero matrix
  83294. */
  83295. static Zero(): Matrix;
  83296. /**
  83297. * Creates a new rotation matrix for "angle" radians around the X axis
  83298. * @param angle defines the angle (in radians) to use
  83299. * @return the new matrix
  83300. */
  83301. static RotationX(angle: number): Matrix;
  83302. /**
  83303. * Creates a new matrix as the invert of a given matrix
  83304. * @param source defines the source matrix
  83305. * @returns the new matrix
  83306. */
  83307. static Invert(source: DeepImmutable<Matrix>): Matrix;
  83308. /**
  83309. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  83310. * @param angle defines the angle (in radians) to use
  83311. * @param result defines the target matrix
  83312. */
  83313. static RotationXToRef(angle: number, result: Matrix): void;
  83314. /**
  83315. * Creates a new rotation matrix for "angle" radians around the Y axis
  83316. * @param angle defines the angle (in radians) to use
  83317. * @return the new matrix
  83318. */
  83319. static RotationY(angle: number): Matrix;
  83320. /**
  83321. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  83322. * @param angle defines the angle (in radians) to use
  83323. * @param result defines the target matrix
  83324. */
  83325. static RotationYToRef(angle: number, result: Matrix): void;
  83326. /**
  83327. * Creates a new rotation matrix for "angle" radians around the Z axis
  83328. * @param angle defines the angle (in radians) to use
  83329. * @return the new matrix
  83330. */
  83331. static RotationZ(angle: number): Matrix;
  83332. /**
  83333. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83334. * @param angle defines the angle (in radians) to use
  83335. * @param result defines the target matrix
  83336. */
  83337. static RotationZToRef(angle: number, result: Matrix): void;
  83338. /**
  83339. * Creates a new rotation matrix for "angle" radians around the given axis
  83340. * @param axis defines the axis to use
  83341. * @param angle defines the angle (in radians) to use
  83342. * @return the new matrix
  83343. */
  83344. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83345. /**
  83346. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83347. * @param axis defines the axis to use
  83348. * @param angle defines the angle (in radians) to use
  83349. * @param result defines the target matrix
  83350. */
  83351. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83352. /**
  83353. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83354. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83355. * @param from defines the vector to align
  83356. * @param to defines the vector to align to
  83357. * @param result defines the target matrix
  83358. */
  83359. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83360. /**
  83361. * Creates a rotation matrix
  83362. * @param yaw defines the yaw angle in radians (Y axis)
  83363. * @param pitch defines the pitch angle in radians (X axis)
  83364. * @param roll defines the roll angle in radians (Z axis)
  83365. * @returns the new rotation matrix
  83366. */
  83367. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83368. /**
  83369. * Creates a rotation matrix and stores it in a given matrix
  83370. * @param yaw defines the yaw angle in radians (Y axis)
  83371. * @param pitch defines the pitch angle in radians (X axis)
  83372. * @param roll defines the roll angle in radians (Z axis)
  83373. * @param result defines the target matrix
  83374. */
  83375. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83376. /**
  83377. * Creates a scaling matrix
  83378. * @param x defines the scale factor on X axis
  83379. * @param y defines the scale factor on Y axis
  83380. * @param z defines the scale factor on Z axis
  83381. * @returns the new matrix
  83382. */
  83383. static Scaling(x: number, y: number, z: number): Matrix;
  83384. /**
  83385. * Creates a scaling matrix and stores it in a given matrix
  83386. * @param x defines the scale factor on X axis
  83387. * @param y defines the scale factor on Y axis
  83388. * @param z defines the scale factor on Z axis
  83389. * @param result defines the target matrix
  83390. */
  83391. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83392. /**
  83393. * Creates a translation matrix
  83394. * @param x defines the translation on X axis
  83395. * @param y defines the translation on Y axis
  83396. * @param z defines the translationon Z axis
  83397. * @returns the new matrix
  83398. */
  83399. static Translation(x: number, y: number, z: number): Matrix;
  83400. /**
  83401. * Creates a translation matrix and stores it in a given matrix
  83402. * @param x defines the translation on X axis
  83403. * @param y defines the translation on Y axis
  83404. * @param z defines the translationon Z axis
  83405. * @param result defines the target matrix
  83406. */
  83407. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83408. /**
  83409. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83410. * @param startValue defines the start value
  83411. * @param endValue defines the end value
  83412. * @param gradient defines the gradient factor
  83413. * @returns the new matrix
  83414. */
  83415. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83416. /**
  83417. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83418. * @param startValue defines the start value
  83419. * @param endValue defines the end value
  83420. * @param gradient defines the gradient factor
  83421. * @param result defines the Matrix object where to store data
  83422. */
  83423. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83424. /**
  83425. * Builds a new matrix whose values are computed by:
  83426. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83427. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83428. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83429. * @param startValue defines the first matrix
  83430. * @param endValue defines the second matrix
  83431. * @param gradient defines the gradient between the two matrices
  83432. * @returns the new matrix
  83433. */
  83434. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83435. /**
  83436. * Update a matrix to values which are computed by:
  83437. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83438. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83439. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83440. * @param startValue defines the first matrix
  83441. * @param endValue defines the second matrix
  83442. * @param gradient defines the gradient between the two matrices
  83443. * @param result defines the target matrix
  83444. */
  83445. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83446. /**
  83447. * 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"
  83448. * This function works in left handed mode
  83449. * @param eye defines the final position of the entity
  83450. * @param target defines where the entity should look at
  83451. * @param up defines the up vector for the entity
  83452. * @returns the new matrix
  83453. */
  83454. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83455. /**
  83456. * 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".
  83457. * This function works in left handed mode
  83458. * @param eye defines the final position of the entity
  83459. * @param target defines where the entity should look at
  83460. * @param up defines the up vector for the entity
  83461. * @param result defines the target matrix
  83462. */
  83463. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83464. /**
  83465. * 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"
  83466. * This function works in right handed mode
  83467. * @param eye defines the final position of the entity
  83468. * @param target defines where the entity should look at
  83469. * @param up defines the up vector for the entity
  83470. * @returns the new matrix
  83471. */
  83472. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83473. /**
  83474. * 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".
  83475. * This function works in right handed mode
  83476. * @param eye defines the final position of the entity
  83477. * @param target defines where the entity should look at
  83478. * @param up defines the up vector for the entity
  83479. * @param result defines the target matrix
  83480. */
  83481. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83482. /**
  83483. * Create a left-handed orthographic projection matrix
  83484. * @param width defines the viewport width
  83485. * @param height defines the viewport height
  83486. * @param znear defines the near clip plane
  83487. * @param zfar defines the far clip plane
  83488. * @returns a new matrix as a left-handed orthographic projection matrix
  83489. */
  83490. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83491. /**
  83492. * Store a left-handed orthographic projection to a given matrix
  83493. * @param width defines the viewport width
  83494. * @param height defines the viewport height
  83495. * @param znear defines the near clip plane
  83496. * @param zfar defines the far clip plane
  83497. * @param result defines the target matrix
  83498. */
  83499. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83500. /**
  83501. * Create a left-handed orthographic projection matrix
  83502. * @param left defines the viewport left coordinate
  83503. * @param right defines the viewport right coordinate
  83504. * @param bottom defines the viewport bottom coordinate
  83505. * @param top defines the viewport top coordinate
  83506. * @param znear defines the near clip plane
  83507. * @param zfar defines the far clip plane
  83508. * @returns a new matrix as a left-handed orthographic projection matrix
  83509. */
  83510. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83511. /**
  83512. * Stores a left-handed orthographic projection into a given matrix
  83513. * @param left defines the viewport left coordinate
  83514. * @param right defines the viewport right coordinate
  83515. * @param bottom defines the viewport bottom coordinate
  83516. * @param top defines the viewport top coordinate
  83517. * @param znear defines the near clip plane
  83518. * @param zfar defines the far clip plane
  83519. * @param result defines the target matrix
  83520. */
  83521. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83522. /**
  83523. * Creates a right-handed orthographic projection matrix
  83524. * @param left defines the viewport left coordinate
  83525. * @param right defines the viewport right coordinate
  83526. * @param bottom defines the viewport bottom coordinate
  83527. * @param top defines the viewport top coordinate
  83528. * @param znear defines the near clip plane
  83529. * @param zfar defines the far clip plane
  83530. * @returns a new matrix as a right-handed orthographic projection matrix
  83531. */
  83532. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83533. /**
  83534. * Stores a right-handed orthographic projection into a given matrix
  83535. * @param left defines the viewport left coordinate
  83536. * @param right defines the viewport right coordinate
  83537. * @param bottom defines the viewport bottom coordinate
  83538. * @param top defines the viewport top coordinate
  83539. * @param znear defines the near clip plane
  83540. * @param zfar defines the far clip plane
  83541. * @param result defines the target matrix
  83542. */
  83543. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83544. /**
  83545. * Creates a left-handed perspective projection matrix
  83546. * @param width defines the viewport width
  83547. * @param height defines the viewport height
  83548. * @param znear defines the near clip plane
  83549. * @param zfar defines the far clip plane
  83550. * @returns a new matrix as a left-handed perspective projection matrix
  83551. */
  83552. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83553. /**
  83554. * Creates a left-handed perspective projection matrix
  83555. * @param fov defines the horizontal field of view
  83556. * @param aspect defines the aspect ratio
  83557. * @param znear defines the near clip plane
  83558. * @param zfar defines the far clip plane
  83559. * @returns a new matrix as a left-handed perspective projection matrix
  83560. */
  83561. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83562. /**
  83563. * Stores a left-handed perspective projection into a given matrix
  83564. * @param fov defines the horizontal field of view
  83565. * @param aspect defines the aspect ratio
  83566. * @param znear defines the near clip plane
  83567. * @param zfar defines the far clip plane
  83568. * @param result defines the target matrix
  83569. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83570. */
  83571. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83572. /**
  83573. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83574. * @param fov defines the horizontal field of view
  83575. * @param aspect defines the aspect ratio
  83576. * @param znear defines the near clip plane
  83577. * @param zfar not used as infinity is used as far clip
  83578. * @param result defines the target matrix
  83579. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83580. */
  83581. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83582. /**
  83583. * Creates a right-handed perspective projection matrix
  83584. * @param fov defines the horizontal field of view
  83585. * @param aspect defines the aspect ratio
  83586. * @param znear defines the near clip plane
  83587. * @param zfar defines the far clip plane
  83588. * @returns a new matrix as a right-handed perspective projection matrix
  83589. */
  83590. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83591. /**
  83592. * Stores a right-handed perspective projection into a given matrix
  83593. * @param fov defines the horizontal field of view
  83594. * @param aspect defines the aspect ratio
  83595. * @param znear defines the near clip plane
  83596. * @param zfar defines the far clip plane
  83597. * @param result defines the target matrix
  83598. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83599. */
  83600. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83601. /**
  83602. * Stores a right-handed perspective projection into a given matrix
  83603. * @param fov defines the horizontal field of view
  83604. * @param aspect defines the aspect ratio
  83605. * @param znear defines the near clip plane
  83606. * @param zfar not used as infinity is used as far clip
  83607. * @param result defines the target matrix
  83608. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83609. */
  83610. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83611. /**
  83612. * Stores a perspective projection for WebVR info a given matrix
  83613. * @param fov defines the field of view
  83614. * @param znear defines the near clip plane
  83615. * @param zfar defines the far clip plane
  83616. * @param result defines the target matrix
  83617. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83618. */
  83619. static PerspectiveFovWebVRToRef(fov: {
  83620. upDegrees: number;
  83621. downDegrees: number;
  83622. leftDegrees: number;
  83623. rightDegrees: number;
  83624. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83625. /**
  83626. * Computes a complete transformation matrix
  83627. * @param viewport defines the viewport to use
  83628. * @param world defines the world matrix
  83629. * @param view defines the view matrix
  83630. * @param projection defines the projection matrix
  83631. * @param zmin defines the near clip plane
  83632. * @param zmax defines the far clip plane
  83633. * @returns the transformation matrix
  83634. */
  83635. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83636. /**
  83637. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83638. * @param matrix defines the matrix to use
  83639. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83640. */
  83641. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83642. /**
  83643. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83644. * @param matrix defines the matrix to use
  83645. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83646. */
  83647. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83648. /**
  83649. * Compute the transpose of a given matrix
  83650. * @param matrix defines the matrix to transpose
  83651. * @returns the new matrix
  83652. */
  83653. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83654. /**
  83655. * Compute the transpose of a matrix and store it in a target matrix
  83656. * @param matrix defines the matrix to transpose
  83657. * @param result defines the target matrix
  83658. */
  83659. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83660. /**
  83661. * Computes a reflection matrix from a plane
  83662. * @param plane defines the reflection plane
  83663. * @returns a new matrix
  83664. */
  83665. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83666. /**
  83667. * Computes a reflection matrix from a plane
  83668. * @param plane defines the reflection plane
  83669. * @param result defines the target matrix
  83670. */
  83671. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83672. /**
  83673. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83674. * @param xaxis defines the value of the 1st axis
  83675. * @param yaxis defines the value of the 2nd axis
  83676. * @param zaxis defines the value of the 3rd axis
  83677. * @param result defines the target matrix
  83678. */
  83679. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83680. /**
  83681. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83682. * @param quat defines the quaternion to use
  83683. * @param result defines the target matrix
  83684. */
  83685. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83686. }
  83687. /**
  83688. * @hidden
  83689. */
  83690. export class TmpVectors {
  83691. static Vector2: Vector2[];
  83692. static Vector3: Vector3[];
  83693. static Vector4: Vector4[];
  83694. static Quaternion: Quaternion[];
  83695. static Matrix: Matrix[];
  83696. }
  83697. }
  83698. declare module BABYLON {
  83699. /**
  83700. * Defines potential orientation for back face culling
  83701. */
  83702. export enum Orientation {
  83703. /**
  83704. * Clockwise
  83705. */
  83706. CW = 0,
  83707. /** Counter clockwise */
  83708. CCW = 1
  83709. }
  83710. /** Class used to represent a Bezier curve */
  83711. export class BezierCurve {
  83712. /**
  83713. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83714. * @param t defines the time
  83715. * @param x1 defines the left coordinate on X axis
  83716. * @param y1 defines the left coordinate on Y axis
  83717. * @param x2 defines the right coordinate on X axis
  83718. * @param y2 defines the right coordinate on Y axis
  83719. * @returns the interpolated value
  83720. */
  83721. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83722. }
  83723. /**
  83724. * Defines angle representation
  83725. */
  83726. export class Angle {
  83727. private _radians;
  83728. /**
  83729. * Creates an Angle object of "radians" radians (float).
  83730. * @param radians the angle in radians
  83731. */
  83732. constructor(radians: number);
  83733. /**
  83734. * Get value in degrees
  83735. * @returns the Angle value in degrees (float)
  83736. */
  83737. degrees(): number;
  83738. /**
  83739. * Get value in radians
  83740. * @returns the Angle value in radians (float)
  83741. */
  83742. radians(): number;
  83743. /**
  83744. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83745. * @param a defines first point as the origin
  83746. * @param b defines point
  83747. * @returns a new Angle
  83748. */
  83749. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83750. /**
  83751. * Gets a new Angle object from the given float in radians
  83752. * @param radians defines the angle value in radians
  83753. * @returns a new Angle
  83754. */
  83755. static FromRadians(radians: number): Angle;
  83756. /**
  83757. * Gets a new Angle object from the given float in degrees
  83758. * @param degrees defines the angle value in degrees
  83759. * @returns a new Angle
  83760. */
  83761. static FromDegrees(degrees: number): Angle;
  83762. }
  83763. /**
  83764. * This represents an arc in a 2d space.
  83765. */
  83766. export class Arc2 {
  83767. /** Defines the start point of the arc */
  83768. startPoint: Vector2;
  83769. /** Defines the mid point of the arc */
  83770. midPoint: Vector2;
  83771. /** Defines the end point of the arc */
  83772. endPoint: Vector2;
  83773. /**
  83774. * Defines the center point of the arc.
  83775. */
  83776. centerPoint: Vector2;
  83777. /**
  83778. * Defines the radius of the arc.
  83779. */
  83780. radius: number;
  83781. /**
  83782. * Defines the angle of the arc (from mid point to end point).
  83783. */
  83784. angle: Angle;
  83785. /**
  83786. * Defines the start angle of the arc (from start point to middle point).
  83787. */
  83788. startAngle: Angle;
  83789. /**
  83790. * Defines the orientation of the arc (clock wise/counter clock wise).
  83791. */
  83792. orientation: Orientation;
  83793. /**
  83794. * Creates an Arc object from the three given points : start, middle and end.
  83795. * @param startPoint Defines the start point of the arc
  83796. * @param midPoint Defines the midlle point of the arc
  83797. * @param endPoint Defines the end point of the arc
  83798. */
  83799. constructor(
  83800. /** Defines the start point of the arc */
  83801. startPoint: Vector2,
  83802. /** Defines the mid point of the arc */
  83803. midPoint: Vector2,
  83804. /** Defines the end point of the arc */
  83805. endPoint: Vector2);
  83806. }
  83807. /**
  83808. * Represents a 2D path made up of multiple 2D points
  83809. */
  83810. export class Path2 {
  83811. private _points;
  83812. private _length;
  83813. /**
  83814. * If the path start and end point are the same
  83815. */
  83816. closed: boolean;
  83817. /**
  83818. * Creates a Path2 object from the starting 2D coordinates x and y.
  83819. * @param x the starting points x value
  83820. * @param y the starting points y value
  83821. */
  83822. constructor(x: number, y: number);
  83823. /**
  83824. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83825. * @param x the added points x value
  83826. * @param y the added points y value
  83827. * @returns the updated Path2.
  83828. */
  83829. addLineTo(x: number, y: number): Path2;
  83830. /**
  83831. * 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.
  83832. * @param midX middle point x value
  83833. * @param midY middle point y value
  83834. * @param endX end point x value
  83835. * @param endY end point y value
  83836. * @param numberOfSegments (default: 36)
  83837. * @returns the updated Path2.
  83838. */
  83839. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83840. /**
  83841. * Closes the Path2.
  83842. * @returns the Path2.
  83843. */
  83844. close(): Path2;
  83845. /**
  83846. * Gets the sum of the distance between each sequential point in the path
  83847. * @returns the Path2 total length (float).
  83848. */
  83849. length(): number;
  83850. /**
  83851. * Gets the points which construct the path
  83852. * @returns the Path2 internal array of points.
  83853. */
  83854. getPoints(): Vector2[];
  83855. /**
  83856. * Retreives the point at the distance aways from the starting point
  83857. * @param normalizedLengthPosition the length along the path to retreive the point from
  83858. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83859. */
  83860. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83861. /**
  83862. * Creates a new path starting from an x and y position
  83863. * @param x starting x value
  83864. * @param y starting y value
  83865. * @returns a new Path2 starting at the coordinates (x, y).
  83866. */
  83867. static StartingAt(x: number, y: number): Path2;
  83868. }
  83869. /**
  83870. * Represents a 3D path made up of multiple 3D points
  83871. */
  83872. export class Path3D {
  83873. /**
  83874. * an array of Vector3, the curve axis of the Path3D
  83875. */
  83876. path: Vector3[];
  83877. private _curve;
  83878. private _distances;
  83879. private _tangents;
  83880. private _normals;
  83881. private _binormals;
  83882. private _raw;
  83883. private _alignTangentsWithPath;
  83884. private readonly _pointAtData;
  83885. /**
  83886. * new Path3D(path, normal, raw)
  83887. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83888. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83889. * @param path an array of Vector3, the curve axis of the Path3D
  83890. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83891. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83892. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83893. */
  83894. constructor(
  83895. /**
  83896. * an array of Vector3, the curve axis of the Path3D
  83897. */
  83898. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  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. getCurve(): Vector3[];
  83904. /**
  83905. * Returns the Path3D array of successive Vector3 designing its curve.
  83906. * @returns the Path3D array of successive Vector3 designing its curve.
  83907. */
  83908. getPoints(): Vector3[];
  83909. /**
  83910. * @returns the computed length (float) of the path.
  83911. */
  83912. length(): number;
  83913. /**
  83914. * Returns an array populated with tangent vectors on each Path3D curve point.
  83915. * @returns an array populated with tangent vectors on each Path3D curve point.
  83916. */
  83917. getTangents(): Vector3[];
  83918. /**
  83919. * Returns an array populated with normal vectors on each Path3D curve point.
  83920. * @returns an array populated with normal vectors on each Path3D curve point.
  83921. */
  83922. getNormals(): Vector3[];
  83923. /**
  83924. * Returns an array populated with binormal vectors on each Path3D curve point.
  83925. * @returns an array populated with binormal vectors on each Path3D curve point.
  83926. */
  83927. getBinormals(): Vector3[];
  83928. /**
  83929. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83930. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83931. */
  83932. getDistances(): number[];
  83933. /**
  83934. * Returns an interpolated point along this path
  83935. * @param position the position of the point along this path, from 0.0 to 1.0
  83936. * @returns a new Vector3 as the point
  83937. */
  83938. getPointAt(position: number): Vector3;
  83939. /**
  83940. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83941. * @param position the position of the point along this path, from 0.0 to 1.0
  83942. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83943. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83944. */
  83945. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83946. /**
  83947. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83948. * @param position the position of the point along this path, from 0.0 to 1.0
  83949. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83950. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83951. */
  83952. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83953. /**
  83954. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83955. * @param position the position of the point along this path, from 0.0 to 1.0
  83956. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83957. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83958. */
  83959. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83960. /**
  83961. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83962. * @param position the position of the point along this path, from 0.0 to 1.0
  83963. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83964. */
  83965. getDistanceAt(position: number): number;
  83966. /**
  83967. * Returns the array index of the previous point of an interpolated point along this path
  83968. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83969. * @returns the array index
  83970. */
  83971. getPreviousPointIndexAt(position: number): number;
  83972. /**
  83973. * 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)
  83974. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83975. * @returns the sub position
  83976. */
  83977. getSubPositionAt(position: number): number;
  83978. /**
  83979. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83980. * @param target the vector of which to get the closest position to
  83981. * @returns the position of the closest virtual point on this path to the target vector
  83982. */
  83983. getClosestPositionTo(target: Vector3): number;
  83984. /**
  83985. * Returns a sub path (slice) of this path
  83986. * @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
  83987. * @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
  83988. * @returns a sub path (slice) of this path
  83989. */
  83990. slice(start?: number, end?: number): Path3D;
  83991. /**
  83992. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83993. * @param path path which all values are copied into the curves points
  83994. * @param firstNormal which should be projected onto the curve
  83995. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83996. * @returns the same object updated.
  83997. */
  83998. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83999. private _compute;
  84000. private _getFirstNonNullVector;
  84001. private _getLastNonNullVector;
  84002. private _normalVector;
  84003. /**
  84004. * Updates the point at data for an interpolated point along this curve
  84005. * @param position the position of the point along this curve, from 0.0 to 1.0
  84006. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84007. * @returns the (updated) point at data
  84008. */
  84009. private _updatePointAtData;
  84010. /**
  84011. * Updates the point at data from the specified parameters
  84012. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84013. * @param point the interpolated point
  84014. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84015. */
  84016. private _setPointAtData;
  84017. /**
  84018. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84019. */
  84020. private _updateInterpolationMatrix;
  84021. }
  84022. /**
  84023. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84024. * A Curve3 is designed from a series of successive Vector3.
  84025. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84026. */
  84027. export class Curve3 {
  84028. private _points;
  84029. private _length;
  84030. /**
  84031. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84032. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84033. * @param v1 (Vector3) the control point
  84034. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84035. * @param nbPoints (integer) the wanted number of points in the curve
  84036. * @returns the created Curve3
  84037. */
  84038. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84039. /**
  84040. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84041. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84042. * @param v1 (Vector3) the first control point
  84043. * @param v2 (Vector3) the second control point
  84044. * @param v3 (Vector3) the end point of the Cubic Bezier
  84045. * @param nbPoints (integer) the wanted number of points in the curve
  84046. * @returns the created Curve3
  84047. */
  84048. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84049. /**
  84050. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84051. * @param p1 (Vector3) the origin point of the Hermite Spline
  84052. * @param t1 (Vector3) the tangent vector at the origin point
  84053. * @param p2 (Vector3) the end point of the Hermite Spline
  84054. * @param t2 (Vector3) the tangent vector at the end point
  84055. * @param nbPoints (integer) the wanted number of points in the curve
  84056. * @returns the created Curve3
  84057. */
  84058. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84059. /**
  84060. * Returns a Curve3 object along a CatmullRom Spline curve :
  84061. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84062. * @param nbPoints (integer) the wanted number of points between each curve control points
  84063. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84064. * @returns the created Curve3
  84065. */
  84066. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84067. /**
  84068. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84069. * A Curve3 is designed from a series of successive Vector3.
  84070. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84071. * @param points points which make up the curve
  84072. */
  84073. constructor(points: Vector3[]);
  84074. /**
  84075. * @returns the Curve3 stored array of successive Vector3
  84076. */
  84077. getPoints(): Vector3[];
  84078. /**
  84079. * @returns the computed length (float) of the curve.
  84080. */
  84081. length(): number;
  84082. /**
  84083. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84084. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84085. * curveA and curveB keep unchanged.
  84086. * @param curve the curve to continue from this curve
  84087. * @returns the newly constructed curve
  84088. */
  84089. continue(curve: DeepImmutable<Curve3>): Curve3;
  84090. private _computeLength;
  84091. }
  84092. }
  84093. declare module BABYLON {
  84094. /**
  84095. * This represents the main contract an easing function should follow.
  84096. * Easing functions are used throughout the animation system.
  84097. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84098. */
  84099. export interface IEasingFunction {
  84100. /**
  84101. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84102. * of the easing function.
  84103. * The link below provides some of the most common examples of easing functions.
  84104. * @see https://easings.net/
  84105. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84106. * @returns the corresponding value on the curve defined by the easing function
  84107. */
  84108. ease(gradient: number): number;
  84109. }
  84110. /**
  84111. * Base class used for every default easing function.
  84112. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84113. */
  84114. export class EasingFunction implements IEasingFunction {
  84115. /**
  84116. * Interpolation follows the mathematical formula associated with the easing function.
  84117. */
  84118. static readonly EASINGMODE_EASEIN: number;
  84119. /**
  84120. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84121. */
  84122. static readonly EASINGMODE_EASEOUT: number;
  84123. /**
  84124. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84125. */
  84126. static readonly EASINGMODE_EASEINOUT: number;
  84127. private _easingMode;
  84128. /**
  84129. * Sets the easing mode of the current function.
  84130. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84131. */
  84132. setEasingMode(easingMode: number): void;
  84133. /**
  84134. * Gets the current easing mode.
  84135. * @returns the easing mode
  84136. */
  84137. getEasingMode(): number;
  84138. /**
  84139. * @hidden
  84140. */
  84141. easeInCore(gradient: number): number;
  84142. /**
  84143. * Given an input gradient between 0 and 1, this returns the corresponding value
  84144. * of the easing function.
  84145. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84146. * @returns the corresponding value on the curve defined by the easing function
  84147. */
  84148. ease(gradient: number): number;
  84149. }
  84150. /**
  84151. * Easing function with a circle shape (see link below).
  84152. * @see https://easings.net/#easeInCirc
  84153. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84154. */
  84155. export class CircleEase extends EasingFunction implements IEasingFunction {
  84156. /** @hidden */
  84157. easeInCore(gradient: number): number;
  84158. }
  84159. /**
  84160. * Easing function with a ease back shape (see link below).
  84161. * @see https://easings.net/#easeInBack
  84162. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84163. */
  84164. export class BackEase extends EasingFunction implements IEasingFunction {
  84165. /** Defines the amplitude of the function */
  84166. amplitude: number;
  84167. /**
  84168. * Instantiates a back ease easing
  84169. * @see https://easings.net/#easeInBack
  84170. * @param amplitude Defines the amplitude of the function
  84171. */
  84172. constructor(
  84173. /** Defines the amplitude of the function */
  84174. amplitude?: number);
  84175. /** @hidden */
  84176. easeInCore(gradient: number): number;
  84177. }
  84178. /**
  84179. * Easing function with a bouncing shape (see link below).
  84180. * @see https://easings.net/#easeInBounce
  84181. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84182. */
  84183. export class BounceEase extends EasingFunction implements IEasingFunction {
  84184. /** Defines the number of bounces */
  84185. bounces: number;
  84186. /** Defines the amplitude of the bounce */
  84187. bounciness: number;
  84188. /**
  84189. * Instantiates a bounce easing
  84190. * @see https://easings.net/#easeInBounce
  84191. * @param bounces Defines the number of bounces
  84192. * @param bounciness Defines the amplitude of the bounce
  84193. */
  84194. constructor(
  84195. /** Defines the number of bounces */
  84196. bounces?: number,
  84197. /** Defines the amplitude of the bounce */
  84198. bounciness?: number);
  84199. /** @hidden */
  84200. easeInCore(gradient: number): number;
  84201. }
  84202. /**
  84203. * Easing function with a power of 3 shape (see link below).
  84204. * @see https://easings.net/#easeInCubic
  84205. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84206. */
  84207. export class CubicEase extends EasingFunction implements IEasingFunction {
  84208. /** @hidden */
  84209. easeInCore(gradient: number): number;
  84210. }
  84211. /**
  84212. * Easing function with an elastic shape (see link below).
  84213. * @see https://easings.net/#easeInElastic
  84214. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84215. */
  84216. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84217. /** Defines the number of oscillations*/
  84218. oscillations: number;
  84219. /** Defines the amplitude of the oscillations*/
  84220. springiness: number;
  84221. /**
  84222. * Instantiates an elastic easing function
  84223. * @see https://easings.net/#easeInElastic
  84224. * @param oscillations Defines the number of oscillations
  84225. * @param springiness Defines the amplitude of the oscillations
  84226. */
  84227. constructor(
  84228. /** Defines the number of oscillations*/
  84229. oscillations?: number,
  84230. /** Defines the amplitude of the oscillations*/
  84231. springiness?: number);
  84232. /** @hidden */
  84233. easeInCore(gradient: number): number;
  84234. }
  84235. /**
  84236. * Easing function with an exponential shape (see link below).
  84237. * @see https://easings.net/#easeInExpo
  84238. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84239. */
  84240. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84241. /** Defines the exponent of the function */
  84242. exponent: number;
  84243. /**
  84244. * Instantiates an exponential easing function
  84245. * @see https://easings.net/#easeInExpo
  84246. * @param exponent Defines the exponent of the function
  84247. */
  84248. constructor(
  84249. /** Defines the exponent of the function */
  84250. exponent?: number);
  84251. /** @hidden */
  84252. easeInCore(gradient: number): number;
  84253. }
  84254. /**
  84255. * Easing function with a power shape (see link below).
  84256. * @see https://easings.net/#easeInQuad
  84257. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84258. */
  84259. export class PowerEase extends EasingFunction implements IEasingFunction {
  84260. /** Defines the power of the function */
  84261. power: number;
  84262. /**
  84263. * Instantiates an power base easing function
  84264. * @see https://easings.net/#easeInQuad
  84265. * @param power Defines the power of the function
  84266. */
  84267. constructor(
  84268. /** Defines the power of the function */
  84269. power?: number);
  84270. /** @hidden */
  84271. easeInCore(gradient: number): number;
  84272. }
  84273. /**
  84274. * Easing function with a power of 2 shape (see link below).
  84275. * @see https://easings.net/#easeInQuad
  84276. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84277. */
  84278. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  84279. /** @hidden */
  84280. easeInCore(gradient: number): number;
  84281. }
  84282. /**
  84283. * Easing function with a power of 4 shape (see link below).
  84284. * @see https://easings.net/#easeInQuart
  84285. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84286. */
  84287. export class QuarticEase extends EasingFunction implements IEasingFunction {
  84288. /** @hidden */
  84289. easeInCore(gradient: number): number;
  84290. }
  84291. /**
  84292. * Easing function with a power of 5 shape (see link below).
  84293. * @see https://easings.net/#easeInQuint
  84294. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84295. */
  84296. export class QuinticEase extends EasingFunction implements IEasingFunction {
  84297. /** @hidden */
  84298. easeInCore(gradient: number): number;
  84299. }
  84300. /**
  84301. * Easing function with a sin shape (see link below).
  84302. * @see https://easings.net/#easeInSine
  84303. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84304. */
  84305. export class SineEase extends EasingFunction implements IEasingFunction {
  84306. /** @hidden */
  84307. easeInCore(gradient: number): number;
  84308. }
  84309. /**
  84310. * Easing function with a bezier shape (see link below).
  84311. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84312. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84313. */
  84314. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  84315. /** Defines the x component of the start tangent in the bezier curve */
  84316. x1: number;
  84317. /** Defines the y component of the start tangent in the bezier curve */
  84318. y1: number;
  84319. /** Defines the x component of the end tangent in the bezier curve */
  84320. x2: number;
  84321. /** Defines the y component of the end tangent in the bezier curve */
  84322. y2: number;
  84323. /**
  84324. * Instantiates a bezier function
  84325. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84326. * @param x1 Defines the x component of the start tangent in the bezier curve
  84327. * @param y1 Defines the y component of the start tangent in the bezier curve
  84328. * @param x2 Defines the x component of the end tangent in the bezier curve
  84329. * @param y2 Defines the y component of the end tangent in the bezier curve
  84330. */
  84331. constructor(
  84332. /** Defines the x component of the start tangent in the bezier curve */
  84333. x1?: number,
  84334. /** Defines the y component of the start tangent in the bezier curve */
  84335. y1?: number,
  84336. /** Defines the x component of the end tangent in the bezier curve */
  84337. x2?: number,
  84338. /** Defines the y component of the end tangent in the bezier curve */
  84339. y2?: number);
  84340. /** @hidden */
  84341. easeInCore(gradient: number): number;
  84342. }
  84343. }
  84344. declare module BABYLON {
  84345. /**
  84346. * Class used to hold a RBG color
  84347. */
  84348. export class Color3 {
  84349. /**
  84350. * Defines the red component (between 0 and 1, default is 0)
  84351. */
  84352. r: number;
  84353. /**
  84354. * Defines the green component (between 0 and 1, default is 0)
  84355. */
  84356. g: number;
  84357. /**
  84358. * Defines the blue component (between 0 and 1, default is 0)
  84359. */
  84360. b: number;
  84361. /**
  84362. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84363. * @param r defines the red component (between 0 and 1, default is 0)
  84364. * @param g defines the green component (between 0 and 1, default is 0)
  84365. * @param b defines the blue component (between 0 and 1, default is 0)
  84366. */
  84367. constructor(
  84368. /**
  84369. * Defines the red component (between 0 and 1, default is 0)
  84370. */
  84371. r?: number,
  84372. /**
  84373. * Defines the green component (between 0 and 1, default is 0)
  84374. */
  84375. g?: number,
  84376. /**
  84377. * Defines the blue component (between 0 and 1, default is 0)
  84378. */
  84379. b?: number);
  84380. /**
  84381. * Creates a string with the Color3 current values
  84382. * @returns the string representation of the Color3 object
  84383. */
  84384. toString(): string;
  84385. /**
  84386. * Returns the string "Color3"
  84387. * @returns "Color3"
  84388. */
  84389. getClassName(): string;
  84390. /**
  84391. * Compute the Color3 hash code
  84392. * @returns an unique number that can be used to hash Color3 objects
  84393. */
  84394. getHashCode(): number;
  84395. /**
  84396. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84397. * @param array defines the array where to store the r,g,b components
  84398. * @param index defines an optional index in the target array to define where to start storing values
  84399. * @returns the current Color3 object
  84400. */
  84401. toArray(array: FloatArray, index?: number): Color3;
  84402. /**
  84403. * Update the current color with values stored in an array from the starting index of the given array
  84404. * @param array defines the source array
  84405. * @param offset defines an offset in the source array
  84406. * @returns the current Color3 object
  84407. */
  84408. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84409. /**
  84410. * Returns a new Color4 object from the current Color3 and the given alpha
  84411. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84412. * @returns a new Color4 object
  84413. */
  84414. toColor4(alpha?: number): Color4;
  84415. /**
  84416. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84417. * @returns the new array
  84418. */
  84419. asArray(): number[];
  84420. /**
  84421. * Returns the luminance value
  84422. * @returns a float value
  84423. */
  84424. toLuminance(): number;
  84425. /**
  84426. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84427. * @param otherColor defines the second operand
  84428. * @returns the new Color3 object
  84429. */
  84430. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84431. /**
  84432. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84433. * @param otherColor defines the second operand
  84434. * @param result defines the Color3 object where to store the result
  84435. * @returns the current Color3
  84436. */
  84437. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84438. /**
  84439. * Determines equality between Color3 objects
  84440. * @param otherColor defines the second operand
  84441. * @returns true if the rgb values are equal to the given ones
  84442. */
  84443. equals(otherColor: DeepImmutable<Color3>): boolean;
  84444. /**
  84445. * Determines equality between the current Color3 object and a set of r,b,g values
  84446. * @param r defines the red component to check
  84447. * @param g defines the green component to check
  84448. * @param b defines the blue component to check
  84449. * @returns true if the rgb values are equal to the given ones
  84450. */
  84451. equalsFloats(r: number, g: number, b: number): boolean;
  84452. /**
  84453. * Multiplies in place each rgb value by scale
  84454. * @param scale defines the scaling factor
  84455. * @returns the updated Color3
  84456. */
  84457. scale(scale: number): Color3;
  84458. /**
  84459. * Multiplies the rgb values by scale and stores the result into "result"
  84460. * @param scale defines the scaling factor
  84461. * @param result defines the Color3 object where to store the result
  84462. * @returns the unmodified current Color3
  84463. */
  84464. scaleToRef(scale: number, result: Color3): Color3;
  84465. /**
  84466. * Scale the current Color3 values by a factor and add the result to a given Color3
  84467. * @param scale defines the scale factor
  84468. * @param result defines color to store the result into
  84469. * @returns the unmodified current Color3
  84470. */
  84471. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84472. /**
  84473. * Clamps the rgb values by the min and max values and stores the result into "result"
  84474. * @param min defines minimum clamping value (default is 0)
  84475. * @param max defines maximum clamping value (default is 1)
  84476. * @param result defines color to store the result into
  84477. * @returns the original Color3
  84478. */
  84479. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84480. /**
  84481. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84482. * @param otherColor defines the second operand
  84483. * @returns the new Color3
  84484. */
  84485. add(otherColor: DeepImmutable<Color3>): Color3;
  84486. /**
  84487. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84488. * @param otherColor defines the second operand
  84489. * @param result defines Color3 object to store the result into
  84490. * @returns the unmodified current Color3
  84491. */
  84492. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84493. /**
  84494. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84495. * @param otherColor defines the second operand
  84496. * @returns the new Color3
  84497. */
  84498. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84499. /**
  84500. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84501. * @param otherColor defines the second operand
  84502. * @param result defines Color3 object to store the result into
  84503. * @returns the unmodified current Color3
  84504. */
  84505. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84506. /**
  84507. * Copy the current object
  84508. * @returns a new Color3 copied the current one
  84509. */
  84510. clone(): Color3;
  84511. /**
  84512. * Copies the rgb values from the source in the current Color3
  84513. * @param source defines the source Color3 object
  84514. * @returns the updated Color3 object
  84515. */
  84516. copyFrom(source: DeepImmutable<Color3>): Color3;
  84517. /**
  84518. * Updates the Color3 rgb values from the given floats
  84519. * @param r defines the red component to read from
  84520. * @param g defines the green component to read from
  84521. * @param b defines the blue component to read from
  84522. * @returns the current Color3 object
  84523. */
  84524. copyFromFloats(r: number, g: number, b: number): Color3;
  84525. /**
  84526. * Updates the Color3 rgb values from the given floats
  84527. * @param r defines the red component to read from
  84528. * @param g defines the green component to read from
  84529. * @param b defines the blue component to read from
  84530. * @returns the current Color3 object
  84531. */
  84532. set(r: number, g: number, b: number): Color3;
  84533. /**
  84534. * Compute the Color3 hexadecimal code as a string
  84535. * @returns a string containing the hexadecimal representation of the Color3 object
  84536. */
  84537. toHexString(): string;
  84538. /**
  84539. * Computes a new Color3 converted from the current one to linear space
  84540. * @returns a new Color3 object
  84541. */
  84542. toLinearSpace(): Color3;
  84543. /**
  84544. * Converts current color in rgb space to HSV values
  84545. * @returns a new color3 representing the HSV values
  84546. */
  84547. toHSV(): Color3;
  84548. /**
  84549. * Converts current color in rgb space to HSV values
  84550. * @param result defines the Color3 where to store the HSV values
  84551. */
  84552. toHSVToRef(result: Color3): void;
  84553. /**
  84554. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84555. * @param convertedColor defines the Color3 object where to store the linear space version
  84556. * @returns the unmodified Color3
  84557. */
  84558. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84559. /**
  84560. * Computes a new Color3 converted from the current one to gamma space
  84561. * @returns a new Color3 object
  84562. */
  84563. toGammaSpace(): Color3;
  84564. /**
  84565. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84566. * @param convertedColor defines the Color3 object where to store the gamma space version
  84567. * @returns the unmodified Color3
  84568. */
  84569. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84570. private static _BlackReadOnly;
  84571. /**
  84572. * Convert Hue, saturation and value to a Color3 (RGB)
  84573. * @param hue defines the hue
  84574. * @param saturation defines the saturation
  84575. * @param value defines the value
  84576. * @param result defines the Color3 where to store the RGB values
  84577. */
  84578. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84579. /**
  84580. * Creates a new Color3 from the string containing valid hexadecimal values
  84581. * @param hex defines a string containing valid hexadecimal values
  84582. * @returns a new Color3 object
  84583. */
  84584. static FromHexString(hex: string): Color3;
  84585. /**
  84586. * Creates a new Color3 from the starting index of the given array
  84587. * @param array defines the source array
  84588. * @param offset defines an offset in the source array
  84589. * @returns a new Color3 object
  84590. */
  84591. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84592. /**
  84593. * Creates a new Color3 from the starting index element of the given array
  84594. * @param array defines the source array to read from
  84595. * @param offset defines the offset in the source array
  84596. * @param result defines the target Color3 object
  84597. */
  84598. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  84599. /**
  84600. * Creates a new Color3 from integer values (< 256)
  84601. * @param r defines the red component to read from (value between 0 and 255)
  84602. * @param g defines the green component to read from (value between 0 and 255)
  84603. * @param b defines the blue component to read from (value between 0 and 255)
  84604. * @returns a new Color3 object
  84605. */
  84606. static FromInts(r: number, g: number, b: number): Color3;
  84607. /**
  84608. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84609. * @param start defines the start Color3 value
  84610. * @param end defines the end Color3 value
  84611. * @param amount defines the gradient value between start and end
  84612. * @returns a new Color3 object
  84613. */
  84614. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84615. /**
  84616. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84617. * @param left defines the start value
  84618. * @param right defines the end value
  84619. * @param amount defines the gradient factor
  84620. * @param result defines the Color3 object where to store the result
  84621. */
  84622. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84623. /**
  84624. * Returns a Color3 value containing a red color
  84625. * @returns a new Color3 object
  84626. */
  84627. static Red(): Color3;
  84628. /**
  84629. * Returns a Color3 value containing a green color
  84630. * @returns a new Color3 object
  84631. */
  84632. static Green(): Color3;
  84633. /**
  84634. * Returns a Color3 value containing a blue color
  84635. * @returns a new Color3 object
  84636. */
  84637. static Blue(): Color3;
  84638. /**
  84639. * Returns a Color3 value containing a black color
  84640. * @returns a new Color3 object
  84641. */
  84642. static Black(): Color3;
  84643. /**
  84644. * Gets a Color3 value containing a black color that must not be updated
  84645. */
  84646. static get BlackReadOnly(): DeepImmutable<Color3>;
  84647. /**
  84648. * Returns a Color3 value containing a white color
  84649. * @returns a new Color3 object
  84650. */
  84651. static White(): Color3;
  84652. /**
  84653. * Returns a Color3 value containing a purple color
  84654. * @returns a new Color3 object
  84655. */
  84656. static Purple(): Color3;
  84657. /**
  84658. * Returns a Color3 value containing a magenta color
  84659. * @returns a new Color3 object
  84660. */
  84661. static Magenta(): Color3;
  84662. /**
  84663. * Returns a Color3 value containing a yellow color
  84664. * @returns a new Color3 object
  84665. */
  84666. static Yellow(): Color3;
  84667. /**
  84668. * Returns a Color3 value containing a gray color
  84669. * @returns a new Color3 object
  84670. */
  84671. static Gray(): Color3;
  84672. /**
  84673. * Returns a Color3 value containing a teal color
  84674. * @returns a new Color3 object
  84675. */
  84676. static Teal(): Color3;
  84677. /**
  84678. * Returns a Color3 value containing a random color
  84679. * @returns a new Color3 object
  84680. */
  84681. static Random(): Color3;
  84682. }
  84683. /**
  84684. * Class used to hold a RBGA color
  84685. */
  84686. export class Color4 {
  84687. /**
  84688. * Defines the red component (between 0 and 1, default is 0)
  84689. */
  84690. r: number;
  84691. /**
  84692. * Defines the green component (between 0 and 1, default is 0)
  84693. */
  84694. g: number;
  84695. /**
  84696. * Defines the blue component (between 0 and 1, default is 0)
  84697. */
  84698. b: number;
  84699. /**
  84700. * Defines the alpha component (between 0 and 1, default is 1)
  84701. */
  84702. a: number;
  84703. /**
  84704. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84705. * @param r defines the red component (between 0 and 1, default is 0)
  84706. * @param g defines the green component (between 0 and 1, default is 0)
  84707. * @param b defines the blue component (between 0 and 1, default is 0)
  84708. * @param a defines the alpha component (between 0 and 1, default is 1)
  84709. */
  84710. constructor(
  84711. /**
  84712. * Defines the red component (between 0 and 1, default is 0)
  84713. */
  84714. r?: number,
  84715. /**
  84716. * Defines the green component (between 0 and 1, default is 0)
  84717. */
  84718. g?: number,
  84719. /**
  84720. * Defines the blue component (between 0 and 1, default is 0)
  84721. */
  84722. b?: number,
  84723. /**
  84724. * Defines the alpha component (between 0 and 1, default is 1)
  84725. */
  84726. a?: number);
  84727. /**
  84728. * Adds in place the given Color4 values to the current Color4 object
  84729. * @param right defines the second operand
  84730. * @returns the current updated Color4 object
  84731. */
  84732. addInPlace(right: DeepImmutable<Color4>): Color4;
  84733. /**
  84734. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84735. * @returns the new array
  84736. */
  84737. asArray(): number[];
  84738. /**
  84739. * Stores from the starting index in the given array the Color4 successive values
  84740. * @param array defines the array where to store the r,g,b components
  84741. * @param index defines an optional index in the target array to define where to start storing values
  84742. * @returns the current Color4 object
  84743. */
  84744. toArray(array: number[], index?: number): Color4;
  84745. /**
  84746. * Update the current color with values stored in an array from the starting index of the given array
  84747. * @param array defines the source array
  84748. * @param offset defines an offset in the source array
  84749. * @returns the current Color4 object
  84750. */
  84751. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84752. /**
  84753. * Determines equality between Color4 objects
  84754. * @param otherColor defines the second operand
  84755. * @returns true if the rgba values are equal to the given ones
  84756. */
  84757. equals(otherColor: DeepImmutable<Color4>): boolean;
  84758. /**
  84759. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84760. * @param right defines the second operand
  84761. * @returns a new Color4 object
  84762. */
  84763. add(right: DeepImmutable<Color4>): Color4;
  84764. /**
  84765. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84766. * @param right defines the second operand
  84767. * @returns a new Color4 object
  84768. */
  84769. subtract(right: DeepImmutable<Color4>): Color4;
  84770. /**
  84771. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84772. * @param right defines the second operand
  84773. * @param result defines the Color4 object where to store the result
  84774. * @returns the current Color4 object
  84775. */
  84776. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84777. /**
  84778. * Creates a new Color4 with the current Color4 values multiplied by scale
  84779. * @param scale defines the scaling factor to apply
  84780. * @returns a new Color4 object
  84781. */
  84782. scale(scale: number): Color4;
  84783. /**
  84784. * Multiplies the current Color4 values by scale and stores the result in "result"
  84785. * @param scale defines the scaling factor to apply
  84786. * @param result defines the Color4 object where to store the result
  84787. * @returns the current unmodified Color4
  84788. */
  84789. scaleToRef(scale: number, result: Color4): Color4;
  84790. /**
  84791. * Scale the current Color4 values by a factor and add the result to a given Color4
  84792. * @param scale defines the scale factor
  84793. * @param result defines the Color4 object where to store the result
  84794. * @returns the unmodified current Color4
  84795. */
  84796. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84797. /**
  84798. * Clamps the rgb values by the min and max values and stores the result into "result"
  84799. * @param min defines minimum clamping value (default is 0)
  84800. * @param max defines maximum clamping value (default is 1)
  84801. * @param result defines color to store the result into.
  84802. * @returns the cuurent Color4
  84803. */
  84804. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84805. /**
  84806. * Multipy an Color4 value by another and return a new Color4 object
  84807. * @param color defines the Color4 value to multiply by
  84808. * @returns a new Color4 object
  84809. */
  84810. multiply(color: Color4): Color4;
  84811. /**
  84812. * Multipy a Color4 value by another and push the result in a reference value
  84813. * @param color defines the Color4 value to multiply by
  84814. * @param result defines the Color4 to fill the result in
  84815. * @returns the result Color4
  84816. */
  84817. multiplyToRef(color: Color4, result: Color4): Color4;
  84818. /**
  84819. * Creates a string with the Color4 current values
  84820. * @returns the string representation of the Color4 object
  84821. */
  84822. toString(): string;
  84823. /**
  84824. * Returns the string "Color4"
  84825. * @returns "Color4"
  84826. */
  84827. getClassName(): string;
  84828. /**
  84829. * Compute the Color4 hash code
  84830. * @returns an unique number that can be used to hash Color4 objects
  84831. */
  84832. getHashCode(): number;
  84833. /**
  84834. * Creates a new Color4 copied from the current one
  84835. * @returns a new Color4 object
  84836. */
  84837. clone(): Color4;
  84838. /**
  84839. * Copies the given Color4 values into the current one
  84840. * @param source defines the source Color4 object
  84841. * @returns the current updated Color4 object
  84842. */
  84843. copyFrom(source: Color4): Color4;
  84844. /**
  84845. * Copies the given float values into the current one
  84846. * @param r defines the red component to read from
  84847. * @param g defines the green component to read from
  84848. * @param b defines the blue component to read from
  84849. * @param a defines the alpha component to read from
  84850. * @returns the current updated Color4 object
  84851. */
  84852. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84853. /**
  84854. * Copies the given float values into the current one
  84855. * @param r defines the red component to read from
  84856. * @param g defines the green component to read from
  84857. * @param b defines the blue component to read from
  84858. * @param a defines the alpha component to read from
  84859. * @returns the current updated Color4 object
  84860. */
  84861. set(r: number, g: number, b: number, a: number): Color4;
  84862. /**
  84863. * Compute the Color4 hexadecimal code as a string
  84864. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84865. * @returns a string containing the hexadecimal representation of the Color4 object
  84866. */
  84867. toHexString(returnAsColor3?: boolean): string;
  84868. /**
  84869. * Computes a new Color4 converted from the current one to linear space
  84870. * @returns a new Color4 object
  84871. */
  84872. toLinearSpace(): Color4;
  84873. /**
  84874. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84875. * @param convertedColor defines the Color4 object where to store the linear space version
  84876. * @returns the unmodified Color4
  84877. */
  84878. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84879. /**
  84880. * Computes a new Color4 converted from the current one to gamma space
  84881. * @returns a new Color4 object
  84882. */
  84883. toGammaSpace(): Color4;
  84884. /**
  84885. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84886. * @param convertedColor defines the Color4 object where to store the gamma space version
  84887. * @returns the unmodified Color4
  84888. */
  84889. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84890. /**
  84891. * Creates a new Color4 from the string containing valid hexadecimal values
  84892. * @param hex defines a string containing valid hexadecimal values
  84893. * @returns a new Color4 object
  84894. */
  84895. static FromHexString(hex: string): Color4;
  84896. /**
  84897. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84898. * @param left defines the start value
  84899. * @param right defines the end value
  84900. * @param amount defines the gradient factor
  84901. * @returns a new Color4 object
  84902. */
  84903. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84904. /**
  84905. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84906. * @param left defines the start value
  84907. * @param right defines the end value
  84908. * @param amount defines the gradient factor
  84909. * @param result defines the Color4 object where to store data
  84910. */
  84911. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84912. /**
  84913. * Creates a new Color4 from a Color3 and an alpha value
  84914. * @param color3 defines the source Color3 to read from
  84915. * @param alpha defines the alpha component (1.0 by default)
  84916. * @returns a new Color4 object
  84917. */
  84918. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84919. /**
  84920. * Creates a new Color4 from the starting index element of the given array
  84921. * @param array defines the source array to read from
  84922. * @param offset defines the offset in the source array
  84923. * @returns a new Color4 object
  84924. */
  84925. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84926. /**
  84927. * Creates a new Color4 from the starting index element of the given array
  84928. * @param array defines the source array to read from
  84929. * @param offset defines the offset in the source array
  84930. * @param result defines the target Color4 object
  84931. */
  84932. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  84933. /**
  84934. * Creates a new Color3 from integer values (< 256)
  84935. * @param r defines the red component to read from (value between 0 and 255)
  84936. * @param g defines the green component to read from (value between 0 and 255)
  84937. * @param b defines the blue component to read from (value between 0 and 255)
  84938. * @param a defines the alpha component to read from (value between 0 and 255)
  84939. * @returns a new Color3 object
  84940. */
  84941. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84942. /**
  84943. * Check the content of a given array and convert it to an array containing RGBA data
  84944. * If the original array was already containing count * 4 values then it is returned directly
  84945. * @param colors defines the array to check
  84946. * @param count defines the number of RGBA data to expect
  84947. * @returns an array containing count * 4 values (RGBA)
  84948. */
  84949. static CheckColors4(colors: number[], count: number): number[];
  84950. }
  84951. /**
  84952. * @hidden
  84953. */
  84954. export class TmpColors {
  84955. static Color3: Color3[];
  84956. static Color4: Color4[];
  84957. }
  84958. }
  84959. declare module BABYLON {
  84960. /**
  84961. * Defines an interface which represents an animation key frame
  84962. */
  84963. export interface IAnimationKey {
  84964. /**
  84965. * Frame of the key frame
  84966. */
  84967. frame: number;
  84968. /**
  84969. * Value at the specifies key frame
  84970. */
  84971. value: any;
  84972. /**
  84973. * The input tangent for the cubic hermite spline
  84974. */
  84975. inTangent?: any;
  84976. /**
  84977. * The output tangent for the cubic hermite spline
  84978. */
  84979. outTangent?: any;
  84980. /**
  84981. * The animation interpolation type
  84982. */
  84983. interpolation?: AnimationKeyInterpolation;
  84984. }
  84985. /**
  84986. * Enum for the animation key frame interpolation type
  84987. */
  84988. export enum AnimationKeyInterpolation {
  84989. /**
  84990. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84991. */
  84992. STEP = 1
  84993. }
  84994. }
  84995. declare module BABYLON {
  84996. /**
  84997. * Represents the range of an animation
  84998. */
  84999. export class AnimationRange {
  85000. /**The name of the animation range**/
  85001. name: string;
  85002. /**The starting frame of the animation */
  85003. from: number;
  85004. /**The ending frame of the animation*/
  85005. to: number;
  85006. /**
  85007. * Initializes the range of an animation
  85008. * @param name The name of the animation range
  85009. * @param from The starting frame of the animation
  85010. * @param to The ending frame of the animation
  85011. */
  85012. constructor(
  85013. /**The name of the animation range**/
  85014. name: string,
  85015. /**The starting frame of the animation */
  85016. from: number,
  85017. /**The ending frame of the animation*/
  85018. to: number);
  85019. /**
  85020. * Makes a copy of the animation range
  85021. * @returns A copy of the animation range
  85022. */
  85023. clone(): AnimationRange;
  85024. }
  85025. }
  85026. declare module BABYLON {
  85027. /**
  85028. * Composed of a frame, and an action function
  85029. */
  85030. export class AnimationEvent {
  85031. /** The frame for which the event is triggered **/
  85032. frame: number;
  85033. /** The event to perform when triggered **/
  85034. action: (currentFrame: number) => void;
  85035. /** Specifies if the event should be triggered only once**/
  85036. onlyOnce?: boolean | undefined;
  85037. /**
  85038. * Specifies if the animation event is done
  85039. */
  85040. isDone: boolean;
  85041. /**
  85042. * Initializes the animation event
  85043. * @param frame The frame for which the event is triggered
  85044. * @param action The event to perform when triggered
  85045. * @param onlyOnce Specifies if the event should be triggered only once
  85046. */
  85047. constructor(
  85048. /** The frame for which the event is triggered **/
  85049. frame: number,
  85050. /** The event to perform when triggered **/
  85051. action: (currentFrame: number) => void,
  85052. /** Specifies if the event should be triggered only once**/
  85053. onlyOnce?: boolean | undefined);
  85054. /** @hidden */
  85055. _clone(): AnimationEvent;
  85056. }
  85057. }
  85058. declare module BABYLON {
  85059. /**
  85060. * Interface used to define a behavior
  85061. */
  85062. export interface Behavior<T> {
  85063. /** gets or sets behavior's name */
  85064. name: string;
  85065. /**
  85066. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85067. */
  85068. init(): void;
  85069. /**
  85070. * Called when the behavior is attached to a target
  85071. * @param target defines the target where the behavior is attached to
  85072. */
  85073. attach(target: T): void;
  85074. /**
  85075. * Called when the behavior is detached from its target
  85076. */
  85077. detach(): void;
  85078. }
  85079. /**
  85080. * Interface implemented by classes supporting behaviors
  85081. */
  85082. export interface IBehaviorAware<T> {
  85083. /**
  85084. * Attach a behavior
  85085. * @param behavior defines the behavior to attach
  85086. * @returns the current host
  85087. */
  85088. addBehavior(behavior: Behavior<T>): T;
  85089. /**
  85090. * Remove a behavior from the current object
  85091. * @param behavior defines the behavior to detach
  85092. * @returns the current host
  85093. */
  85094. removeBehavior(behavior: Behavior<T>): T;
  85095. /**
  85096. * Gets a behavior using its name to search
  85097. * @param name defines the name to search
  85098. * @returns the behavior or null if not found
  85099. */
  85100. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85101. }
  85102. }
  85103. declare module BABYLON {
  85104. /**
  85105. * Defines an array and its length.
  85106. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85107. */
  85108. export interface ISmartArrayLike<T> {
  85109. /**
  85110. * The data of the array.
  85111. */
  85112. data: Array<T>;
  85113. /**
  85114. * The active length of the array.
  85115. */
  85116. length: number;
  85117. }
  85118. /**
  85119. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85120. */
  85121. export class SmartArray<T> implements ISmartArrayLike<T> {
  85122. /**
  85123. * The full set of data from the array.
  85124. */
  85125. data: Array<T>;
  85126. /**
  85127. * The active length of the array.
  85128. */
  85129. length: number;
  85130. protected _id: number;
  85131. /**
  85132. * Instantiates a Smart Array.
  85133. * @param capacity defines the default capacity of the array.
  85134. */
  85135. constructor(capacity: number);
  85136. /**
  85137. * Pushes a value at the end of the active data.
  85138. * @param value defines the object to push in the array.
  85139. */
  85140. push(value: T): void;
  85141. /**
  85142. * Iterates over the active data and apply the lambda to them.
  85143. * @param func defines the action to apply on each value.
  85144. */
  85145. forEach(func: (content: T) => void): void;
  85146. /**
  85147. * Sorts the full sets of data.
  85148. * @param compareFn defines the comparison function to apply.
  85149. */
  85150. sort(compareFn: (a: T, b: T) => number): void;
  85151. /**
  85152. * Resets the active data to an empty array.
  85153. */
  85154. reset(): void;
  85155. /**
  85156. * Releases all the data from the array as well as the array.
  85157. */
  85158. dispose(): void;
  85159. /**
  85160. * Concats the active data with a given array.
  85161. * @param array defines the data to concatenate with.
  85162. */
  85163. concat(array: any): void;
  85164. /**
  85165. * Returns the position of a value in the active data.
  85166. * @param value defines the value to find the index for
  85167. * @returns the index if found in the active data otherwise -1
  85168. */
  85169. indexOf(value: T): number;
  85170. /**
  85171. * Returns whether an element is part of the active data.
  85172. * @param value defines the value to look for
  85173. * @returns true if found in the active data otherwise false
  85174. */
  85175. contains(value: T): boolean;
  85176. private static _GlobalId;
  85177. }
  85178. /**
  85179. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85180. * The data in this array can only be present once
  85181. */
  85182. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85183. private _duplicateId;
  85184. /**
  85185. * Pushes a value at the end of the active data.
  85186. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85187. * @param value defines the object to push in the array.
  85188. */
  85189. push(value: T): void;
  85190. /**
  85191. * Pushes a value at the end of the active data.
  85192. * If the data is already present, it won t be added again
  85193. * @param value defines the object to push in the array.
  85194. * @returns true if added false if it was already present
  85195. */
  85196. pushNoDuplicate(value: T): boolean;
  85197. /**
  85198. * Resets the active data to an empty array.
  85199. */
  85200. reset(): void;
  85201. /**
  85202. * Concats the active data with a given array.
  85203. * This ensures no dupplicate will be present in the result.
  85204. * @param array defines the data to concatenate with.
  85205. */
  85206. concatWithNoDuplicate(array: any): void;
  85207. }
  85208. }
  85209. declare module BABYLON {
  85210. /**
  85211. * @ignore
  85212. * This is a list of all the different input types that are available in the application.
  85213. * Fo instance: ArcRotateCameraGamepadInput...
  85214. */
  85215. export var CameraInputTypes: {};
  85216. /**
  85217. * This is the contract to implement in order to create a new input class.
  85218. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85219. */
  85220. export interface ICameraInput<TCamera extends Camera> {
  85221. /**
  85222. * Defines the camera the input is attached to.
  85223. */
  85224. camera: Nullable<TCamera>;
  85225. /**
  85226. * Gets the class name of the current intput.
  85227. * @returns the class name
  85228. */
  85229. getClassName(): string;
  85230. /**
  85231. * Get the friendly name associated with the input class.
  85232. * @returns the input friendly name
  85233. */
  85234. getSimpleName(): string;
  85235. /**
  85236. * Attach the input controls to a specific dom element to get the input from.
  85237. * @param element Defines the element the controls should be listened from
  85238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85239. */
  85240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85241. /**
  85242. * Detach the current controls from the specified dom element.
  85243. * @param element Defines the element to stop listening the inputs from
  85244. */
  85245. detachControl(element: Nullable<HTMLElement>): void;
  85246. /**
  85247. * Update the current camera state depending on the inputs that have been used this frame.
  85248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85249. */
  85250. checkInputs?: () => void;
  85251. }
  85252. /**
  85253. * Represents a map of input types to input instance or input index to input instance.
  85254. */
  85255. export interface CameraInputsMap<TCamera extends Camera> {
  85256. /**
  85257. * Accessor to the input by input type.
  85258. */
  85259. [name: string]: ICameraInput<TCamera>;
  85260. /**
  85261. * Accessor to the input by input index.
  85262. */
  85263. [idx: number]: ICameraInput<TCamera>;
  85264. }
  85265. /**
  85266. * This represents the input manager used within a camera.
  85267. * It helps dealing with all the different kind of input attached to a camera.
  85268. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85269. */
  85270. export class CameraInputsManager<TCamera extends Camera> {
  85271. /**
  85272. * Defines the list of inputs attahed to the camera.
  85273. */
  85274. attached: CameraInputsMap<TCamera>;
  85275. /**
  85276. * Defines the dom element the camera is collecting inputs from.
  85277. * This is null if the controls have not been attached.
  85278. */
  85279. attachedElement: Nullable<HTMLElement>;
  85280. /**
  85281. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85282. */
  85283. noPreventDefault: boolean;
  85284. /**
  85285. * Defined the camera the input manager belongs to.
  85286. */
  85287. camera: TCamera;
  85288. /**
  85289. * Update the current camera state depending on the inputs that have been used this frame.
  85290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85291. */
  85292. checkInputs: () => void;
  85293. /**
  85294. * Instantiate a new Camera Input Manager.
  85295. * @param camera Defines the camera the input manager blongs to
  85296. */
  85297. constructor(camera: TCamera);
  85298. /**
  85299. * Add an input method to a camera
  85300. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85301. * @param input camera input method
  85302. */
  85303. add(input: ICameraInput<TCamera>): void;
  85304. /**
  85305. * Remove a specific input method from a camera
  85306. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  85307. * @param inputToRemove camera input method
  85308. */
  85309. remove(inputToRemove: ICameraInput<TCamera>): void;
  85310. /**
  85311. * Remove a specific input type from a camera
  85312. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  85313. * @param inputType the type of the input to remove
  85314. */
  85315. removeByType(inputType: string): void;
  85316. private _addCheckInputs;
  85317. /**
  85318. * Attach the input controls to the currently attached dom element to listen the events from.
  85319. * @param input Defines the input to attach
  85320. */
  85321. attachInput(input: ICameraInput<TCamera>): void;
  85322. /**
  85323. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  85324. * @param element Defines the dom element to collect the events from
  85325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85326. */
  85327. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  85328. /**
  85329. * Detach the current manager inputs controls from a specific dom element.
  85330. * @param element Defines the dom element to collect the events from
  85331. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  85332. */
  85333. detachElement(element: HTMLElement, disconnect?: boolean): void;
  85334. /**
  85335. * Rebuild the dynamic inputCheck function from the current list of
  85336. * defined inputs in the manager.
  85337. */
  85338. rebuildInputCheck(): void;
  85339. /**
  85340. * Remove all attached input methods from a camera
  85341. */
  85342. clear(): void;
  85343. /**
  85344. * Serialize the current input manager attached to a camera.
  85345. * This ensures than once parsed,
  85346. * the input associated to the camera will be identical to the current ones
  85347. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  85348. */
  85349. serialize(serializedCamera: any): void;
  85350. /**
  85351. * Parses an input manager serialized JSON to restore the previous list of inputs
  85352. * and states associated to a camera.
  85353. * @param parsedCamera Defines the JSON to parse
  85354. */
  85355. parse(parsedCamera: any): void;
  85356. }
  85357. }
  85358. declare module BABYLON {
  85359. /**
  85360. * Class used to store data that will be store in GPU memory
  85361. */
  85362. export class Buffer {
  85363. private _engine;
  85364. private _buffer;
  85365. /** @hidden */
  85366. _data: Nullable<DataArray>;
  85367. private _updatable;
  85368. private _instanced;
  85369. private _divisor;
  85370. /**
  85371. * Gets the byte stride.
  85372. */
  85373. readonly byteStride: number;
  85374. /**
  85375. * Constructor
  85376. * @param engine the engine
  85377. * @param data the data to use for this buffer
  85378. * @param updatable whether the data is updatable
  85379. * @param stride the stride (optional)
  85380. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85381. * @param instanced whether the buffer is instanced (optional)
  85382. * @param useBytes set to true if the stride in in bytes (optional)
  85383. * @param divisor sets an optional divisor for instances (1 by default)
  85384. */
  85385. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85386. /**
  85387. * Create a new VertexBuffer based on the current buffer
  85388. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85389. * @param offset defines offset in the buffer (0 by default)
  85390. * @param size defines the size in floats of attributes (position is 3 for instance)
  85391. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85392. * @param instanced defines if the vertex buffer contains indexed data
  85393. * @param useBytes defines if the offset and stride are in bytes *
  85394. * @param divisor sets an optional divisor for instances (1 by default)
  85395. * @returns the new vertex buffer
  85396. */
  85397. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85398. /**
  85399. * Gets a boolean indicating if the Buffer is updatable?
  85400. * @returns true if the buffer is updatable
  85401. */
  85402. isUpdatable(): boolean;
  85403. /**
  85404. * Gets current buffer's data
  85405. * @returns a DataArray or null
  85406. */
  85407. getData(): Nullable<DataArray>;
  85408. /**
  85409. * Gets underlying native buffer
  85410. * @returns underlying native buffer
  85411. */
  85412. getBuffer(): Nullable<DataBuffer>;
  85413. /**
  85414. * Gets the stride in float32 units (i.e. byte stride / 4).
  85415. * May not be an integer if the byte stride is not divisible by 4.
  85416. * @returns the stride in float32 units
  85417. * @deprecated Please use byteStride instead.
  85418. */
  85419. getStrideSize(): number;
  85420. /**
  85421. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85422. * @param data defines the data to store
  85423. */
  85424. create(data?: Nullable<DataArray>): void;
  85425. /** @hidden */
  85426. _rebuild(): void;
  85427. /**
  85428. * Update current buffer data
  85429. * @param data defines the data to store
  85430. */
  85431. update(data: DataArray): void;
  85432. /**
  85433. * Updates the data directly.
  85434. * @param data the new data
  85435. * @param offset the new offset
  85436. * @param vertexCount the vertex count (optional)
  85437. * @param useBytes set to true if the offset is in bytes
  85438. */
  85439. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85440. /**
  85441. * Release all resources
  85442. */
  85443. dispose(): void;
  85444. }
  85445. /**
  85446. * Specialized buffer used to store vertex data
  85447. */
  85448. export class VertexBuffer {
  85449. /** @hidden */
  85450. _buffer: Buffer;
  85451. private _kind;
  85452. private _size;
  85453. private _ownsBuffer;
  85454. private _instanced;
  85455. private _instanceDivisor;
  85456. /**
  85457. * The byte type.
  85458. */
  85459. static readonly BYTE: number;
  85460. /**
  85461. * The unsigned byte type.
  85462. */
  85463. static readonly UNSIGNED_BYTE: number;
  85464. /**
  85465. * The short type.
  85466. */
  85467. static readonly SHORT: number;
  85468. /**
  85469. * The unsigned short type.
  85470. */
  85471. static readonly UNSIGNED_SHORT: number;
  85472. /**
  85473. * The integer type.
  85474. */
  85475. static readonly INT: number;
  85476. /**
  85477. * The unsigned integer type.
  85478. */
  85479. static readonly UNSIGNED_INT: number;
  85480. /**
  85481. * The float type.
  85482. */
  85483. static readonly FLOAT: number;
  85484. /**
  85485. * Gets or sets the instance divisor when in instanced mode
  85486. */
  85487. get instanceDivisor(): number;
  85488. set instanceDivisor(value: number);
  85489. /**
  85490. * Gets the byte stride.
  85491. */
  85492. readonly byteStride: number;
  85493. /**
  85494. * Gets the byte offset.
  85495. */
  85496. readonly byteOffset: number;
  85497. /**
  85498. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85499. */
  85500. readonly normalized: boolean;
  85501. /**
  85502. * Gets the data type of each component in the array.
  85503. */
  85504. readonly type: number;
  85505. /**
  85506. * Constructor
  85507. * @param engine the engine
  85508. * @param data the data to use for this vertex buffer
  85509. * @param kind the vertex buffer kind
  85510. * @param updatable whether the data is updatable
  85511. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85512. * @param stride the stride (optional)
  85513. * @param instanced whether the buffer is instanced (optional)
  85514. * @param offset the offset of the data (optional)
  85515. * @param size the number of components (optional)
  85516. * @param type the type of the component (optional)
  85517. * @param normalized whether the data contains normalized data (optional)
  85518. * @param useBytes set to true if stride and offset are in bytes (optional)
  85519. * @param divisor defines the instance divisor to use (1 by default)
  85520. */
  85521. 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);
  85522. /** @hidden */
  85523. _rebuild(): void;
  85524. /**
  85525. * Returns the kind of the VertexBuffer (string)
  85526. * @returns a string
  85527. */
  85528. getKind(): string;
  85529. /**
  85530. * Gets a boolean indicating if the VertexBuffer is updatable?
  85531. * @returns true if the buffer is updatable
  85532. */
  85533. isUpdatable(): boolean;
  85534. /**
  85535. * Gets current buffer's data
  85536. * @returns a DataArray or null
  85537. */
  85538. getData(): Nullable<DataArray>;
  85539. /**
  85540. * Gets underlying native buffer
  85541. * @returns underlying native buffer
  85542. */
  85543. getBuffer(): Nullable<DataBuffer>;
  85544. /**
  85545. * Gets the stride in float32 units (i.e. byte stride / 4).
  85546. * May not be an integer if the byte stride is not divisible by 4.
  85547. * @returns the stride in float32 units
  85548. * @deprecated Please use byteStride instead.
  85549. */
  85550. getStrideSize(): number;
  85551. /**
  85552. * Returns the offset as a multiple of the type byte length.
  85553. * @returns the offset in bytes
  85554. * @deprecated Please use byteOffset instead.
  85555. */
  85556. getOffset(): number;
  85557. /**
  85558. * Returns the number of components per vertex attribute (integer)
  85559. * @returns the size in float
  85560. */
  85561. getSize(): number;
  85562. /**
  85563. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85564. * @returns true if this buffer is instanced
  85565. */
  85566. getIsInstanced(): boolean;
  85567. /**
  85568. * Returns the instancing divisor, zero for non-instanced (integer).
  85569. * @returns a number
  85570. */
  85571. getInstanceDivisor(): number;
  85572. /**
  85573. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85574. * @param data defines the data to store
  85575. */
  85576. create(data?: DataArray): void;
  85577. /**
  85578. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85579. * This function will create a new buffer if the current one is not updatable
  85580. * @param data defines the data to store
  85581. */
  85582. update(data: DataArray): void;
  85583. /**
  85584. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85585. * Returns the directly updated WebGLBuffer.
  85586. * @param data the new data
  85587. * @param offset the new offset
  85588. * @param useBytes set to true if the offset is in bytes
  85589. */
  85590. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85591. /**
  85592. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85593. */
  85594. dispose(): void;
  85595. /**
  85596. * Enumerates each value of this vertex buffer as numbers.
  85597. * @param count the number of values to enumerate
  85598. * @param callback the callback function called for each value
  85599. */
  85600. forEach(count: number, callback: (value: number, index: number) => void): void;
  85601. /**
  85602. * Positions
  85603. */
  85604. static readonly PositionKind: string;
  85605. /**
  85606. * Normals
  85607. */
  85608. static readonly NormalKind: string;
  85609. /**
  85610. * Tangents
  85611. */
  85612. static readonly TangentKind: string;
  85613. /**
  85614. * Texture coordinates
  85615. */
  85616. static readonly UVKind: string;
  85617. /**
  85618. * Texture coordinates 2
  85619. */
  85620. static readonly UV2Kind: string;
  85621. /**
  85622. * Texture coordinates 3
  85623. */
  85624. static readonly UV3Kind: string;
  85625. /**
  85626. * Texture coordinates 4
  85627. */
  85628. static readonly UV4Kind: string;
  85629. /**
  85630. * Texture coordinates 5
  85631. */
  85632. static readonly UV5Kind: string;
  85633. /**
  85634. * Texture coordinates 6
  85635. */
  85636. static readonly UV6Kind: string;
  85637. /**
  85638. * Colors
  85639. */
  85640. static readonly ColorKind: string;
  85641. /**
  85642. * Matrix indices (for bones)
  85643. */
  85644. static readonly MatricesIndicesKind: string;
  85645. /**
  85646. * Matrix weights (for bones)
  85647. */
  85648. static readonly MatricesWeightsKind: string;
  85649. /**
  85650. * Additional matrix indices (for bones)
  85651. */
  85652. static readonly MatricesIndicesExtraKind: string;
  85653. /**
  85654. * Additional matrix weights (for bones)
  85655. */
  85656. static readonly MatricesWeightsExtraKind: string;
  85657. /**
  85658. * Deduces the stride given a kind.
  85659. * @param kind The kind string to deduce
  85660. * @returns The deduced stride
  85661. */
  85662. static DeduceStride(kind: string): number;
  85663. /**
  85664. * Gets the byte length of the given type.
  85665. * @param type the type
  85666. * @returns the number of bytes
  85667. */
  85668. static GetTypeByteLength(type: number): number;
  85669. /**
  85670. * Enumerates each value of the given parameters as numbers.
  85671. * @param data the data to enumerate
  85672. * @param byteOffset the byte offset of the data
  85673. * @param byteStride the byte stride of the data
  85674. * @param componentCount the number of components per element
  85675. * @param componentType the type of the component
  85676. * @param count the number of values to enumerate
  85677. * @param normalized whether the data is normalized
  85678. * @param callback the callback function called for each value
  85679. */
  85680. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85681. private static _GetFloatValue;
  85682. }
  85683. }
  85684. declare module BABYLON {
  85685. /**
  85686. * @hidden
  85687. */
  85688. export class IntersectionInfo {
  85689. bu: Nullable<number>;
  85690. bv: Nullable<number>;
  85691. distance: number;
  85692. faceId: number;
  85693. subMeshId: number;
  85694. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85695. }
  85696. }
  85697. declare module BABYLON {
  85698. /**
  85699. * Class used to store bounding sphere information
  85700. */
  85701. export class BoundingSphere {
  85702. /**
  85703. * Gets the center of the bounding sphere in local space
  85704. */
  85705. readonly center: Vector3;
  85706. /**
  85707. * Radius of the bounding sphere in local space
  85708. */
  85709. radius: number;
  85710. /**
  85711. * Gets the center of the bounding sphere in world space
  85712. */
  85713. readonly centerWorld: Vector3;
  85714. /**
  85715. * Radius of the bounding sphere in world space
  85716. */
  85717. radiusWorld: number;
  85718. /**
  85719. * Gets the minimum vector in local space
  85720. */
  85721. readonly minimum: Vector3;
  85722. /**
  85723. * Gets the maximum vector in local space
  85724. */
  85725. readonly maximum: Vector3;
  85726. private _worldMatrix;
  85727. private static readonly TmpVector3;
  85728. /**
  85729. * Creates a new bounding sphere
  85730. * @param min defines the minimum vector (in local space)
  85731. * @param max defines the maximum vector (in local space)
  85732. * @param worldMatrix defines the new world matrix
  85733. */
  85734. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85735. /**
  85736. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85737. * @param min defines the new minimum vector (in local space)
  85738. * @param max defines the new maximum vector (in local space)
  85739. * @param worldMatrix defines the new world matrix
  85740. */
  85741. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85742. /**
  85743. * Scale the current bounding sphere by applying a scale factor
  85744. * @param factor defines the scale factor to apply
  85745. * @returns the current bounding box
  85746. */
  85747. scale(factor: number): BoundingSphere;
  85748. /**
  85749. * Gets the world matrix of the bounding box
  85750. * @returns a matrix
  85751. */
  85752. getWorldMatrix(): DeepImmutable<Matrix>;
  85753. /** @hidden */
  85754. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85755. /**
  85756. * Tests if the bounding sphere is intersecting the frustum planes
  85757. * @param frustumPlanes defines the frustum planes to test
  85758. * @returns true if there is an intersection
  85759. */
  85760. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85761. /**
  85762. * Tests if the bounding sphere center is in between the frustum planes.
  85763. * Used for optimistic fast inclusion.
  85764. * @param frustumPlanes defines the frustum planes to test
  85765. * @returns true if the sphere center is in between the frustum planes
  85766. */
  85767. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85768. /**
  85769. * Tests if a point is inside the bounding sphere
  85770. * @param point defines the point to test
  85771. * @returns true if the point is inside the bounding sphere
  85772. */
  85773. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85774. /**
  85775. * Checks if two sphere intersct
  85776. * @param sphere0 sphere 0
  85777. * @param sphere1 sphere 1
  85778. * @returns true if the speres intersect
  85779. */
  85780. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85781. }
  85782. }
  85783. declare module BABYLON {
  85784. /**
  85785. * Class used to store bounding box information
  85786. */
  85787. export class BoundingBox implements ICullable {
  85788. /**
  85789. * Gets the 8 vectors representing the bounding box in local space
  85790. */
  85791. readonly vectors: Vector3[];
  85792. /**
  85793. * Gets the center of the bounding box in local space
  85794. */
  85795. readonly center: Vector3;
  85796. /**
  85797. * Gets the center of the bounding box in world space
  85798. */
  85799. readonly centerWorld: Vector3;
  85800. /**
  85801. * Gets the extend size in local space
  85802. */
  85803. readonly extendSize: Vector3;
  85804. /**
  85805. * Gets the extend size in world space
  85806. */
  85807. readonly extendSizeWorld: Vector3;
  85808. /**
  85809. * Gets the OBB (object bounding box) directions
  85810. */
  85811. readonly directions: Vector3[];
  85812. /**
  85813. * Gets the 8 vectors representing the bounding box in world space
  85814. */
  85815. readonly vectorsWorld: Vector3[];
  85816. /**
  85817. * Gets the minimum vector in world space
  85818. */
  85819. readonly minimumWorld: Vector3;
  85820. /**
  85821. * Gets the maximum vector in world space
  85822. */
  85823. readonly maximumWorld: Vector3;
  85824. /**
  85825. * Gets the minimum vector in local space
  85826. */
  85827. readonly minimum: Vector3;
  85828. /**
  85829. * Gets the maximum vector in local space
  85830. */
  85831. readonly maximum: Vector3;
  85832. private _worldMatrix;
  85833. private static readonly TmpVector3;
  85834. /**
  85835. * @hidden
  85836. */
  85837. _tag: number;
  85838. /**
  85839. * Creates a new bounding box
  85840. * @param min defines the minimum vector (in local space)
  85841. * @param max defines the maximum vector (in local space)
  85842. * @param worldMatrix defines the new world matrix
  85843. */
  85844. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85845. /**
  85846. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85847. * @param min defines the new minimum vector (in local space)
  85848. * @param max defines the new maximum vector (in local space)
  85849. * @param worldMatrix defines the new world matrix
  85850. */
  85851. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85852. /**
  85853. * Scale the current bounding box by applying a scale factor
  85854. * @param factor defines the scale factor to apply
  85855. * @returns the current bounding box
  85856. */
  85857. scale(factor: number): BoundingBox;
  85858. /**
  85859. * Gets the world matrix of the bounding box
  85860. * @returns a matrix
  85861. */
  85862. getWorldMatrix(): DeepImmutable<Matrix>;
  85863. /** @hidden */
  85864. _update(world: DeepImmutable<Matrix>): void;
  85865. /**
  85866. * Tests if the bounding box is intersecting the frustum planes
  85867. * @param frustumPlanes defines the frustum planes to test
  85868. * @returns true if there is an intersection
  85869. */
  85870. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85871. /**
  85872. * Tests if the bounding box is entirely inside the frustum planes
  85873. * @param frustumPlanes defines the frustum planes to test
  85874. * @returns true if there is an inclusion
  85875. */
  85876. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85877. /**
  85878. * Tests if a point is inside the bounding box
  85879. * @param point defines the point to test
  85880. * @returns true if the point is inside the bounding box
  85881. */
  85882. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85883. /**
  85884. * Tests if the bounding box intersects with a bounding sphere
  85885. * @param sphere defines the sphere to test
  85886. * @returns true if there is an intersection
  85887. */
  85888. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85889. /**
  85890. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85891. * @param min defines the min vector to use
  85892. * @param max defines the max vector to use
  85893. * @returns true if there is an intersection
  85894. */
  85895. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85896. /**
  85897. * Tests if two bounding boxes are intersections
  85898. * @param box0 defines the first box to test
  85899. * @param box1 defines the second box to test
  85900. * @returns true if there is an intersection
  85901. */
  85902. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85903. /**
  85904. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85905. * @param minPoint defines the minimum vector of the bounding box
  85906. * @param maxPoint defines the maximum vector of the bounding box
  85907. * @param sphereCenter defines the sphere center
  85908. * @param sphereRadius defines the sphere radius
  85909. * @returns true if there is an intersection
  85910. */
  85911. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85912. /**
  85913. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85914. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85915. * @param frustumPlanes defines the frustum planes to test
  85916. * @return true if there is an inclusion
  85917. */
  85918. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85919. /**
  85920. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85921. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85922. * @param frustumPlanes defines the frustum planes to test
  85923. * @return true if there is an intersection
  85924. */
  85925. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85926. }
  85927. }
  85928. declare module BABYLON {
  85929. /** @hidden */
  85930. export class Collider {
  85931. /** Define if a collision was found */
  85932. collisionFound: boolean;
  85933. /**
  85934. * Define last intersection point in local space
  85935. */
  85936. intersectionPoint: Vector3;
  85937. /**
  85938. * Define last collided mesh
  85939. */
  85940. collidedMesh: Nullable<AbstractMesh>;
  85941. private _collisionPoint;
  85942. private _planeIntersectionPoint;
  85943. private _tempVector;
  85944. private _tempVector2;
  85945. private _tempVector3;
  85946. private _tempVector4;
  85947. private _edge;
  85948. private _baseToVertex;
  85949. private _destinationPoint;
  85950. private _slidePlaneNormal;
  85951. private _displacementVector;
  85952. /** @hidden */
  85953. _radius: Vector3;
  85954. /** @hidden */
  85955. _retry: number;
  85956. private _velocity;
  85957. private _basePoint;
  85958. private _epsilon;
  85959. /** @hidden */
  85960. _velocityWorldLength: number;
  85961. /** @hidden */
  85962. _basePointWorld: Vector3;
  85963. private _velocityWorld;
  85964. private _normalizedVelocity;
  85965. /** @hidden */
  85966. _initialVelocity: Vector3;
  85967. /** @hidden */
  85968. _initialPosition: Vector3;
  85969. private _nearestDistance;
  85970. private _collisionMask;
  85971. get collisionMask(): number;
  85972. set collisionMask(mask: number);
  85973. /**
  85974. * Gets the plane normal used to compute the sliding response (in local space)
  85975. */
  85976. get slidePlaneNormal(): Vector3;
  85977. /** @hidden */
  85978. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85979. /** @hidden */
  85980. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85981. /** @hidden */
  85982. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85983. /** @hidden */
  85984. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85985. /** @hidden */
  85986. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85987. /** @hidden */
  85988. _getResponse(pos: Vector3, vel: Vector3): void;
  85989. }
  85990. }
  85991. declare module BABYLON {
  85992. /**
  85993. * Interface for cullable objects
  85994. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85995. */
  85996. export interface ICullable {
  85997. /**
  85998. * Checks if the object or part of the object is in the frustum
  85999. * @param frustumPlanes Camera near/planes
  86000. * @returns true if the object is in frustum otherwise false
  86001. */
  86002. isInFrustum(frustumPlanes: Plane[]): boolean;
  86003. /**
  86004. * Checks if a cullable object (mesh...) is in the camera frustum
  86005. * Unlike isInFrustum this cheks the full bounding box
  86006. * @param frustumPlanes Camera near/planes
  86007. * @returns true if the object is in frustum otherwise false
  86008. */
  86009. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86010. }
  86011. /**
  86012. * Info for a bounding data of a mesh
  86013. */
  86014. export class BoundingInfo implements ICullable {
  86015. /**
  86016. * Bounding box for the mesh
  86017. */
  86018. readonly boundingBox: BoundingBox;
  86019. /**
  86020. * Bounding sphere for the mesh
  86021. */
  86022. readonly boundingSphere: BoundingSphere;
  86023. private _isLocked;
  86024. private static readonly TmpVector3;
  86025. /**
  86026. * Constructs bounding info
  86027. * @param minimum min vector of the bounding box/sphere
  86028. * @param maximum max vector of the bounding box/sphere
  86029. * @param worldMatrix defines the new world matrix
  86030. */
  86031. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86032. /**
  86033. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86034. * @param min defines the new minimum vector (in local space)
  86035. * @param max defines the new maximum vector (in local space)
  86036. * @param worldMatrix defines the new world matrix
  86037. */
  86038. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86039. /**
  86040. * min vector of the bounding box/sphere
  86041. */
  86042. get minimum(): Vector3;
  86043. /**
  86044. * max vector of the bounding box/sphere
  86045. */
  86046. get maximum(): Vector3;
  86047. /**
  86048. * If the info is locked and won't be updated to avoid perf overhead
  86049. */
  86050. get isLocked(): boolean;
  86051. set isLocked(value: boolean);
  86052. /**
  86053. * Updates the bounding sphere and box
  86054. * @param world world matrix to be used to update
  86055. */
  86056. update(world: DeepImmutable<Matrix>): void;
  86057. /**
  86058. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86059. * @param center New center of the bounding info
  86060. * @param extend New extend of the bounding info
  86061. * @returns the current bounding info
  86062. */
  86063. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86064. /**
  86065. * Scale the current bounding info by applying a scale factor
  86066. * @param factor defines the scale factor to apply
  86067. * @returns the current bounding info
  86068. */
  86069. scale(factor: number): BoundingInfo;
  86070. /**
  86071. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86072. * @param frustumPlanes defines the frustum to test
  86073. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86074. * @returns true if the bounding info is in the frustum planes
  86075. */
  86076. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86077. /**
  86078. * Gets the world distance between the min and max points of the bounding box
  86079. */
  86080. get diagonalLength(): number;
  86081. /**
  86082. * Checks if a cullable object (mesh...) is in the camera frustum
  86083. * Unlike isInFrustum this cheks the full bounding box
  86084. * @param frustumPlanes Camera near/planes
  86085. * @returns true if the object is in frustum otherwise false
  86086. */
  86087. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86088. /** @hidden */
  86089. _checkCollision(collider: Collider): boolean;
  86090. /**
  86091. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86092. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86093. * @param point the point to check intersection with
  86094. * @returns if the point intersects
  86095. */
  86096. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86097. /**
  86098. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86099. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86100. * @param boundingInfo the bounding info to check intersection with
  86101. * @param precise if the intersection should be done using OBB
  86102. * @returns if the bounding info intersects
  86103. */
  86104. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86105. }
  86106. }
  86107. declare module BABYLON {
  86108. /**
  86109. * Extracts minimum and maximum values from a list of indexed positions
  86110. * @param positions defines the positions to use
  86111. * @param indices defines the indices to the positions
  86112. * @param indexStart defines the start index
  86113. * @param indexCount defines the end index
  86114. * @param bias defines bias value to add to the result
  86115. * @return minimum and maximum values
  86116. */
  86117. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86118. minimum: Vector3;
  86119. maximum: Vector3;
  86120. };
  86121. /**
  86122. * Extracts minimum and maximum values from a list of positions
  86123. * @param positions defines the positions to use
  86124. * @param start defines the start index in the positions array
  86125. * @param count defines the number of positions to handle
  86126. * @param bias defines bias value to add to the result
  86127. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86128. * @return minimum and maximum values
  86129. */
  86130. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86131. minimum: Vector3;
  86132. maximum: Vector3;
  86133. };
  86134. }
  86135. declare module BABYLON {
  86136. /** @hidden */
  86137. export class WebGLDataBuffer extends DataBuffer {
  86138. private _buffer;
  86139. constructor(resource: WebGLBuffer);
  86140. get underlyingResource(): any;
  86141. }
  86142. }
  86143. declare module BABYLON {
  86144. /** @hidden */
  86145. export class WebGLPipelineContext implements IPipelineContext {
  86146. engine: ThinEngine;
  86147. program: Nullable<WebGLProgram>;
  86148. context?: WebGLRenderingContext;
  86149. vertexShader?: WebGLShader;
  86150. fragmentShader?: WebGLShader;
  86151. isParallelCompiled: boolean;
  86152. onCompiled?: () => void;
  86153. transformFeedback?: WebGLTransformFeedback | null;
  86154. vertexCompilationError: Nullable<string>;
  86155. fragmentCompilationError: Nullable<string>;
  86156. programLinkError: Nullable<string>;
  86157. programValidationError: Nullable<string>;
  86158. get isAsync(): boolean;
  86159. get isReady(): boolean;
  86160. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86161. _getVertexShaderCode(): string | null;
  86162. _getFragmentShaderCode(): string | null;
  86163. }
  86164. }
  86165. declare module BABYLON {
  86166. interface ThinEngine {
  86167. /**
  86168. * Create an uniform buffer
  86169. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86170. * @param elements defines the content of the uniform buffer
  86171. * @returns the webGL uniform buffer
  86172. */
  86173. createUniformBuffer(elements: FloatArray): DataBuffer;
  86174. /**
  86175. * Create a dynamic uniform buffer
  86176. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86177. * @param elements defines the content of the uniform buffer
  86178. * @returns the webGL uniform buffer
  86179. */
  86180. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86181. /**
  86182. * Update an existing uniform buffer
  86183. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86184. * @param uniformBuffer defines the target uniform buffer
  86185. * @param elements defines the content to update
  86186. * @param offset defines the offset in the uniform buffer where update should start
  86187. * @param count defines the size of the data to update
  86188. */
  86189. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86190. /**
  86191. * Bind an uniform buffer to the current webGL context
  86192. * @param buffer defines the buffer to bind
  86193. */
  86194. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86195. /**
  86196. * Bind a buffer to the current webGL context at a given location
  86197. * @param buffer defines the buffer to bind
  86198. * @param location defines the index where to bind the buffer
  86199. */
  86200. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86201. /**
  86202. * Bind a specific block at a given index in a specific shader program
  86203. * @param pipelineContext defines the pipeline context to use
  86204. * @param blockName defines the block name
  86205. * @param index defines the index where to bind the block
  86206. */
  86207. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86208. }
  86209. }
  86210. declare module BABYLON {
  86211. /**
  86212. * Uniform buffer objects.
  86213. *
  86214. * Handles blocks of uniform on the GPU.
  86215. *
  86216. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86217. *
  86218. * For more information, please refer to :
  86219. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86220. */
  86221. export class UniformBuffer {
  86222. private _engine;
  86223. private _buffer;
  86224. private _data;
  86225. private _bufferData;
  86226. private _dynamic?;
  86227. private _uniformLocations;
  86228. private _uniformSizes;
  86229. private _uniformLocationPointer;
  86230. private _needSync;
  86231. private _noUBO;
  86232. private _currentEffect;
  86233. /** @hidden */
  86234. _alreadyBound: boolean;
  86235. private static _MAX_UNIFORM_SIZE;
  86236. private static _tempBuffer;
  86237. /**
  86238. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86239. * This is dynamic to allow compat with webgl 1 and 2.
  86240. * You will need to pass the name of the uniform as well as the value.
  86241. */
  86242. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86243. /**
  86244. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86245. * This is dynamic to allow compat with webgl 1 and 2.
  86246. * You will need to pass the name of the uniform as well as the value.
  86247. */
  86248. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86249. /**
  86250. * Lambda to Update a single float in a uniform buffer.
  86251. * This is dynamic to allow compat with webgl 1 and 2.
  86252. * You will need to pass the name of the uniform as well as the value.
  86253. */
  86254. updateFloat: (name: string, x: number) => void;
  86255. /**
  86256. * Lambda to Update a vec2 of float in a uniform buffer.
  86257. * This is dynamic to allow compat with webgl 1 and 2.
  86258. * You will need to pass the name of the uniform as well as the value.
  86259. */
  86260. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86261. /**
  86262. * Lambda to Update a vec3 of float in a uniform buffer.
  86263. * This is dynamic to allow compat with webgl 1 and 2.
  86264. * You will need to pass the name of the uniform as well as the value.
  86265. */
  86266. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86267. /**
  86268. * Lambda to Update a vec4 of float in a uniform buffer.
  86269. * This is dynamic to allow compat with webgl 1 and 2.
  86270. * You will need to pass the name of the uniform as well as the value.
  86271. */
  86272. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86273. /**
  86274. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86275. * This is dynamic to allow compat with webgl 1 and 2.
  86276. * You will need to pass the name of the uniform as well as the value.
  86277. */
  86278. updateMatrix: (name: string, mat: Matrix) => void;
  86279. /**
  86280. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86281. * This is dynamic to allow compat with webgl 1 and 2.
  86282. * You will need to pass the name of the uniform as well as the value.
  86283. */
  86284. updateVector3: (name: string, vector: Vector3) => void;
  86285. /**
  86286. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86287. * This is dynamic to allow compat with webgl 1 and 2.
  86288. * You will need to pass the name of the uniform as well as the value.
  86289. */
  86290. updateVector4: (name: string, vector: Vector4) => void;
  86291. /**
  86292. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86293. * This is dynamic to allow compat with webgl 1 and 2.
  86294. * You will need to pass the name of the uniform as well as the value.
  86295. */
  86296. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86297. /**
  86298. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86299. * This is dynamic to allow compat with webgl 1 and 2.
  86300. * You will need to pass the name of the uniform as well as the value.
  86301. */
  86302. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86303. /**
  86304. * Instantiates a new Uniform buffer objects.
  86305. *
  86306. * Handles blocks of uniform on the GPU.
  86307. *
  86308. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86309. *
  86310. * For more information, please refer to :
  86311. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86312. * @param engine Define the engine the buffer is associated with
  86313. * @param data Define the data contained in the buffer
  86314. * @param dynamic Define if the buffer is updatable
  86315. */
  86316. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86317. /**
  86318. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86319. * or just falling back on setUniformXXX calls.
  86320. */
  86321. get useUbo(): boolean;
  86322. /**
  86323. * Indicates if the WebGL underlying uniform buffer is in sync
  86324. * with the javascript cache data.
  86325. */
  86326. get isSync(): boolean;
  86327. /**
  86328. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86329. * Also, a dynamic UniformBuffer will disable cache verification and always
  86330. * update the underlying WebGL uniform buffer to the GPU.
  86331. * @returns if Dynamic, otherwise false
  86332. */
  86333. isDynamic(): boolean;
  86334. /**
  86335. * The data cache on JS side.
  86336. * @returns the underlying data as a float array
  86337. */
  86338. getData(): Float32Array;
  86339. /**
  86340. * The underlying WebGL Uniform buffer.
  86341. * @returns the webgl buffer
  86342. */
  86343. getBuffer(): Nullable<DataBuffer>;
  86344. /**
  86345. * std140 layout specifies how to align data within an UBO structure.
  86346. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86347. * for specs.
  86348. */
  86349. private _fillAlignment;
  86350. /**
  86351. * Adds an uniform in the buffer.
  86352. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86353. * for the layout to be correct !
  86354. * @param name Name of the uniform, as used in the uniform block in the shader.
  86355. * @param size Data size, or data directly.
  86356. */
  86357. addUniform(name: string, size: number | number[]): void;
  86358. /**
  86359. * Adds a Matrix 4x4 to the uniform buffer.
  86360. * @param name Name of the uniform, as used in the uniform block in the shader.
  86361. * @param mat A 4x4 matrix.
  86362. */
  86363. addMatrix(name: string, mat: Matrix): void;
  86364. /**
  86365. * Adds a vec2 to the uniform buffer.
  86366. * @param name Name of the uniform, as used in the uniform block in the shader.
  86367. * @param x Define the x component value of the vec2
  86368. * @param y Define the y component value of the vec2
  86369. */
  86370. addFloat2(name: string, x: number, y: number): void;
  86371. /**
  86372. * Adds a vec3 to the uniform buffer.
  86373. * @param name Name of the uniform, as used in the uniform block in the shader.
  86374. * @param x Define the x component value of the vec3
  86375. * @param y Define the y component value of the vec3
  86376. * @param z Define the z component value of the vec3
  86377. */
  86378. addFloat3(name: string, x: number, y: number, z: number): void;
  86379. /**
  86380. * Adds a vec3 to the uniform buffer.
  86381. * @param name Name of the uniform, as used in the uniform block in the shader.
  86382. * @param color Define the vec3 from a Color
  86383. */
  86384. addColor3(name: string, color: Color3): void;
  86385. /**
  86386. * Adds a vec4 to the uniform buffer.
  86387. * @param name Name of the uniform, as used in the uniform block in the shader.
  86388. * @param color Define the rgb components from a Color
  86389. * @param alpha Define the a component of the vec4
  86390. */
  86391. addColor4(name: string, color: Color3, alpha: number): void;
  86392. /**
  86393. * Adds a vec3 to the uniform buffer.
  86394. * @param name Name of the uniform, as used in the uniform block in the shader.
  86395. * @param vector Define the vec3 components from a Vector
  86396. */
  86397. addVector3(name: string, vector: Vector3): void;
  86398. /**
  86399. * Adds a Matrix 3x3 to the uniform buffer.
  86400. * @param name Name of the uniform, as used in the uniform block in the shader.
  86401. */
  86402. addMatrix3x3(name: string): void;
  86403. /**
  86404. * Adds a Matrix 2x2 to the uniform buffer.
  86405. * @param name Name of the uniform, as used in the uniform block in the shader.
  86406. */
  86407. addMatrix2x2(name: string): void;
  86408. /**
  86409. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86410. */
  86411. create(): void;
  86412. /** @hidden */
  86413. _rebuild(): void;
  86414. /**
  86415. * Updates the WebGL Uniform Buffer on the GPU.
  86416. * If the `dynamic` flag is set to true, no cache comparison is done.
  86417. * Otherwise, the buffer will be updated only if the cache differs.
  86418. */
  86419. update(): void;
  86420. /**
  86421. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86422. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86423. * @param data Define the flattened data
  86424. * @param size Define the size of the data.
  86425. */
  86426. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86427. private _valueCache;
  86428. private _cacheMatrix;
  86429. private _updateMatrix3x3ForUniform;
  86430. private _updateMatrix3x3ForEffect;
  86431. private _updateMatrix2x2ForEffect;
  86432. private _updateMatrix2x2ForUniform;
  86433. private _updateFloatForEffect;
  86434. private _updateFloatForUniform;
  86435. private _updateFloat2ForEffect;
  86436. private _updateFloat2ForUniform;
  86437. private _updateFloat3ForEffect;
  86438. private _updateFloat3ForUniform;
  86439. private _updateFloat4ForEffect;
  86440. private _updateFloat4ForUniform;
  86441. private _updateMatrixForEffect;
  86442. private _updateMatrixForUniform;
  86443. private _updateVector3ForEffect;
  86444. private _updateVector3ForUniform;
  86445. private _updateVector4ForEffect;
  86446. private _updateVector4ForUniform;
  86447. private _updateColor3ForEffect;
  86448. private _updateColor3ForUniform;
  86449. private _updateColor4ForEffect;
  86450. private _updateColor4ForUniform;
  86451. /**
  86452. * Sets a sampler uniform on the effect.
  86453. * @param name Define the name of the sampler.
  86454. * @param texture Define the texture to set in the sampler
  86455. */
  86456. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86457. /**
  86458. * Directly updates the value of the uniform in the cache AND on the GPU.
  86459. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86460. * @param data Define the flattened data
  86461. */
  86462. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86463. /**
  86464. * Binds this uniform buffer to an effect.
  86465. * @param effect Define the effect to bind the buffer to
  86466. * @param name Name of the uniform block in the shader.
  86467. */
  86468. bindToEffect(effect: Effect, name: string): void;
  86469. /**
  86470. * Disposes the uniform buffer.
  86471. */
  86472. dispose(): void;
  86473. }
  86474. }
  86475. declare module BABYLON {
  86476. /**
  86477. * Enum that determines the text-wrapping mode to use.
  86478. */
  86479. export enum InspectableType {
  86480. /**
  86481. * Checkbox for booleans
  86482. */
  86483. Checkbox = 0,
  86484. /**
  86485. * Sliders for numbers
  86486. */
  86487. Slider = 1,
  86488. /**
  86489. * Vector3
  86490. */
  86491. Vector3 = 2,
  86492. /**
  86493. * Quaternions
  86494. */
  86495. Quaternion = 3,
  86496. /**
  86497. * Color3
  86498. */
  86499. Color3 = 4,
  86500. /**
  86501. * String
  86502. */
  86503. String = 5
  86504. }
  86505. /**
  86506. * Interface used to define custom inspectable properties.
  86507. * This interface is used by the inspector to display custom property grids
  86508. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86509. */
  86510. export interface IInspectable {
  86511. /**
  86512. * Gets the label to display
  86513. */
  86514. label: string;
  86515. /**
  86516. * Gets the name of the property to edit
  86517. */
  86518. propertyName: string;
  86519. /**
  86520. * Gets the type of the editor to use
  86521. */
  86522. type: InspectableType;
  86523. /**
  86524. * Gets the minimum value of the property when using in "slider" mode
  86525. */
  86526. min?: number;
  86527. /**
  86528. * Gets the maximum value of the property when using in "slider" mode
  86529. */
  86530. max?: number;
  86531. /**
  86532. * Gets the setp to use when using in "slider" mode
  86533. */
  86534. step?: number;
  86535. }
  86536. }
  86537. declare module BABYLON {
  86538. /**
  86539. * Class used to provide helper for timing
  86540. */
  86541. export class TimingTools {
  86542. /**
  86543. * Polyfill for setImmediate
  86544. * @param action defines the action to execute after the current execution block
  86545. */
  86546. static SetImmediate(action: () => void): void;
  86547. }
  86548. }
  86549. declare module BABYLON {
  86550. /**
  86551. * Class used to enable instatition of objects by class name
  86552. */
  86553. export class InstantiationTools {
  86554. /**
  86555. * Use this object to register external classes like custom textures or material
  86556. * to allow the laoders to instantiate them
  86557. */
  86558. static RegisteredExternalClasses: {
  86559. [key: string]: Object;
  86560. };
  86561. /**
  86562. * Tries to instantiate a new object from a given class name
  86563. * @param className defines the class name to instantiate
  86564. * @returns the new object or null if the system was not able to do the instantiation
  86565. */
  86566. static Instantiate(className: string): any;
  86567. }
  86568. }
  86569. declare module BABYLON {
  86570. /**
  86571. * Define options used to create a depth texture
  86572. */
  86573. export class DepthTextureCreationOptions {
  86574. /** Specifies whether or not a stencil should be allocated in the texture */
  86575. generateStencil?: boolean;
  86576. /** Specifies whether or not bilinear filtering is enable on the texture */
  86577. bilinearFiltering?: boolean;
  86578. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86579. comparisonFunction?: number;
  86580. /** Specifies if the created texture is a cube texture */
  86581. isCube?: boolean;
  86582. }
  86583. }
  86584. declare module BABYLON {
  86585. interface ThinEngine {
  86586. /**
  86587. * Creates a depth stencil cube texture.
  86588. * This is only available in WebGL 2.
  86589. * @param size The size of face edge in the cube texture.
  86590. * @param options The options defining the cube texture.
  86591. * @returns The cube texture
  86592. */
  86593. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86594. /**
  86595. * Creates a cube texture
  86596. * @param rootUrl defines the url where the files to load is located
  86597. * @param scene defines the current scene
  86598. * @param files defines the list of files to load (1 per face)
  86599. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86600. * @param onLoad defines an optional callback raised when the texture is loaded
  86601. * @param onError defines an optional callback raised if there is an issue to load the texture
  86602. * @param format defines the format of the data
  86603. * @param forcedExtension defines the extension to use to pick the right loader
  86604. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86605. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86606. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86607. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86608. * @returns the cube texture as an InternalTexture
  86609. */
  86610. 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;
  86611. /**
  86612. * Creates a cube texture
  86613. * @param rootUrl defines the url where the files to load is located
  86614. * @param scene defines the current scene
  86615. * @param files defines the list of files to load (1 per face)
  86616. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86617. * @param onLoad defines an optional callback raised when the texture is loaded
  86618. * @param onError defines an optional callback raised if there is an issue to load the texture
  86619. * @param format defines the format of the data
  86620. * @param forcedExtension defines the extension to use to pick the right loader
  86621. * @returns the cube texture as an InternalTexture
  86622. */
  86623. 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;
  86624. /**
  86625. * Creates a cube texture
  86626. * @param rootUrl defines the url where the files to load is located
  86627. * @param scene defines the current scene
  86628. * @param files defines the list of files to load (1 per face)
  86629. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86630. * @param onLoad defines an optional callback raised when the texture is loaded
  86631. * @param onError defines an optional callback raised if there is an issue to load the texture
  86632. * @param format defines the format of the data
  86633. * @param forcedExtension defines the extension to use to pick the right loader
  86634. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86635. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86636. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86637. * @returns the cube texture as an InternalTexture
  86638. */
  86639. 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;
  86640. /** @hidden */
  86641. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86642. /** @hidden */
  86643. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86644. /** @hidden */
  86645. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86646. /** @hidden */
  86647. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86648. /**
  86649. * @hidden
  86650. */
  86651. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86652. }
  86653. }
  86654. declare module BABYLON {
  86655. /**
  86656. * Class for creating a cube texture
  86657. */
  86658. export class CubeTexture extends BaseTexture {
  86659. private _delayedOnLoad;
  86660. /**
  86661. * Observable triggered once the texture has been loaded.
  86662. */
  86663. onLoadObservable: Observable<CubeTexture>;
  86664. /**
  86665. * The url of the texture
  86666. */
  86667. url: string;
  86668. /**
  86669. * Gets or sets the center of the bounding box associated with the cube texture.
  86670. * It must define where the camera used to render the texture was set
  86671. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86672. */
  86673. boundingBoxPosition: Vector3;
  86674. private _boundingBoxSize;
  86675. /**
  86676. * Gets or sets the size of the bounding box associated with the cube texture
  86677. * When defined, the cubemap will switch to local mode
  86678. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86679. * @example https://www.babylonjs-playground.com/#RNASML
  86680. */
  86681. set boundingBoxSize(value: Vector3);
  86682. /**
  86683. * Returns the bounding box size
  86684. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86685. */
  86686. get boundingBoxSize(): Vector3;
  86687. protected _rotationY: number;
  86688. /**
  86689. * Sets texture matrix rotation angle around Y axis in radians.
  86690. */
  86691. set rotationY(value: number);
  86692. /**
  86693. * Gets texture matrix rotation angle around Y axis radians.
  86694. */
  86695. get rotationY(): number;
  86696. /**
  86697. * Are mip maps generated for this texture or not.
  86698. */
  86699. get noMipmap(): boolean;
  86700. private _noMipmap;
  86701. private _files;
  86702. protected _forcedExtension: Nullable<string>;
  86703. private _extensions;
  86704. private _textureMatrix;
  86705. private _format;
  86706. private _createPolynomials;
  86707. /**
  86708. * Creates a cube texture from an array of image urls
  86709. * @param files defines an array of image urls
  86710. * @param scene defines the hosting scene
  86711. * @param noMipmap specifies if mip maps are not used
  86712. * @returns a cube texture
  86713. */
  86714. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86715. /**
  86716. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86717. * @param url defines the url of the prefiltered texture
  86718. * @param scene defines the scene the texture is attached to
  86719. * @param forcedExtension defines the extension of the file if different from the url
  86720. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86721. * @return the prefiltered texture
  86722. */
  86723. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86724. /**
  86725. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86726. * as prefiltered data.
  86727. * @param rootUrl defines the url of the texture or the root name of the six images
  86728. * @param null defines the scene or engine the texture is attached to
  86729. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86730. * @param noMipmap defines if mipmaps should be created or not
  86731. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86732. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86733. * @param onError defines a callback triggered in case of error during load
  86734. * @param format defines the internal format to use for the texture once loaded
  86735. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86736. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86737. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86740. * @return the cube texture
  86741. */
  86742. 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);
  86743. /**
  86744. * Get the current class name of the texture useful for serialization or dynamic coding.
  86745. * @returns "CubeTexture"
  86746. */
  86747. getClassName(): string;
  86748. /**
  86749. * Update the url (and optional buffer) of this texture if url was null during construction.
  86750. * @param url the url of the texture
  86751. * @param forcedExtension defines the extension to use
  86752. * @param onLoad callback called when the texture is loaded (defaults to null)
  86753. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86754. */
  86755. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86756. /**
  86757. * Delays loading of the cube texture
  86758. * @param forcedExtension defines the extension to use
  86759. */
  86760. delayLoad(forcedExtension?: string): void;
  86761. /**
  86762. * Returns the reflection texture matrix
  86763. * @returns the reflection texture matrix
  86764. */
  86765. getReflectionTextureMatrix(): Matrix;
  86766. /**
  86767. * Sets the reflection texture matrix
  86768. * @param value Reflection texture matrix
  86769. */
  86770. setReflectionTextureMatrix(value: Matrix): void;
  86771. /**
  86772. * Parses text to create a cube texture
  86773. * @param parsedTexture define the serialized text to read from
  86774. * @param scene defines the hosting scene
  86775. * @param rootUrl defines the root url of the cube texture
  86776. * @returns a cube texture
  86777. */
  86778. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86779. /**
  86780. * Makes a clone, or deep copy, of the cube texture
  86781. * @returns a new cube texture
  86782. */
  86783. clone(): CubeTexture;
  86784. }
  86785. }
  86786. declare module BABYLON {
  86787. /**
  86788. * Manages the defines for the Material
  86789. */
  86790. export class MaterialDefines {
  86791. /** @hidden */
  86792. protected _keys: string[];
  86793. private _isDirty;
  86794. /** @hidden */
  86795. _renderId: number;
  86796. /** @hidden */
  86797. _areLightsDirty: boolean;
  86798. /** @hidden */
  86799. _areLightsDisposed: boolean;
  86800. /** @hidden */
  86801. _areAttributesDirty: boolean;
  86802. /** @hidden */
  86803. _areTexturesDirty: boolean;
  86804. /** @hidden */
  86805. _areFresnelDirty: boolean;
  86806. /** @hidden */
  86807. _areMiscDirty: boolean;
  86808. /** @hidden */
  86809. _areImageProcessingDirty: boolean;
  86810. /** @hidden */
  86811. _normals: boolean;
  86812. /** @hidden */
  86813. _uvs: boolean;
  86814. /** @hidden */
  86815. _needNormals: boolean;
  86816. /** @hidden */
  86817. _needUVs: boolean;
  86818. [id: string]: any;
  86819. /**
  86820. * Specifies if the material needs to be re-calculated
  86821. */
  86822. get isDirty(): boolean;
  86823. /**
  86824. * Marks the material to indicate that it has been re-calculated
  86825. */
  86826. markAsProcessed(): void;
  86827. /**
  86828. * Marks the material to indicate that it needs to be re-calculated
  86829. */
  86830. markAsUnprocessed(): void;
  86831. /**
  86832. * Marks the material to indicate all of its defines need to be re-calculated
  86833. */
  86834. markAllAsDirty(): void;
  86835. /**
  86836. * Marks the material to indicate that image processing needs to be re-calculated
  86837. */
  86838. markAsImageProcessingDirty(): void;
  86839. /**
  86840. * Marks the material to indicate the lights need to be re-calculated
  86841. * @param disposed Defines whether the light is dirty due to dispose or not
  86842. */
  86843. markAsLightDirty(disposed?: boolean): void;
  86844. /**
  86845. * Marks the attribute state as changed
  86846. */
  86847. markAsAttributesDirty(): void;
  86848. /**
  86849. * Marks the texture state as changed
  86850. */
  86851. markAsTexturesDirty(): void;
  86852. /**
  86853. * Marks the fresnel state as changed
  86854. */
  86855. markAsFresnelDirty(): void;
  86856. /**
  86857. * Marks the misc state as changed
  86858. */
  86859. markAsMiscDirty(): void;
  86860. /**
  86861. * Rebuilds the material defines
  86862. */
  86863. rebuild(): void;
  86864. /**
  86865. * Specifies if two material defines are equal
  86866. * @param other - A material define instance to compare to
  86867. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86868. */
  86869. isEqual(other: MaterialDefines): boolean;
  86870. /**
  86871. * Clones this instance's defines to another instance
  86872. * @param other - material defines to clone values to
  86873. */
  86874. cloneTo(other: MaterialDefines): void;
  86875. /**
  86876. * Resets the material define values
  86877. */
  86878. reset(): void;
  86879. /**
  86880. * Converts the material define values to a string
  86881. * @returns - String of material define information
  86882. */
  86883. toString(): string;
  86884. }
  86885. }
  86886. declare module BABYLON {
  86887. /**
  86888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86890. * 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;
  86891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86892. */
  86893. export class ColorCurves {
  86894. private _dirty;
  86895. private _tempColor;
  86896. private _globalCurve;
  86897. private _highlightsCurve;
  86898. private _midtonesCurve;
  86899. private _shadowsCurve;
  86900. private _positiveCurve;
  86901. private _negativeCurve;
  86902. private _globalHue;
  86903. private _globalDensity;
  86904. private _globalSaturation;
  86905. private _globalExposure;
  86906. /**
  86907. * Gets 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. get globalHue(): number;
  86911. /**
  86912. * Sets the global Hue value.
  86913. * 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).
  86914. */
  86915. set globalHue(value: number);
  86916. /**
  86917. * Gets the global Density value.
  86918. * 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.
  86919. * Values less than zero provide a filter of opposite hue.
  86920. */
  86921. get globalDensity(): number;
  86922. /**
  86923. * Sets the global Density value.
  86924. * 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.
  86925. * Values less than zero provide a filter of opposite hue.
  86926. */
  86927. set globalDensity(value: number);
  86928. /**
  86929. * Gets 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. get globalSaturation(): number;
  86933. /**
  86934. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  86936. */
  86937. set globalSaturation(value: number);
  86938. /**
  86939. * Gets 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. get globalExposure(): number;
  86943. /**
  86944. * Sets the global Exposure value.
  86945. * 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.
  86946. */
  86947. set globalExposure(value: number);
  86948. private _highlightsHue;
  86949. private _highlightsDensity;
  86950. private _highlightsSaturation;
  86951. private _highlightsExposure;
  86952. /**
  86953. * Gets 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. get highlightsHue(): number;
  86957. /**
  86958. * Sets the highlights Hue value.
  86959. * 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).
  86960. */
  86961. set highlightsHue(value: number);
  86962. /**
  86963. * Gets the highlights Density value.
  86964. * 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.
  86965. * Values less than zero provide a filter of opposite hue.
  86966. */
  86967. get highlightsDensity(): number;
  86968. /**
  86969. * Sets the highlights Density value.
  86970. * 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.
  86971. * Values less than zero provide a filter of opposite hue.
  86972. */
  86973. set highlightsDensity(value: number);
  86974. /**
  86975. * Gets 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. get highlightsSaturation(): number;
  86979. /**
  86980. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  86982. */
  86983. set highlightsSaturation(value: number);
  86984. /**
  86985. * Gets 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. get highlightsExposure(): number;
  86989. /**
  86990. * Sets the highlights Exposure value.
  86991. * 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.
  86992. */
  86993. set highlightsExposure(value: number);
  86994. private _midtonesHue;
  86995. private _midtonesDensity;
  86996. private _midtonesSaturation;
  86997. private _midtonesExposure;
  86998. /**
  86999. * Gets 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. get midtonesHue(): number;
  87003. /**
  87004. * Sets the midtones Hue value.
  87005. * 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).
  87006. */
  87007. set midtonesHue(value: number);
  87008. /**
  87009. * Gets the midtones Density value.
  87010. * 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.
  87011. * Values less than zero provide a filter of opposite hue.
  87012. */
  87013. get midtonesDensity(): number;
  87014. /**
  87015. * Sets the midtones Density value.
  87016. * 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.
  87017. * Values less than zero provide a filter of opposite hue.
  87018. */
  87019. set midtonesDensity(value: number);
  87020. /**
  87021. * Gets 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. get midtonesSaturation(): number;
  87025. /**
  87026. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  87028. */
  87029. set midtonesSaturation(value: number);
  87030. /**
  87031. * Gets 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. get midtonesExposure(): number;
  87035. /**
  87036. * Sets the midtones Exposure value.
  87037. * 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.
  87038. */
  87039. set midtonesExposure(value: number);
  87040. private _shadowsHue;
  87041. private _shadowsDensity;
  87042. private _shadowsSaturation;
  87043. private _shadowsExposure;
  87044. /**
  87045. * Gets 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. get shadowsHue(): number;
  87049. /**
  87050. * Sets the shadows Hue value.
  87051. * 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).
  87052. */
  87053. set shadowsHue(value: number);
  87054. /**
  87055. * Gets the shadows Density value.
  87056. * 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.
  87057. * Values less than zero provide a filter of opposite hue.
  87058. */
  87059. get shadowsDensity(): number;
  87060. /**
  87061. * Sets the shadows Density value.
  87062. * 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.
  87063. * Values less than zero provide a filter of opposite hue.
  87064. */
  87065. set shadowsDensity(value: number);
  87066. /**
  87067. * Gets 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. get shadowsSaturation(): number;
  87071. /**
  87072. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  87074. */
  87075. set shadowsSaturation(value: number);
  87076. /**
  87077. * Gets 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. get shadowsExposure(): number;
  87081. /**
  87082. * Sets the shadows Exposure value.
  87083. * 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.
  87084. */
  87085. set shadowsExposure(value: number);
  87086. /**
  87087. * Returns the class name
  87088. * @returns The class name
  87089. */
  87090. getClassName(): string;
  87091. /**
  87092. * Binds the color curves to the shader.
  87093. * @param colorCurves The color curve to bind
  87094. * @param effect The effect to bind to
  87095. * @param positiveUniform The positive uniform shader parameter
  87096. * @param neutralUniform The neutral uniform shader parameter
  87097. * @param negativeUniform The negative uniform shader parameter
  87098. */
  87099. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87100. /**
  87101. * Prepare the list of uniforms associated with the ColorCurves effects.
  87102. * @param uniformsList The list of uniforms used in the effect
  87103. */
  87104. static PrepareUniforms(uniformsList: string[]): void;
  87105. /**
  87106. * Returns color grading data based on a hue, density, saturation and exposure value.
  87107. * @param filterHue The hue of the color filter.
  87108. * @param filterDensity The density of the color filter.
  87109. * @param saturation The saturation.
  87110. * @param exposure The exposure.
  87111. * @param result The result data container.
  87112. */
  87113. private getColorGradingDataToRef;
  87114. /**
  87115. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87116. * @param value The input slider value in range [-100,100].
  87117. * @returns Adjusted value.
  87118. */
  87119. private static applyColorGradingSliderNonlinear;
  87120. /**
  87121. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87122. * @param hue The hue (H) input.
  87123. * @param saturation The saturation (S) input.
  87124. * @param brightness The brightness (B) input.
  87125. * @result An RGBA color represented as Vector4.
  87126. */
  87127. private static fromHSBToRef;
  87128. /**
  87129. * Returns a value clamped between min and max
  87130. * @param value The value to clamp
  87131. * @param min The minimum of value
  87132. * @param max The maximum of value
  87133. * @returns The clamped value.
  87134. */
  87135. private static clamp;
  87136. /**
  87137. * Clones the current color curve instance.
  87138. * @return The cloned curves
  87139. */
  87140. clone(): ColorCurves;
  87141. /**
  87142. * Serializes the current color curve instance to a json representation.
  87143. * @return a JSON representation
  87144. */
  87145. serialize(): any;
  87146. /**
  87147. * Parses the color curve from a json representation.
  87148. * @param source the JSON source to parse
  87149. * @return The parsed curves
  87150. */
  87151. static Parse(source: any): ColorCurves;
  87152. }
  87153. }
  87154. declare module BABYLON {
  87155. /**
  87156. * Interface to follow in your material defines to integrate easily the
  87157. * Image proccessing functions.
  87158. * @hidden
  87159. */
  87160. export interface IImageProcessingConfigurationDefines {
  87161. IMAGEPROCESSING: boolean;
  87162. VIGNETTE: boolean;
  87163. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87164. VIGNETTEBLENDMODEOPAQUE: boolean;
  87165. TONEMAPPING: boolean;
  87166. TONEMAPPING_ACES: boolean;
  87167. CONTRAST: boolean;
  87168. EXPOSURE: boolean;
  87169. COLORCURVES: boolean;
  87170. COLORGRADING: boolean;
  87171. COLORGRADING3D: boolean;
  87172. SAMPLER3DGREENDEPTH: boolean;
  87173. SAMPLER3DBGRMAP: boolean;
  87174. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87175. }
  87176. /**
  87177. * @hidden
  87178. */
  87179. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87180. IMAGEPROCESSING: boolean;
  87181. VIGNETTE: boolean;
  87182. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87183. VIGNETTEBLENDMODEOPAQUE: boolean;
  87184. TONEMAPPING: boolean;
  87185. TONEMAPPING_ACES: boolean;
  87186. CONTRAST: boolean;
  87187. COLORCURVES: boolean;
  87188. COLORGRADING: boolean;
  87189. COLORGRADING3D: boolean;
  87190. SAMPLER3DGREENDEPTH: boolean;
  87191. SAMPLER3DBGRMAP: boolean;
  87192. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87193. EXPOSURE: boolean;
  87194. constructor();
  87195. }
  87196. /**
  87197. * This groups together the common properties used for image processing either in direct forward pass
  87198. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87199. * or not.
  87200. */
  87201. export class ImageProcessingConfiguration {
  87202. /**
  87203. * Default tone mapping applied in BabylonJS.
  87204. */
  87205. static readonly TONEMAPPING_STANDARD: number;
  87206. /**
  87207. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87208. * to other engines rendering to increase portability.
  87209. */
  87210. static readonly TONEMAPPING_ACES: number;
  87211. /**
  87212. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87213. */
  87214. colorCurves: Nullable<ColorCurves>;
  87215. private _colorCurvesEnabled;
  87216. /**
  87217. * Gets wether the color curves effect is enabled.
  87218. */
  87219. get colorCurvesEnabled(): boolean;
  87220. /**
  87221. * Sets wether the color curves effect is enabled.
  87222. */
  87223. set colorCurvesEnabled(value: boolean);
  87224. private _colorGradingTexture;
  87225. /**
  87226. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87227. */
  87228. get colorGradingTexture(): Nullable<BaseTexture>;
  87229. /**
  87230. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87231. */
  87232. set colorGradingTexture(value: Nullable<BaseTexture>);
  87233. private _colorGradingEnabled;
  87234. /**
  87235. * Gets wether the color grading effect is enabled.
  87236. */
  87237. get colorGradingEnabled(): boolean;
  87238. /**
  87239. * Sets wether the color grading effect is enabled.
  87240. */
  87241. set colorGradingEnabled(value: boolean);
  87242. private _colorGradingWithGreenDepth;
  87243. /**
  87244. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87245. */
  87246. get colorGradingWithGreenDepth(): boolean;
  87247. /**
  87248. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87249. */
  87250. set colorGradingWithGreenDepth(value: boolean);
  87251. private _colorGradingBGR;
  87252. /**
  87253. * Gets wether the color grading texture contains BGR values.
  87254. */
  87255. get colorGradingBGR(): boolean;
  87256. /**
  87257. * Sets wether the color grading texture contains BGR values.
  87258. */
  87259. set colorGradingBGR(value: boolean);
  87260. /** @hidden */
  87261. _exposure: number;
  87262. /**
  87263. * Gets the Exposure used in the effect.
  87264. */
  87265. get exposure(): number;
  87266. /**
  87267. * Sets the Exposure used in the effect.
  87268. */
  87269. set exposure(value: number);
  87270. private _toneMappingEnabled;
  87271. /**
  87272. * Gets wether the tone mapping effect is enabled.
  87273. */
  87274. get toneMappingEnabled(): boolean;
  87275. /**
  87276. * Sets wether the tone mapping effect is enabled.
  87277. */
  87278. set toneMappingEnabled(value: boolean);
  87279. private _toneMappingType;
  87280. /**
  87281. * Gets the type of tone mapping effect.
  87282. */
  87283. get toneMappingType(): number;
  87284. /**
  87285. * Sets the type of tone mapping effect used in BabylonJS.
  87286. */
  87287. set toneMappingType(value: number);
  87288. protected _contrast: number;
  87289. /**
  87290. * Gets the contrast used in the effect.
  87291. */
  87292. get contrast(): number;
  87293. /**
  87294. * Sets the contrast used in the effect.
  87295. */
  87296. set contrast(value: number);
  87297. /**
  87298. * Vignette stretch size.
  87299. */
  87300. vignetteStretch: number;
  87301. /**
  87302. * Vignette centre X Offset.
  87303. */
  87304. vignetteCentreX: number;
  87305. /**
  87306. * Vignette centre Y Offset.
  87307. */
  87308. vignetteCentreY: number;
  87309. /**
  87310. * Vignette weight or intensity of the vignette effect.
  87311. */
  87312. vignetteWeight: number;
  87313. /**
  87314. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87315. * if vignetteEnabled is set to true.
  87316. */
  87317. vignetteColor: Color4;
  87318. /**
  87319. * Camera field of view used by the Vignette effect.
  87320. */
  87321. vignetteCameraFov: number;
  87322. private _vignetteBlendMode;
  87323. /**
  87324. * Gets the vignette blend mode allowing different kind of effect.
  87325. */
  87326. get vignetteBlendMode(): number;
  87327. /**
  87328. * Sets the vignette blend mode allowing different kind of effect.
  87329. */
  87330. set vignetteBlendMode(value: number);
  87331. private _vignetteEnabled;
  87332. /**
  87333. * Gets wether the vignette effect is enabled.
  87334. */
  87335. get vignetteEnabled(): boolean;
  87336. /**
  87337. * Sets wether the vignette effect is enabled.
  87338. */
  87339. set vignetteEnabled(value: boolean);
  87340. private _applyByPostProcess;
  87341. /**
  87342. * Gets wether the image processing is applied through a post process or not.
  87343. */
  87344. get applyByPostProcess(): boolean;
  87345. /**
  87346. * Sets wether the image processing is applied through a post process or not.
  87347. */
  87348. set applyByPostProcess(value: boolean);
  87349. private _isEnabled;
  87350. /**
  87351. * Gets wether the image processing is enabled or not.
  87352. */
  87353. get isEnabled(): boolean;
  87354. /**
  87355. * Sets wether the image processing is enabled or not.
  87356. */
  87357. set isEnabled(value: boolean);
  87358. /**
  87359. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87360. */
  87361. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87362. /**
  87363. * Method called each time the image processing information changes requires to recompile the effect.
  87364. */
  87365. protected _updateParameters(): void;
  87366. /**
  87367. * Gets the current class name.
  87368. * @return "ImageProcessingConfiguration"
  87369. */
  87370. getClassName(): string;
  87371. /**
  87372. * Prepare the list of uniforms associated with the Image Processing effects.
  87373. * @param uniforms The list of uniforms used in the effect
  87374. * @param defines the list of defines currently in use
  87375. */
  87376. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87377. /**
  87378. * Prepare the list of samplers associated with the Image Processing effects.
  87379. * @param samplersList The list of uniforms used in the effect
  87380. * @param defines the list of defines currently in use
  87381. */
  87382. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87383. /**
  87384. * Prepare the list of defines associated to the shader.
  87385. * @param defines the list of defines to complete
  87386. * @param forPostProcess Define if we are currently in post process mode or not
  87387. */
  87388. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87389. /**
  87390. * Returns true if all the image processing information are ready.
  87391. * @returns True if ready, otherwise, false
  87392. */
  87393. isReady(): boolean;
  87394. /**
  87395. * Binds the image processing to the shader.
  87396. * @param effect The effect to bind to
  87397. * @param overrideAspectRatio Override the aspect ratio of the effect
  87398. */
  87399. bind(effect: Effect, overrideAspectRatio?: number): void;
  87400. /**
  87401. * Clones the current image processing instance.
  87402. * @return The cloned image processing
  87403. */
  87404. clone(): ImageProcessingConfiguration;
  87405. /**
  87406. * Serializes the current image processing instance to a json representation.
  87407. * @return a JSON representation
  87408. */
  87409. serialize(): any;
  87410. /**
  87411. * Parses the image processing from a json representation.
  87412. * @param source the JSON source to parse
  87413. * @return The parsed image processing
  87414. */
  87415. static Parse(source: any): ImageProcessingConfiguration;
  87416. private static _VIGNETTEMODE_MULTIPLY;
  87417. private static _VIGNETTEMODE_OPAQUE;
  87418. /**
  87419. * Used to apply the vignette as a mix with the pixel color.
  87420. */
  87421. static get VIGNETTEMODE_MULTIPLY(): number;
  87422. /**
  87423. * Used to apply the vignette as a replacement of the pixel color.
  87424. */
  87425. static get VIGNETTEMODE_OPAQUE(): number;
  87426. }
  87427. }
  87428. declare module BABYLON {
  87429. /** @hidden */
  87430. export var postprocessVertexShader: {
  87431. name: string;
  87432. shader: string;
  87433. };
  87434. }
  87435. declare module BABYLON {
  87436. interface ThinEngine {
  87437. /**
  87438. * Creates a new render target texture
  87439. * @param size defines the size of the texture
  87440. * @param options defines the options used to create the texture
  87441. * @returns a new render target texture stored in an InternalTexture
  87442. */
  87443. createRenderTargetTexture(size: number | {
  87444. width: number;
  87445. height: number;
  87446. layers?: number;
  87447. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87448. /**
  87449. * Creates a depth stencil texture.
  87450. * This is only available in WebGL 2 or with the depth texture extension available.
  87451. * @param size The size of face edge in the texture.
  87452. * @param options The options defining the texture.
  87453. * @returns The texture
  87454. */
  87455. createDepthStencilTexture(size: number | {
  87456. width: number;
  87457. height: number;
  87458. layers?: number;
  87459. }, options: DepthTextureCreationOptions): InternalTexture;
  87460. /** @hidden */
  87461. _createDepthStencilTexture(size: number | {
  87462. width: number;
  87463. height: number;
  87464. layers?: number;
  87465. }, options: DepthTextureCreationOptions): InternalTexture;
  87466. }
  87467. }
  87468. declare module BABYLON {
  87469. /**
  87470. * Defines the kind of connection point for node based material
  87471. */
  87472. export enum NodeMaterialBlockConnectionPointTypes {
  87473. /** Float */
  87474. Float = 1,
  87475. /** Int */
  87476. Int = 2,
  87477. /** Vector2 */
  87478. Vector2 = 4,
  87479. /** Vector3 */
  87480. Vector3 = 8,
  87481. /** Vector4 */
  87482. Vector4 = 16,
  87483. /** Color3 */
  87484. Color3 = 32,
  87485. /** Color4 */
  87486. Color4 = 64,
  87487. /** Matrix */
  87488. Matrix = 128,
  87489. /** Custom object */
  87490. Object = 256,
  87491. /** Detect type based on connection */
  87492. AutoDetect = 1024,
  87493. /** Output type that will be defined by input type */
  87494. BasedOnInput = 2048
  87495. }
  87496. }
  87497. declare module BABYLON {
  87498. /**
  87499. * Enum used to define the target of a block
  87500. */
  87501. export enum NodeMaterialBlockTargets {
  87502. /** Vertex shader */
  87503. Vertex = 1,
  87504. /** Fragment shader */
  87505. Fragment = 2,
  87506. /** Neutral */
  87507. Neutral = 4,
  87508. /** Vertex and Fragment */
  87509. VertexAndFragment = 3
  87510. }
  87511. }
  87512. declare module BABYLON {
  87513. /**
  87514. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87515. */
  87516. export enum NodeMaterialBlockConnectionPointMode {
  87517. /** Value is an uniform */
  87518. Uniform = 0,
  87519. /** Value is a mesh attribute */
  87520. Attribute = 1,
  87521. /** Value is a varying between vertex and fragment shaders */
  87522. Varying = 2,
  87523. /** Mode is undefined */
  87524. Undefined = 3
  87525. }
  87526. }
  87527. declare module BABYLON {
  87528. /**
  87529. * Enum used to define system values e.g. values automatically provided by the system
  87530. */
  87531. export enum NodeMaterialSystemValues {
  87532. /** World */
  87533. World = 1,
  87534. /** View */
  87535. View = 2,
  87536. /** Projection */
  87537. Projection = 3,
  87538. /** ViewProjection */
  87539. ViewProjection = 4,
  87540. /** WorldView */
  87541. WorldView = 5,
  87542. /** WorldViewProjection */
  87543. WorldViewProjection = 6,
  87544. /** CameraPosition */
  87545. CameraPosition = 7,
  87546. /** Fog Color */
  87547. FogColor = 8,
  87548. /** Delta time */
  87549. DeltaTime = 9
  87550. }
  87551. }
  87552. declare module BABYLON {
  87553. /** Defines supported spaces */
  87554. export enum Space {
  87555. /** Local (object) space */
  87556. LOCAL = 0,
  87557. /** World space */
  87558. WORLD = 1,
  87559. /** Bone space */
  87560. BONE = 2
  87561. }
  87562. /** Defines the 3 main axes */
  87563. export class Axis {
  87564. /** X axis */
  87565. static X: Vector3;
  87566. /** Y axis */
  87567. static Y: Vector3;
  87568. /** Z axis */
  87569. static Z: Vector3;
  87570. }
  87571. }
  87572. declare module BABYLON {
  87573. /**
  87574. * Represents a camera frustum
  87575. */
  87576. export class Frustum {
  87577. /**
  87578. * Gets the planes representing the frustum
  87579. * @param transform matrix to be applied to the returned planes
  87580. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87581. */
  87582. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87583. /**
  87584. * Gets the near frustum plane transformed by the transform matrix
  87585. * @param transform transformation matrix to be applied to the resulting frustum plane
  87586. * @param frustumPlane the resuling frustum plane
  87587. */
  87588. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87589. /**
  87590. * Gets the far frustum plane transformed by the transform matrix
  87591. * @param transform transformation matrix to be applied to the resulting frustum plane
  87592. * @param frustumPlane the resuling frustum plane
  87593. */
  87594. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87595. /**
  87596. * Gets the left frustum plane transformed by the transform matrix
  87597. * @param transform transformation matrix to be applied to the resulting frustum plane
  87598. * @param frustumPlane the resuling frustum plane
  87599. */
  87600. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87601. /**
  87602. * Gets the right frustum plane transformed by the transform matrix
  87603. * @param transform transformation matrix to be applied to the resulting frustum plane
  87604. * @param frustumPlane the resuling frustum plane
  87605. */
  87606. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87607. /**
  87608. * Gets the top frustum plane transformed by the transform matrix
  87609. * @param transform transformation matrix to be applied to the resulting frustum plane
  87610. * @param frustumPlane the resuling frustum plane
  87611. */
  87612. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87613. /**
  87614. * Gets the bottom frustum plane transformed by the transform matrix
  87615. * @param transform transformation matrix to be applied to the resulting frustum plane
  87616. * @param frustumPlane the resuling frustum plane
  87617. */
  87618. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87619. /**
  87620. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87621. * @param transform transformation matrix to be applied to the resulting frustum planes
  87622. * @param frustumPlanes the resuling frustum planes
  87623. */
  87624. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87625. }
  87626. }
  87627. declare module BABYLON {
  87628. /**
  87629. * Interface for the size containing width and height
  87630. */
  87631. export interface ISize {
  87632. /**
  87633. * Width
  87634. */
  87635. width: number;
  87636. /**
  87637. * Heighht
  87638. */
  87639. height: number;
  87640. }
  87641. /**
  87642. * Size containing widht and height
  87643. */
  87644. export class Size implements ISize {
  87645. /**
  87646. * Width
  87647. */
  87648. width: number;
  87649. /**
  87650. * Height
  87651. */
  87652. height: number;
  87653. /**
  87654. * Creates a Size object from the given width and height (floats).
  87655. * @param width width of the new size
  87656. * @param height height of the new size
  87657. */
  87658. constructor(width: number, height: number);
  87659. /**
  87660. * Returns a string with the Size width and height
  87661. * @returns a string with the Size width and height
  87662. */
  87663. toString(): string;
  87664. /**
  87665. * "Size"
  87666. * @returns the string "Size"
  87667. */
  87668. getClassName(): string;
  87669. /**
  87670. * Returns the Size hash code.
  87671. * @returns a hash code for a unique width and height
  87672. */
  87673. getHashCode(): number;
  87674. /**
  87675. * Updates the current size from the given one.
  87676. * @param src the given size
  87677. */
  87678. copyFrom(src: Size): void;
  87679. /**
  87680. * Updates in place the current Size from the given floats.
  87681. * @param width width of the new size
  87682. * @param height height of the new size
  87683. * @returns the updated Size.
  87684. */
  87685. copyFromFloats(width: number, height: number): Size;
  87686. /**
  87687. * Updates in place the current Size from the given floats.
  87688. * @param width width to set
  87689. * @param height height to set
  87690. * @returns the updated Size.
  87691. */
  87692. set(width: number, height: number): Size;
  87693. /**
  87694. * Multiplies the width and height by numbers
  87695. * @param w factor to multiple the width by
  87696. * @param h factor to multiple the height by
  87697. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87698. */
  87699. multiplyByFloats(w: number, h: number): Size;
  87700. /**
  87701. * Clones the size
  87702. * @returns a new Size copied from the given one.
  87703. */
  87704. clone(): Size;
  87705. /**
  87706. * True if the current Size and the given one width and height are strictly equal.
  87707. * @param other the other size to compare against
  87708. * @returns True if the current Size and the given one width and height are strictly equal.
  87709. */
  87710. equals(other: Size): boolean;
  87711. /**
  87712. * The surface of the Size : width * height (float).
  87713. */
  87714. get surface(): number;
  87715. /**
  87716. * Create a new size of zero
  87717. * @returns a new Size set to (0.0, 0.0)
  87718. */
  87719. static Zero(): Size;
  87720. /**
  87721. * Sums the width and height of two sizes
  87722. * @param otherSize size to add to this size
  87723. * @returns a new Size set as the addition result of the current Size and the given one.
  87724. */
  87725. add(otherSize: Size): Size;
  87726. /**
  87727. * Subtracts the width and height of two
  87728. * @param otherSize size to subtract to this size
  87729. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87730. */
  87731. subtract(otherSize: Size): Size;
  87732. /**
  87733. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87734. * @param start starting size to lerp between
  87735. * @param end end size to lerp between
  87736. * @param amount amount to lerp between the start and end values
  87737. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87738. */
  87739. static Lerp(start: Size, end: Size, amount: number): Size;
  87740. }
  87741. }
  87742. declare module BABYLON {
  87743. /**
  87744. * Contains position and normal vectors for a vertex
  87745. */
  87746. export class PositionNormalVertex {
  87747. /** the position of the vertex (defaut: 0,0,0) */
  87748. position: Vector3;
  87749. /** the normal of the vertex (defaut: 0,1,0) */
  87750. normal: Vector3;
  87751. /**
  87752. * Creates a PositionNormalVertex
  87753. * @param position the position of the vertex (defaut: 0,0,0)
  87754. * @param normal the normal of the vertex (defaut: 0,1,0)
  87755. */
  87756. constructor(
  87757. /** the position of the vertex (defaut: 0,0,0) */
  87758. position?: Vector3,
  87759. /** the normal of the vertex (defaut: 0,1,0) */
  87760. normal?: Vector3);
  87761. /**
  87762. * Clones the PositionNormalVertex
  87763. * @returns the cloned PositionNormalVertex
  87764. */
  87765. clone(): PositionNormalVertex;
  87766. }
  87767. /**
  87768. * Contains position, normal and uv vectors for a vertex
  87769. */
  87770. export class PositionNormalTextureVertex {
  87771. /** the position of the vertex (defaut: 0,0,0) */
  87772. position: Vector3;
  87773. /** the normal of the vertex (defaut: 0,1,0) */
  87774. normal: Vector3;
  87775. /** the uv of the vertex (default: 0,0) */
  87776. uv: Vector2;
  87777. /**
  87778. * Creates a PositionNormalTextureVertex
  87779. * @param position the position of the vertex (defaut: 0,0,0)
  87780. * @param normal the normal of the vertex (defaut: 0,1,0)
  87781. * @param uv the uv of the vertex (default: 0,0)
  87782. */
  87783. constructor(
  87784. /** the position of the vertex (defaut: 0,0,0) */
  87785. position?: Vector3,
  87786. /** the normal of the vertex (defaut: 0,1,0) */
  87787. normal?: Vector3,
  87788. /** the uv of the vertex (default: 0,0) */
  87789. uv?: Vector2);
  87790. /**
  87791. * Clones the PositionNormalTextureVertex
  87792. * @returns the cloned PositionNormalTextureVertex
  87793. */
  87794. clone(): PositionNormalTextureVertex;
  87795. }
  87796. }
  87797. declare module BABYLON {
  87798. /**
  87799. * Enum defining the type of animations supported by InputBlock
  87800. */
  87801. export enum AnimatedInputBlockTypes {
  87802. /** No animation */
  87803. None = 0,
  87804. /** Time based animation. Will only work for floats */
  87805. Time = 1
  87806. }
  87807. }
  87808. declare module BABYLON {
  87809. /**
  87810. * Interface describing all the common properties and methods a shadow light needs to implement.
  87811. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87812. * as well as binding the different shadow properties to the effects.
  87813. */
  87814. export interface IShadowLight extends Light {
  87815. /**
  87816. * The light id in the scene (used in scene.findLighById for instance)
  87817. */
  87818. id: string;
  87819. /**
  87820. * The position the shdow will be casted from.
  87821. */
  87822. position: Vector3;
  87823. /**
  87824. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87825. */
  87826. direction: Vector3;
  87827. /**
  87828. * The transformed position. Position of the light in world space taking parenting in account.
  87829. */
  87830. transformedPosition: Vector3;
  87831. /**
  87832. * The transformed direction. Direction of the light in world space taking parenting in account.
  87833. */
  87834. transformedDirection: Vector3;
  87835. /**
  87836. * The friendly name of the light in the scene.
  87837. */
  87838. name: string;
  87839. /**
  87840. * Defines the shadow projection clipping minimum z value.
  87841. */
  87842. shadowMinZ: number;
  87843. /**
  87844. * Defines the shadow projection clipping maximum z value.
  87845. */
  87846. shadowMaxZ: number;
  87847. /**
  87848. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87849. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87850. */
  87851. computeTransformedInformation(): boolean;
  87852. /**
  87853. * Gets the scene the light belongs to.
  87854. * @returns The scene
  87855. */
  87856. getScene(): Scene;
  87857. /**
  87858. * Callback defining a custom Projection Matrix Builder.
  87859. * This can be used to override the default projection matrix computation.
  87860. */
  87861. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87862. /**
  87863. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87864. * @param matrix The materix to updated with the projection information
  87865. * @param viewMatrix The transform matrix of the light
  87866. * @param renderList The list of mesh to render in the map
  87867. * @returns The current light
  87868. */
  87869. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87870. /**
  87871. * Gets the current depth scale used in ESM.
  87872. * @returns The scale
  87873. */
  87874. getDepthScale(): number;
  87875. /**
  87876. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87877. * @returns true if a cube texture needs to be use
  87878. */
  87879. needCube(): boolean;
  87880. /**
  87881. * Detects if the projection matrix requires to be recomputed this frame.
  87882. * @returns true if it requires to be recomputed otherwise, false.
  87883. */
  87884. needProjectionMatrixCompute(): boolean;
  87885. /**
  87886. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87887. */
  87888. forceProjectionMatrixCompute(): void;
  87889. /**
  87890. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87891. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87892. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87893. */
  87894. getShadowDirection(faceIndex?: number): Vector3;
  87895. /**
  87896. * Gets the minZ used for shadow according to both the scene and the light.
  87897. * @param activeCamera The camera we are returning the min for
  87898. * @returns the depth min z
  87899. */
  87900. getDepthMinZ(activeCamera: Camera): number;
  87901. /**
  87902. * Gets the maxZ used for shadow according to both the scene and the light.
  87903. * @param activeCamera The camera we are returning the max for
  87904. * @returns the depth max z
  87905. */
  87906. getDepthMaxZ(activeCamera: Camera): number;
  87907. }
  87908. /**
  87909. * Base implementation IShadowLight
  87910. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87911. */
  87912. export abstract class ShadowLight extends Light implements IShadowLight {
  87913. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87914. protected _position: Vector3;
  87915. protected _setPosition(value: Vector3): void;
  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. get position(): Vector3;
  87921. /**
  87922. * Sets the position the shadow will be casted from. Also use as the light position for both
  87923. * point and spot lights.
  87924. */
  87925. set position(value: Vector3);
  87926. protected _direction: Vector3;
  87927. protected _setDirection(value: Vector3): void;
  87928. /**
  87929. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87930. * Also use as the light direction on spot and directional lights.
  87931. */
  87932. get direction(): Vector3;
  87933. /**
  87934. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87935. * Also use as the light direction on spot and directional lights.
  87936. */
  87937. set direction(value: Vector3);
  87938. protected _shadowMinZ: number;
  87939. /**
  87940. * Gets the shadow projection clipping minimum z value.
  87941. */
  87942. get shadowMinZ(): number;
  87943. /**
  87944. * Sets the shadow projection clipping minimum z value.
  87945. */
  87946. set shadowMinZ(value: number);
  87947. protected _shadowMaxZ: number;
  87948. /**
  87949. * Sets the shadow projection clipping maximum z value.
  87950. */
  87951. get shadowMaxZ(): number;
  87952. /**
  87953. * Gets the shadow projection clipping maximum z value.
  87954. */
  87955. set shadowMaxZ(value: number);
  87956. /**
  87957. * Callback defining a custom Projection Matrix Builder.
  87958. * This can be used to override the default projection matrix computation.
  87959. */
  87960. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87961. /**
  87962. * The transformed position. Position of the light in world space taking parenting in account.
  87963. */
  87964. transformedPosition: Vector3;
  87965. /**
  87966. * The transformed direction. Direction of the light in world space taking parenting in account.
  87967. */
  87968. transformedDirection: Vector3;
  87969. private _needProjectionMatrixCompute;
  87970. /**
  87971. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87972. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87973. */
  87974. computeTransformedInformation(): boolean;
  87975. /**
  87976. * Return the depth scale used for the shadow map.
  87977. * @returns the depth scale.
  87978. */
  87979. getDepthScale(): number;
  87980. /**
  87981. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87982. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87983. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87984. */
  87985. getShadowDirection(faceIndex?: number): Vector3;
  87986. /**
  87987. * Returns the ShadowLight absolute position in the World.
  87988. * @returns the position vector in world space
  87989. */
  87990. getAbsolutePosition(): Vector3;
  87991. /**
  87992. * Sets the ShadowLight direction toward the passed target.
  87993. * @param target The point to target in local space
  87994. * @returns the updated ShadowLight direction
  87995. */
  87996. setDirectionToTarget(target: Vector3): Vector3;
  87997. /**
  87998. * Returns the light rotation in euler definition.
  87999. * @returns the x y z rotation in local space.
  88000. */
  88001. getRotation(): Vector3;
  88002. /**
  88003. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88004. * @returns true if a cube texture needs to be use
  88005. */
  88006. needCube(): boolean;
  88007. /**
  88008. * Detects if the projection matrix requires to be recomputed this frame.
  88009. * @returns true if it requires to be recomputed otherwise, false.
  88010. */
  88011. needProjectionMatrixCompute(): boolean;
  88012. /**
  88013. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88014. */
  88015. forceProjectionMatrixCompute(): void;
  88016. /** @hidden */
  88017. _initCache(): void;
  88018. /** @hidden */
  88019. _isSynchronized(): boolean;
  88020. /**
  88021. * Computes the world matrix of the node
  88022. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88023. * @returns the world matrix
  88024. */
  88025. computeWorldMatrix(force?: boolean): Matrix;
  88026. /**
  88027. * Gets the minZ used for shadow according to both the scene and the light.
  88028. * @param activeCamera The camera we are returning the min for
  88029. * @returns the depth min z
  88030. */
  88031. getDepthMinZ(activeCamera: Camera): number;
  88032. /**
  88033. * Gets the maxZ used for shadow according to both the scene and the light.
  88034. * @param activeCamera The camera we are returning the max for
  88035. * @returns the depth max z
  88036. */
  88037. getDepthMaxZ(activeCamera: Camera): number;
  88038. /**
  88039. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88040. * @param matrix The materix to updated with the projection information
  88041. * @param viewMatrix The transform matrix of the light
  88042. * @param renderList The list of mesh to render in the map
  88043. * @returns The current light
  88044. */
  88045. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88046. }
  88047. }
  88048. declare module BABYLON {
  88049. /** @hidden */
  88050. export var packingFunctions: {
  88051. name: string;
  88052. shader: string;
  88053. };
  88054. }
  88055. declare module BABYLON {
  88056. /** @hidden */
  88057. export var bayerDitherFunctions: {
  88058. name: string;
  88059. shader: string;
  88060. };
  88061. }
  88062. declare module BABYLON {
  88063. /** @hidden */
  88064. export var shadowMapFragmentDeclaration: {
  88065. name: string;
  88066. shader: string;
  88067. };
  88068. }
  88069. declare module BABYLON {
  88070. /** @hidden */
  88071. export var clipPlaneFragmentDeclaration: {
  88072. name: string;
  88073. shader: string;
  88074. };
  88075. }
  88076. declare module BABYLON {
  88077. /** @hidden */
  88078. export var clipPlaneFragment: {
  88079. name: string;
  88080. shader: string;
  88081. };
  88082. }
  88083. declare module BABYLON {
  88084. /** @hidden */
  88085. export var shadowMapFragment: {
  88086. name: string;
  88087. shader: string;
  88088. };
  88089. }
  88090. declare module BABYLON {
  88091. /** @hidden */
  88092. export var shadowMapPixelShader: {
  88093. name: string;
  88094. shader: string;
  88095. };
  88096. }
  88097. declare module BABYLON {
  88098. /** @hidden */
  88099. export var bonesDeclaration: {
  88100. name: string;
  88101. shader: string;
  88102. };
  88103. }
  88104. declare module BABYLON {
  88105. /** @hidden */
  88106. export var morphTargetsVertexGlobalDeclaration: {
  88107. name: string;
  88108. shader: string;
  88109. };
  88110. }
  88111. declare module BABYLON {
  88112. /** @hidden */
  88113. export var morphTargetsVertexDeclaration: {
  88114. name: string;
  88115. shader: string;
  88116. };
  88117. }
  88118. declare module BABYLON {
  88119. /** @hidden */
  88120. export var instancesDeclaration: {
  88121. name: string;
  88122. shader: string;
  88123. };
  88124. }
  88125. declare module BABYLON {
  88126. /** @hidden */
  88127. export var helperFunctions: {
  88128. name: string;
  88129. shader: string;
  88130. };
  88131. }
  88132. declare module BABYLON {
  88133. /** @hidden */
  88134. export var shadowMapVertexDeclaration: {
  88135. name: string;
  88136. shader: string;
  88137. };
  88138. }
  88139. declare module BABYLON {
  88140. /** @hidden */
  88141. export var clipPlaneVertexDeclaration: {
  88142. name: string;
  88143. shader: string;
  88144. };
  88145. }
  88146. declare module BABYLON {
  88147. /** @hidden */
  88148. export var morphTargetsVertex: {
  88149. name: string;
  88150. shader: string;
  88151. };
  88152. }
  88153. declare module BABYLON {
  88154. /** @hidden */
  88155. export var instancesVertex: {
  88156. name: string;
  88157. shader: string;
  88158. };
  88159. }
  88160. declare module BABYLON {
  88161. /** @hidden */
  88162. export var bonesVertex: {
  88163. name: string;
  88164. shader: string;
  88165. };
  88166. }
  88167. declare module BABYLON {
  88168. /** @hidden */
  88169. export var shadowMapVertexNormalBias: {
  88170. name: string;
  88171. shader: string;
  88172. };
  88173. }
  88174. declare module BABYLON {
  88175. /** @hidden */
  88176. export var shadowMapVertexMetric: {
  88177. name: string;
  88178. shader: string;
  88179. };
  88180. }
  88181. declare module BABYLON {
  88182. /** @hidden */
  88183. export var clipPlaneVertex: {
  88184. name: string;
  88185. shader: string;
  88186. };
  88187. }
  88188. declare module BABYLON {
  88189. /** @hidden */
  88190. export var shadowMapVertexShader: {
  88191. name: string;
  88192. shader: string;
  88193. };
  88194. }
  88195. declare module BABYLON {
  88196. /** @hidden */
  88197. export var depthBoxBlurPixelShader: {
  88198. name: string;
  88199. shader: string;
  88200. };
  88201. }
  88202. declare module BABYLON {
  88203. /** @hidden */
  88204. export var shadowMapFragmentSoftTransparentShadow: {
  88205. name: string;
  88206. shader: string;
  88207. };
  88208. }
  88209. declare module BABYLON {
  88210. /**
  88211. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88212. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88213. */
  88214. export class EffectFallbacks implements IEffectFallbacks {
  88215. private _defines;
  88216. private _currentRank;
  88217. private _maxRank;
  88218. private _mesh;
  88219. /**
  88220. * Removes the fallback from the bound mesh.
  88221. */
  88222. unBindMesh(): void;
  88223. /**
  88224. * Adds a fallback on the specified property.
  88225. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88226. * @param define The name of the define in the shader
  88227. */
  88228. addFallback(rank: number, define: string): void;
  88229. /**
  88230. * Sets the mesh to use CPU skinning when needing to fallback.
  88231. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88232. * @param mesh The mesh to use the fallbacks.
  88233. */
  88234. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88235. /**
  88236. * Checks to see if more fallbacks are still availible.
  88237. */
  88238. get hasMoreFallbacks(): boolean;
  88239. /**
  88240. * Removes the defines that should be removed when falling back.
  88241. * @param currentDefines defines the current define statements for the shader.
  88242. * @param effect defines the current effect we try to compile
  88243. * @returns The resulting defines with defines of the current rank removed.
  88244. */
  88245. reduce(currentDefines: string, effect: Effect): string;
  88246. }
  88247. }
  88248. declare module BABYLON {
  88249. /**
  88250. * Interface used to define Action
  88251. */
  88252. export interface IAction {
  88253. /**
  88254. * Trigger for the action
  88255. */
  88256. trigger: number;
  88257. /** Options of the trigger */
  88258. triggerOptions: any;
  88259. /**
  88260. * Gets the trigger parameters
  88261. * @returns the trigger parameters
  88262. */
  88263. getTriggerParameter(): any;
  88264. /**
  88265. * Internal only - executes current action event
  88266. * @hidden
  88267. */
  88268. _executeCurrent(evt?: ActionEvent): void;
  88269. /**
  88270. * Serialize placeholder for child classes
  88271. * @param parent of child
  88272. * @returns the serialized object
  88273. */
  88274. serialize(parent: any): any;
  88275. /**
  88276. * Internal only
  88277. * @hidden
  88278. */
  88279. _prepare(): void;
  88280. /**
  88281. * Internal only - manager for action
  88282. * @hidden
  88283. */
  88284. _actionManager: AbstractActionManager;
  88285. /**
  88286. * Adds action to chain of actions, may be a DoNothingAction
  88287. * @param action defines the next action to execute
  88288. * @returns The action passed in
  88289. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88290. */
  88291. then(action: IAction): IAction;
  88292. }
  88293. /**
  88294. * The action to be carried out following a trigger
  88295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  88296. */
  88297. export class Action implements IAction {
  88298. /** the trigger, with or without parameters, for the action */
  88299. triggerOptions: any;
  88300. /**
  88301. * Trigger for the action
  88302. */
  88303. trigger: number;
  88304. /**
  88305. * Internal only - manager for action
  88306. * @hidden
  88307. */
  88308. _actionManager: ActionManager;
  88309. private _nextActiveAction;
  88310. private _child;
  88311. private _condition?;
  88312. private _triggerParameter;
  88313. /**
  88314. * An event triggered prior to action being executed.
  88315. */
  88316. onBeforeExecuteObservable: Observable<Action>;
  88317. /**
  88318. * Creates a new Action
  88319. * @param triggerOptions the trigger, with or without parameters, for the action
  88320. * @param condition an optional determinant of action
  88321. */
  88322. constructor(
  88323. /** the trigger, with or without parameters, for the action */
  88324. triggerOptions: any, condition?: Condition);
  88325. /**
  88326. * Internal only
  88327. * @hidden
  88328. */
  88329. _prepare(): void;
  88330. /**
  88331. * Gets the trigger parameters
  88332. * @returns the trigger parameters
  88333. */
  88334. getTriggerParameter(): any;
  88335. /**
  88336. * Internal only - executes current action event
  88337. * @hidden
  88338. */
  88339. _executeCurrent(evt?: ActionEvent): void;
  88340. /**
  88341. * Execute placeholder for child classes
  88342. * @param evt optional action event
  88343. */
  88344. execute(evt?: ActionEvent): void;
  88345. /**
  88346. * Skips to next active action
  88347. */
  88348. skipToNextActiveAction(): void;
  88349. /**
  88350. * Adds action to chain of actions, may be a DoNothingAction
  88351. * @param action defines the next action to execute
  88352. * @returns The action passed in
  88353. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88354. */
  88355. then(action: Action): Action;
  88356. /**
  88357. * Internal only
  88358. * @hidden
  88359. */
  88360. _getProperty(propertyPath: string): string;
  88361. /**
  88362. * Internal only
  88363. * @hidden
  88364. */
  88365. _getEffectiveTarget(target: any, propertyPath: string): any;
  88366. /**
  88367. * Serialize placeholder for child classes
  88368. * @param parent of child
  88369. * @returns the serialized object
  88370. */
  88371. serialize(parent: any): any;
  88372. /**
  88373. * Internal only called by serialize
  88374. * @hidden
  88375. */
  88376. protected _serialize(serializedAction: any, parent?: any): any;
  88377. /**
  88378. * Internal only
  88379. * @hidden
  88380. */
  88381. static _SerializeValueAsString: (value: any) => string;
  88382. /**
  88383. * Internal only
  88384. * @hidden
  88385. */
  88386. static _GetTargetProperty: (target: Scene | Node) => {
  88387. name: string;
  88388. targetType: string;
  88389. value: string;
  88390. };
  88391. }
  88392. }
  88393. declare module BABYLON {
  88394. /**
  88395. * A Condition applied to an Action
  88396. */
  88397. export class Condition {
  88398. /**
  88399. * Internal only - manager for action
  88400. * @hidden
  88401. */
  88402. _actionManager: ActionManager;
  88403. /**
  88404. * Internal only
  88405. * @hidden
  88406. */
  88407. _evaluationId: number;
  88408. /**
  88409. * Internal only
  88410. * @hidden
  88411. */
  88412. _currentResult: boolean;
  88413. /**
  88414. * Creates a new Condition
  88415. * @param actionManager the manager of the action the condition is applied to
  88416. */
  88417. constructor(actionManager: ActionManager);
  88418. /**
  88419. * Check if the current condition is valid
  88420. * @returns a boolean
  88421. */
  88422. isValid(): boolean;
  88423. /**
  88424. * Internal only
  88425. * @hidden
  88426. */
  88427. _getProperty(propertyPath: string): string;
  88428. /**
  88429. * Internal only
  88430. * @hidden
  88431. */
  88432. _getEffectiveTarget(target: any, propertyPath: string): any;
  88433. /**
  88434. * Serialize placeholder for child classes
  88435. * @returns the serialized object
  88436. */
  88437. serialize(): any;
  88438. /**
  88439. * Internal only
  88440. * @hidden
  88441. */
  88442. protected _serialize(serializedCondition: any): any;
  88443. }
  88444. /**
  88445. * Defines specific conditional operators as extensions of Condition
  88446. */
  88447. export class ValueCondition extends Condition {
  88448. /** path to specify the property of the target the conditional operator uses */
  88449. propertyPath: string;
  88450. /** the value compared by the conditional operator against the current value of the property */
  88451. value: any;
  88452. /** the conditional operator, default ValueCondition.IsEqual */
  88453. operator: number;
  88454. /**
  88455. * Internal only
  88456. * @hidden
  88457. */
  88458. private static _IsEqual;
  88459. /**
  88460. * Internal only
  88461. * @hidden
  88462. */
  88463. private static _IsDifferent;
  88464. /**
  88465. * Internal only
  88466. * @hidden
  88467. */
  88468. private static _IsGreater;
  88469. /**
  88470. * Internal only
  88471. * @hidden
  88472. */
  88473. private static _IsLesser;
  88474. /**
  88475. * returns the number for IsEqual
  88476. */
  88477. static get IsEqual(): number;
  88478. /**
  88479. * Returns the number for IsDifferent
  88480. */
  88481. static get IsDifferent(): number;
  88482. /**
  88483. * Returns the number for IsGreater
  88484. */
  88485. static get IsGreater(): number;
  88486. /**
  88487. * Returns the number for IsLesser
  88488. */
  88489. static get IsLesser(): number;
  88490. /**
  88491. * Internal only The action manager for the condition
  88492. * @hidden
  88493. */
  88494. _actionManager: ActionManager;
  88495. /**
  88496. * Internal only
  88497. * @hidden
  88498. */
  88499. private _target;
  88500. /**
  88501. * Internal only
  88502. * @hidden
  88503. */
  88504. private _effectiveTarget;
  88505. /**
  88506. * Internal only
  88507. * @hidden
  88508. */
  88509. private _property;
  88510. /**
  88511. * Creates a new ValueCondition
  88512. * @param actionManager manager for the action the condition applies to
  88513. * @param target for the action
  88514. * @param propertyPath path to specify the property of the target the conditional operator uses
  88515. * @param value the value compared by the conditional operator against the current value of the property
  88516. * @param operator the conditional operator, default ValueCondition.IsEqual
  88517. */
  88518. constructor(actionManager: ActionManager, target: any,
  88519. /** path to specify the property of the target the conditional operator uses */
  88520. propertyPath: string,
  88521. /** the value compared by the conditional operator against the current value of the property */
  88522. value: any,
  88523. /** the conditional operator, default ValueCondition.IsEqual */
  88524. operator?: number);
  88525. /**
  88526. * Compares the given value with the property value for the specified conditional operator
  88527. * @returns the result of the comparison
  88528. */
  88529. isValid(): boolean;
  88530. /**
  88531. * Serialize the ValueCondition into a JSON compatible object
  88532. * @returns serialization object
  88533. */
  88534. serialize(): any;
  88535. /**
  88536. * Gets the name of the conditional operator for the ValueCondition
  88537. * @param operator the conditional operator
  88538. * @returns the name
  88539. */
  88540. static GetOperatorName(operator: number): string;
  88541. }
  88542. /**
  88543. * Defines a predicate condition as an extension of Condition
  88544. */
  88545. export class PredicateCondition extends Condition {
  88546. /** defines the predicate function used to validate the condition */
  88547. predicate: () => boolean;
  88548. /**
  88549. * Internal only - manager for action
  88550. * @hidden
  88551. */
  88552. _actionManager: ActionManager;
  88553. /**
  88554. * Creates a new PredicateCondition
  88555. * @param actionManager manager for the action the condition applies to
  88556. * @param predicate defines the predicate function used to validate the condition
  88557. */
  88558. constructor(actionManager: ActionManager,
  88559. /** defines the predicate function used to validate the condition */
  88560. predicate: () => boolean);
  88561. /**
  88562. * @returns the validity of the predicate condition
  88563. */
  88564. isValid(): boolean;
  88565. }
  88566. /**
  88567. * Defines a state condition as an extension of Condition
  88568. */
  88569. export class StateCondition extends Condition {
  88570. /** Value to compare with target state */
  88571. value: string;
  88572. /**
  88573. * Internal only - manager for action
  88574. * @hidden
  88575. */
  88576. _actionManager: ActionManager;
  88577. /**
  88578. * Internal only
  88579. * @hidden
  88580. */
  88581. private _target;
  88582. /**
  88583. * Creates a new StateCondition
  88584. * @param actionManager manager for the action the condition applies to
  88585. * @param target of the condition
  88586. * @param value to compare with target state
  88587. */
  88588. constructor(actionManager: ActionManager, target: any,
  88589. /** Value to compare with target state */
  88590. value: string);
  88591. /**
  88592. * Gets a boolean indicating if the current condition is met
  88593. * @returns the validity of the state
  88594. */
  88595. isValid(): boolean;
  88596. /**
  88597. * Serialize the StateCondition into a JSON compatible object
  88598. * @returns serialization object
  88599. */
  88600. serialize(): any;
  88601. }
  88602. }
  88603. declare module BABYLON {
  88604. /**
  88605. * This defines an action responsible to toggle a boolean once triggered.
  88606. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88607. */
  88608. export class SwitchBooleanAction extends Action {
  88609. /**
  88610. * The path to the boolean property in the target object
  88611. */
  88612. propertyPath: string;
  88613. private _target;
  88614. private _effectiveTarget;
  88615. private _property;
  88616. /**
  88617. * Instantiate the action
  88618. * @param triggerOptions defines the trigger options
  88619. * @param target defines the object containing the boolean
  88620. * @param propertyPath defines the path to the boolean property in the target object
  88621. * @param condition defines the trigger related conditions
  88622. */
  88623. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88624. /** @hidden */
  88625. _prepare(): void;
  88626. /**
  88627. * Execute the action toggle the boolean value.
  88628. */
  88629. execute(): void;
  88630. /**
  88631. * Serializes the actions and its related information.
  88632. * @param parent defines the object to serialize in
  88633. * @returns the serialized object
  88634. */
  88635. serialize(parent: any): any;
  88636. }
  88637. /**
  88638. * This defines an action responsible to set a the state field of the target
  88639. * to a desired value once triggered.
  88640. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88641. */
  88642. export class SetStateAction extends Action {
  88643. /**
  88644. * The value to store in the state field.
  88645. */
  88646. value: string;
  88647. private _target;
  88648. /**
  88649. * Instantiate the action
  88650. * @param triggerOptions defines the trigger options
  88651. * @param target defines the object containing the state property
  88652. * @param value defines the value to store in the state field
  88653. * @param condition defines the trigger related conditions
  88654. */
  88655. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88656. /**
  88657. * Execute the action and store the value on the target state property.
  88658. */
  88659. execute(): void;
  88660. /**
  88661. * Serializes the actions and its related information.
  88662. * @param parent defines the object to serialize in
  88663. * @returns the serialized object
  88664. */
  88665. serialize(parent: any): any;
  88666. }
  88667. /**
  88668. * This defines an action responsible to set a property of the target
  88669. * to a desired value once triggered.
  88670. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88671. */
  88672. export class SetValueAction extends Action {
  88673. /**
  88674. * The path of the property to set in the target.
  88675. */
  88676. propertyPath: string;
  88677. /**
  88678. * The value to set in the property
  88679. */
  88680. value: any;
  88681. private _target;
  88682. private _effectiveTarget;
  88683. private _property;
  88684. /**
  88685. * Instantiate the action
  88686. * @param triggerOptions defines the trigger options
  88687. * @param target defines the object containing the property
  88688. * @param propertyPath defines the path of the property to set in the target
  88689. * @param value defines the value to set in the property
  88690. * @param condition defines the trigger related conditions
  88691. */
  88692. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88693. /** @hidden */
  88694. _prepare(): void;
  88695. /**
  88696. * Execute the action and set the targetted property to the desired value.
  88697. */
  88698. execute(): void;
  88699. /**
  88700. * Serializes the actions and its related information.
  88701. * @param parent defines the object to serialize in
  88702. * @returns the serialized object
  88703. */
  88704. serialize(parent: any): any;
  88705. }
  88706. /**
  88707. * This defines an action responsible to increment the target value
  88708. * to a desired value once triggered.
  88709. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88710. */
  88711. export class IncrementValueAction extends Action {
  88712. /**
  88713. * The path of the property to increment in the target.
  88714. */
  88715. propertyPath: string;
  88716. /**
  88717. * The value we should increment the property by.
  88718. */
  88719. value: any;
  88720. private _target;
  88721. private _effectiveTarget;
  88722. private _property;
  88723. /**
  88724. * Instantiate the action
  88725. * @param triggerOptions defines the trigger options
  88726. * @param target defines the object containing the property
  88727. * @param propertyPath defines the path of the property to increment in the target
  88728. * @param value defines the value value we should increment the property by
  88729. * @param condition defines the trigger related conditions
  88730. */
  88731. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88732. /** @hidden */
  88733. _prepare(): void;
  88734. /**
  88735. * Execute the action and increment the target of the value amount.
  88736. */
  88737. execute(): void;
  88738. /**
  88739. * Serializes the actions and its related information.
  88740. * @param parent defines the object to serialize in
  88741. * @returns the serialized object
  88742. */
  88743. serialize(parent: any): any;
  88744. }
  88745. /**
  88746. * This defines an action responsible to start an animation once triggered.
  88747. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88748. */
  88749. export class PlayAnimationAction extends Action {
  88750. /**
  88751. * Where the animation should start (animation frame)
  88752. */
  88753. from: number;
  88754. /**
  88755. * Where the animation should stop (animation frame)
  88756. */
  88757. to: number;
  88758. /**
  88759. * Define if the animation should loop or stop after the first play.
  88760. */
  88761. loop?: boolean;
  88762. private _target;
  88763. /**
  88764. * Instantiate the action
  88765. * @param triggerOptions defines the trigger options
  88766. * @param target defines the target animation or animation name
  88767. * @param from defines from where the animation should start (animation frame)
  88768. * @param end defines where the animation should stop (animation frame)
  88769. * @param loop defines if the animation should loop or stop after the first play
  88770. * @param condition defines the trigger related conditions
  88771. */
  88772. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88773. /** @hidden */
  88774. _prepare(): void;
  88775. /**
  88776. * Execute the action and play the animation.
  88777. */
  88778. execute(): void;
  88779. /**
  88780. * Serializes the actions and its related information.
  88781. * @param parent defines the object to serialize in
  88782. * @returns the serialized object
  88783. */
  88784. serialize(parent: any): any;
  88785. }
  88786. /**
  88787. * This defines an action responsible to stop an animation once triggered.
  88788. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88789. */
  88790. export class StopAnimationAction extends Action {
  88791. private _target;
  88792. /**
  88793. * Instantiate the action
  88794. * @param triggerOptions defines the trigger options
  88795. * @param target defines the target animation or animation name
  88796. * @param condition defines the trigger related conditions
  88797. */
  88798. constructor(triggerOptions: any, target: any, condition?: Condition);
  88799. /** @hidden */
  88800. _prepare(): void;
  88801. /**
  88802. * Execute the action and stop the animation.
  88803. */
  88804. execute(): void;
  88805. /**
  88806. * Serializes the actions and its related information.
  88807. * @param parent defines the object to serialize in
  88808. * @returns the serialized object
  88809. */
  88810. serialize(parent: any): any;
  88811. }
  88812. /**
  88813. * This defines an action responsible that does nothing once triggered.
  88814. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88815. */
  88816. export class DoNothingAction extends Action {
  88817. /**
  88818. * Instantiate the action
  88819. * @param triggerOptions defines the trigger options
  88820. * @param condition defines the trigger related conditions
  88821. */
  88822. constructor(triggerOptions?: any, condition?: Condition);
  88823. /**
  88824. * Execute the action and do nothing.
  88825. */
  88826. execute(): void;
  88827. /**
  88828. * Serializes the actions and its related information.
  88829. * @param parent defines the object to serialize in
  88830. * @returns the serialized object
  88831. */
  88832. serialize(parent: any): any;
  88833. }
  88834. /**
  88835. * This defines an action responsible to trigger several actions once triggered.
  88836. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88837. */
  88838. export class CombineAction extends Action {
  88839. /**
  88840. * The list of aggregated animations to run.
  88841. */
  88842. children: Action[];
  88843. /**
  88844. * Instantiate the action
  88845. * @param triggerOptions defines the trigger options
  88846. * @param children defines the list of aggregated animations to run
  88847. * @param condition defines the trigger related conditions
  88848. */
  88849. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88850. /** @hidden */
  88851. _prepare(): void;
  88852. /**
  88853. * Execute the action and executes all the aggregated actions.
  88854. */
  88855. execute(evt: ActionEvent): void;
  88856. /**
  88857. * Serializes the actions and its related information.
  88858. * @param parent defines the object to serialize in
  88859. * @returns the serialized object
  88860. */
  88861. serialize(parent: any): any;
  88862. }
  88863. /**
  88864. * This defines an action responsible to run code (external event) once triggered.
  88865. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88866. */
  88867. export class ExecuteCodeAction extends Action {
  88868. /**
  88869. * The callback function to run.
  88870. */
  88871. func: (evt: ActionEvent) => void;
  88872. /**
  88873. * Instantiate the action
  88874. * @param triggerOptions defines the trigger options
  88875. * @param func defines the callback function to run
  88876. * @param condition defines the trigger related conditions
  88877. */
  88878. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88879. /**
  88880. * Execute the action and run the attached code.
  88881. */
  88882. execute(evt: ActionEvent): void;
  88883. }
  88884. /**
  88885. * This defines an action responsible to set the parent property of the target once triggered.
  88886. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88887. */
  88888. export class SetParentAction extends Action {
  88889. private _parent;
  88890. private _target;
  88891. /**
  88892. * Instantiate the action
  88893. * @param triggerOptions defines the trigger options
  88894. * @param target defines the target containing the parent property
  88895. * @param parent defines from where the animation should start (animation frame)
  88896. * @param condition defines the trigger related conditions
  88897. */
  88898. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88899. /** @hidden */
  88900. _prepare(): void;
  88901. /**
  88902. * Execute the action and set the parent property.
  88903. */
  88904. execute(): void;
  88905. /**
  88906. * Serializes the actions and its related information.
  88907. * @param parent defines the object to serialize in
  88908. * @returns the serialized object
  88909. */
  88910. serialize(parent: any): any;
  88911. }
  88912. }
  88913. declare module BABYLON {
  88914. /**
  88915. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88916. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88917. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88918. */
  88919. export class ActionManager extends AbstractActionManager {
  88920. /**
  88921. * Nothing
  88922. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88923. */
  88924. static readonly NothingTrigger: number;
  88925. /**
  88926. * On pick
  88927. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88928. */
  88929. static readonly OnPickTrigger: number;
  88930. /**
  88931. * On left pick
  88932. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88933. */
  88934. static readonly OnLeftPickTrigger: number;
  88935. /**
  88936. * On right pick
  88937. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88938. */
  88939. static readonly OnRightPickTrigger: number;
  88940. /**
  88941. * On center pick
  88942. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88943. */
  88944. static readonly OnCenterPickTrigger: number;
  88945. /**
  88946. * On pick down
  88947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88948. */
  88949. static readonly OnPickDownTrigger: number;
  88950. /**
  88951. * On double pick
  88952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88953. */
  88954. static readonly OnDoublePickTrigger: number;
  88955. /**
  88956. * On pick up
  88957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88958. */
  88959. static readonly OnPickUpTrigger: number;
  88960. /**
  88961. * On pick out.
  88962. * This trigger will only be raised if you also declared a OnPickDown
  88963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88964. */
  88965. static readonly OnPickOutTrigger: number;
  88966. /**
  88967. * On long press
  88968. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88969. */
  88970. static readonly OnLongPressTrigger: number;
  88971. /**
  88972. * On pointer over
  88973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88974. */
  88975. static readonly OnPointerOverTrigger: number;
  88976. /**
  88977. * On pointer out
  88978. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88979. */
  88980. static readonly OnPointerOutTrigger: number;
  88981. /**
  88982. * On every frame
  88983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88984. */
  88985. static readonly OnEveryFrameTrigger: number;
  88986. /**
  88987. * On intersection enter
  88988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88989. */
  88990. static readonly OnIntersectionEnterTrigger: number;
  88991. /**
  88992. * On intersection exit
  88993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88994. */
  88995. static readonly OnIntersectionExitTrigger: number;
  88996. /**
  88997. * On key down
  88998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88999. */
  89000. static readonly OnKeyDownTrigger: number;
  89001. /**
  89002. * On key up
  89003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89004. */
  89005. static readonly OnKeyUpTrigger: number;
  89006. private _scene;
  89007. /**
  89008. * Creates a new action manager
  89009. * @param scene defines the hosting scene
  89010. */
  89011. constructor(scene: Scene);
  89012. /**
  89013. * Releases all associated resources
  89014. */
  89015. dispose(): void;
  89016. /**
  89017. * Gets hosting scene
  89018. * @returns the hosting scene
  89019. */
  89020. getScene(): Scene;
  89021. /**
  89022. * Does this action manager handles actions of any of the given triggers
  89023. * @param triggers defines the triggers to be tested
  89024. * @return a boolean indicating whether one (or more) of the triggers is handled
  89025. */
  89026. hasSpecificTriggers(triggers: number[]): boolean;
  89027. /**
  89028. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89029. * speed.
  89030. * @param triggerA defines the trigger to be tested
  89031. * @param triggerB defines the trigger to be tested
  89032. * @return a boolean indicating whether one (or more) of the triggers is handled
  89033. */
  89034. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89035. /**
  89036. * Does this action manager handles actions of a given trigger
  89037. * @param trigger defines the trigger to be tested
  89038. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89039. * @return whether the trigger is handled
  89040. */
  89041. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89042. /**
  89043. * Does this action manager has pointer triggers
  89044. */
  89045. get hasPointerTriggers(): boolean;
  89046. /**
  89047. * Does this action manager has pick triggers
  89048. */
  89049. get hasPickTriggers(): boolean;
  89050. /**
  89051. * Registers an action to this action manager
  89052. * @param action defines the action to be registered
  89053. * @return the action amended (prepared) after registration
  89054. */
  89055. registerAction(action: IAction): Nullable<IAction>;
  89056. /**
  89057. * Unregisters an action to this action manager
  89058. * @param action defines the action to be unregistered
  89059. * @return a boolean indicating whether the action has been unregistered
  89060. */
  89061. unregisterAction(action: IAction): Boolean;
  89062. /**
  89063. * Process a specific trigger
  89064. * @param trigger defines the trigger to process
  89065. * @param evt defines the event details to be processed
  89066. */
  89067. processTrigger(trigger: number, evt?: IActionEvent): void;
  89068. /** @hidden */
  89069. _getEffectiveTarget(target: any, propertyPath: string): any;
  89070. /** @hidden */
  89071. _getProperty(propertyPath: string): string;
  89072. /**
  89073. * Serialize this manager to a JSON object
  89074. * @param name defines the property name to store this manager
  89075. * @returns a JSON representation of this manager
  89076. */
  89077. serialize(name: string): any;
  89078. /**
  89079. * Creates a new ActionManager from a JSON data
  89080. * @param parsedActions defines the JSON data to read from
  89081. * @param object defines the hosting mesh
  89082. * @param scene defines the hosting scene
  89083. */
  89084. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89085. /**
  89086. * Get a trigger name by index
  89087. * @param trigger defines the trigger index
  89088. * @returns a trigger name
  89089. */
  89090. static GetTriggerName(trigger: number): string;
  89091. }
  89092. }
  89093. declare module BABYLON {
  89094. /**
  89095. * Class used to represent a sprite
  89096. * @see https://doc.babylonjs.com/babylon101/sprites
  89097. */
  89098. export class Sprite implements IAnimatable {
  89099. /** defines the name */
  89100. name: string;
  89101. /** Gets or sets the current world position */
  89102. position: Vector3;
  89103. /** Gets or sets the main color */
  89104. color: Color4;
  89105. /** Gets or sets the width */
  89106. width: number;
  89107. /** Gets or sets the height */
  89108. height: number;
  89109. /** Gets or sets rotation angle */
  89110. angle: number;
  89111. /** Gets or sets the cell index in the sprite sheet */
  89112. cellIndex: number;
  89113. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89114. cellRef: string;
  89115. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89116. invertU: boolean;
  89117. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89118. invertV: boolean;
  89119. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89120. disposeWhenFinishedAnimating: boolean;
  89121. /** Gets the list of attached animations */
  89122. animations: Nullable<Array<Animation>>;
  89123. /** Gets or sets a boolean indicating if the sprite can be picked */
  89124. isPickable: boolean;
  89125. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89126. useAlphaForPicking: boolean;
  89127. /** @hidden */
  89128. _xOffset: number;
  89129. /** @hidden */
  89130. _yOffset: number;
  89131. /** @hidden */
  89132. _xSize: number;
  89133. /** @hidden */
  89134. _ySize: number;
  89135. /**
  89136. * Gets or sets the associated action manager
  89137. */
  89138. actionManager: Nullable<ActionManager>;
  89139. /**
  89140. * An event triggered when the control has been disposed
  89141. */
  89142. onDisposeObservable: Observable<Sprite>;
  89143. private _animationStarted;
  89144. private _loopAnimation;
  89145. private _fromIndex;
  89146. private _toIndex;
  89147. private _delay;
  89148. private _direction;
  89149. private _manager;
  89150. private _time;
  89151. private _onAnimationEnd;
  89152. /**
  89153. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89154. */
  89155. isVisible: boolean;
  89156. /**
  89157. * Gets or sets the sprite size
  89158. */
  89159. get size(): number;
  89160. set size(value: number);
  89161. /**
  89162. * Returns a boolean indicating if the animation is started
  89163. */
  89164. get animationStarted(): boolean;
  89165. /**
  89166. * Gets or sets the unique id of the sprite
  89167. */
  89168. uniqueId: number;
  89169. /**
  89170. * Gets the manager of this sprite
  89171. */
  89172. get manager(): ISpriteManager;
  89173. /**
  89174. * Creates a new Sprite
  89175. * @param name defines the name
  89176. * @param manager defines the manager
  89177. */
  89178. constructor(
  89179. /** defines the name */
  89180. name: string, manager: ISpriteManager);
  89181. /**
  89182. * Returns the string "Sprite"
  89183. * @returns "Sprite"
  89184. */
  89185. getClassName(): string;
  89186. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89187. get fromIndex(): number;
  89188. set fromIndex(value: number);
  89189. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  89190. get toIndex(): number;
  89191. set toIndex(value: number);
  89192. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89193. get loopAnimation(): boolean;
  89194. set loopAnimation(value: boolean);
  89195. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89196. get delay(): number;
  89197. set delay(value: number);
  89198. /**
  89199. * Starts an animation
  89200. * @param from defines the initial key
  89201. * @param to defines the end key
  89202. * @param loop defines if the animation must loop
  89203. * @param delay defines the start delay (in ms)
  89204. * @param onAnimationEnd defines a callback to call when animation ends
  89205. */
  89206. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89207. /** Stops current animation (if any) */
  89208. stopAnimation(): void;
  89209. /** @hidden */
  89210. _animate(deltaTime: number): void;
  89211. /** Release associated resources */
  89212. dispose(): void;
  89213. /**
  89214. * Serializes the sprite to a JSON object
  89215. * @returns the JSON object
  89216. */
  89217. serialize(): any;
  89218. /**
  89219. * Parses a JSON object to create a new sprite
  89220. * @param parsedSprite The JSON object to parse
  89221. * @param manager defines the hosting manager
  89222. * @returns the new sprite
  89223. */
  89224. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89225. }
  89226. }
  89227. declare module BABYLON {
  89228. /**
  89229. * Information about the result of picking within a scene
  89230. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89231. */
  89232. export class PickingInfo {
  89233. /** @hidden */
  89234. _pickingUnavailable: boolean;
  89235. /**
  89236. * If the pick collided with an object
  89237. */
  89238. hit: boolean;
  89239. /**
  89240. * Distance away where the pick collided
  89241. */
  89242. distance: number;
  89243. /**
  89244. * The location of pick collision
  89245. */
  89246. pickedPoint: Nullable<Vector3>;
  89247. /**
  89248. * The mesh corresponding the the pick collision
  89249. */
  89250. pickedMesh: Nullable<AbstractMesh>;
  89251. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  89252. bu: number;
  89253. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  89254. bv: number;
  89255. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89256. faceId: number;
  89257. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89258. subMeshFaceId: number;
  89259. /** Id of the the submesh that was picked */
  89260. subMeshId: number;
  89261. /** If a sprite was picked, this will be the sprite the pick collided with */
  89262. pickedSprite: Nullable<Sprite>;
  89263. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  89264. thinInstanceIndex: number;
  89265. /**
  89266. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  89267. */
  89268. originMesh: Nullable<AbstractMesh>;
  89269. /**
  89270. * The ray that was used to perform the picking.
  89271. */
  89272. ray: Nullable<Ray>;
  89273. /**
  89274. * Gets the normal correspodning to the face the pick collided with
  89275. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  89276. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  89277. * @returns The normal correspodning to the face the pick collided with
  89278. */
  89279. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  89280. /**
  89281. * Gets the texture coordinates of where the pick occured
  89282. * @returns the vector containing the coordnates of the texture
  89283. */
  89284. getTextureCoordinates(): Nullable<Vector2>;
  89285. }
  89286. }
  89287. declare module BABYLON {
  89288. /**
  89289. * Class representing a ray with position and direction
  89290. */
  89291. export class Ray {
  89292. /** origin point */
  89293. origin: Vector3;
  89294. /** direction */
  89295. direction: Vector3;
  89296. /** length of the ray */
  89297. length: number;
  89298. private static readonly _TmpVector3;
  89299. private _tmpRay;
  89300. /**
  89301. * Creates a new ray
  89302. * @param origin origin point
  89303. * @param direction direction
  89304. * @param length length of the ray
  89305. */
  89306. constructor(
  89307. /** origin point */
  89308. origin: Vector3,
  89309. /** direction */
  89310. direction: Vector3,
  89311. /** length of the ray */
  89312. length?: number);
  89313. /**
  89314. * Checks if the ray intersects a box
  89315. * This does not account for the ray lenght by design to improve perfs.
  89316. * @param minimum bound of the box
  89317. * @param maximum bound of the box
  89318. * @param intersectionTreshold extra extend to be added to the box in all direction
  89319. * @returns if the box was hit
  89320. */
  89321. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  89322. /**
  89323. * Checks if the ray intersects a box
  89324. * This does not account for the ray lenght by design to improve perfs.
  89325. * @param box the bounding box to check
  89326. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  89327. * @returns if the box was hit
  89328. */
  89329. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  89330. /**
  89331. * If the ray hits a sphere
  89332. * @param sphere the bounding sphere to check
  89333. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  89334. * @returns true if it hits the sphere
  89335. */
  89336. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  89337. /**
  89338. * If the ray hits a triange
  89339. * @param vertex0 triangle vertex
  89340. * @param vertex1 triangle vertex
  89341. * @param vertex2 triangle vertex
  89342. * @returns intersection information if hit
  89343. */
  89344. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  89345. /**
  89346. * Checks if ray intersects a plane
  89347. * @param plane the plane to check
  89348. * @returns the distance away it was hit
  89349. */
  89350. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  89351. /**
  89352. * Calculate the intercept of a ray on a given axis
  89353. * @param axis to check 'x' | 'y' | 'z'
  89354. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  89355. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  89356. */
  89357. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89358. /**
  89359. * Checks if ray intersects a mesh
  89360. * @param mesh the mesh to check
  89361. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89362. * @returns picking info of the intersecton
  89363. */
  89364. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89365. /**
  89366. * Checks if ray intersects a mesh
  89367. * @param meshes the meshes to check
  89368. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89369. * @param results array to store result in
  89370. * @returns Array of picking infos
  89371. */
  89372. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89373. private _comparePickingInfo;
  89374. private static smallnum;
  89375. private static rayl;
  89376. /**
  89377. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89378. * @param sega the first point of the segment to test the intersection against
  89379. * @param segb the second point of the segment to test the intersection against
  89380. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89381. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89382. */
  89383. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89384. /**
  89385. * Update the ray from viewport position
  89386. * @param x position
  89387. * @param y y position
  89388. * @param viewportWidth viewport width
  89389. * @param viewportHeight viewport height
  89390. * @param world world matrix
  89391. * @param view view matrix
  89392. * @param projection projection matrix
  89393. * @returns this ray updated
  89394. */
  89395. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89396. /**
  89397. * Creates a ray with origin and direction of 0,0,0
  89398. * @returns the new ray
  89399. */
  89400. static Zero(): Ray;
  89401. /**
  89402. * Creates a new ray from screen space and viewport
  89403. * @param x position
  89404. * @param y y position
  89405. * @param viewportWidth viewport width
  89406. * @param viewportHeight viewport height
  89407. * @param world world matrix
  89408. * @param view view matrix
  89409. * @param projection projection matrix
  89410. * @returns new ray
  89411. */
  89412. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89413. /**
  89414. * 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
  89415. * transformed to the given world matrix.
  89416. * @param origin The origin point
  89417. * @param end The end point
  89418. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89419. * @returns the new ray
  89420. */
  89421. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89422. /**
  89423. * Transforms a ray by a matrix
  89424. * @param ray ray to transform
  89425. * @param matrix matrix to apply
  89426. * @returns the resulting new ray
  89427. */
  89428. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89429. /**
  89430. * Transforms a ray by a matrix
  89431. * @param ray ray to transform
  89432. * @param matrix matrix to apply
  89433. * @param result ray to store result in
  89434. */
  89435. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89436. /**
  89437. * Unproject a ray from screen space to object space
  89438. * @param sourceX defines the screen space x coordinate to use
  89439. * @param sourceY defines the screen space y coordinate to use
  89440. * @param viewportWidth defines the current width of the viewport
  89441. * @param viewportHeight defines the current height of the viewport
  89442. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89443. * @param view defines the view matrix to use
  89444. * @param projection defines the projection matrix to use
  89445. */
  89446. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89447. }
  89448. /**
  89449. * Type used to define predicate used to select faces when a mesh intersection is detected
  89450. */
  89451. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89452. interface Scene {
  89453. /** @hidden */
  89454. _tempPickingRay: Nullable<Ray>;
  89455. /** @hidden */
  89456. _cachedRayForTransform: Ray;
  89457. /** @hidden */
  89458. _pickWithRayInverseMatrix: Matrix;
  89459. /** @hidden */
  89460. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89461. /** @hidden */
  89462. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89463. /** @hidden */
  89464. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89465. }
  89466. }
  89467. declare module BABYLON {
  89468. /**
  89469. * Groups all the scene component constants in one place to ease maintenance.
  89470. * @hidden
  89471. */
  89472. export class SceneComponentConstants {
  89473. static readonly NAME_EFFECTLAYER: string;
  89474. static readonly NAME_LAYER: string;
  89475. static readonly NAME_LENSFLARESYSTEM: string;
  89476. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89477. static readonly NAME_PARTICLESYSTEM: string;
  89478. static readonly NAME_GAMEPAD: string;
  89479. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89480. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89481. static readonly NAME_PREPASSRENDERER: string;
  89482. static readonly NAME_DEPTHRENDERER: string;
  89483. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89484. static readonly NAME_SPRITE: string;
  89485. static readonly NAME_OUTLINERENDERER: string;
  89486. static readonly NAME_PROCEDURALTEXTURE: string;
  89487. static readonly NAME_SHADOWGENERATOR: string;
  89488. static readonly NAME_OCTREE: string;
  89489. static readonly NAME_PHYSICSENGINE: string;
  89490. static readonly NAME_AUDIO: string;
  89491. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89492. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89493. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89494. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89495. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89496. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89497. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89498. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89499. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89500. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89501. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89502. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89503. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89504. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89505. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89506. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89507. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89508. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89509. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89510. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89511. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89512. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89513. static readonly STEP_AFTERRENDER_AUDIO: number;
  89514. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89515. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89516. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89517. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89518. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89519. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89520. static readonly STEP_POINTERMOVE_SPRITE: number;
  89521. static readonly STEP_POINTERDOWN_SPRITE: number;
  89522. static readonly STEP_POINTERUP_SPRITE: number;
  89523. }
  89524. /**
  89525. * This represents a scene component.
  89526. *
  89527. * This is used to decouple the dependency the scene is having on the different workloads like
  89528. * layers, post processes...
  89529. */
  89530. export interface ISceneComponent {
  89531. /**
  89532. * The name of the component. Each component must have a unique name.
  89533. */
  89534. name: string;
  89535. /**
  89536. * The scene the component belongs to.
  89537. */
  89538. scene: Scene;
  89539. /**
  89540. * Register the component to one instance of a scene.
  89541. */
  89542. register(): void;
  89543. /**
  89544. * Rebuilds the elements related to this component in case of
  89545. * context lost for instance.
  89546. */
  89547. rebuild(): void;
  89548. /**
  89549. * Disposes the component and the associated ressources.
  89550. */
  89551. dispose(): void;
  89552. }
  89553. /**
  89554. * This represents a SERIALIZABLE scene component.
  89555. *
  89556. * This extends Scene Component to add Serialization methods on top.
  89557. */
  89558. export interface ISceneSerializableComponent extends ISceneComponent {
  89559. /**
  89560. * Adds all the elements from the container to the scene
  89561. * @param container the container holding the elements
  89562. */
  89563. addFromContainer(container: AbstractScene): void;
  89564. /**
  89565. * Removes all the elements in the container from the scene
  89566. * @param container contains the elements to remove
  89567. * @param dispose if the removed element should be disposed (default: false)
  89568. */
  89569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89570. /**
  89571. * Serializes the component data to the specified json object
  89572. * @param serializationObject The object to serialize to
  89573. */
  89574. serialize(serializationObject: any): void;
  89575. }
  89576. /**
  89577. * Strong typing of a Mesh related stage step action
  89578. */
  89579. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89580. /**
  89581. * Strong typing of a Evaluate Sub Mesh related stage step action
  89582. */
  89583. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89584. /**
  89585. * Strong typing of a Active Mesh related stage step action
  89586. */
  89587. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89588. /**
  89589. * Strong typing of a Camera related stage step action
  89590. */
  89591. export type CameraStageAction = (camera: Camera) => void;
  89592. /**
  89593. * Strong typing of a Camera Frame buffer related stage step action
  89594. */
  89595. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89596. /**
  89597. * Strong typing of a Render Target related stage step action
  89598. */
  89599. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89600. /**
  89601. * Strong typing of a RenderingGroup related stage step action
  89602. */
  89603. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89604. /**
  89605. * Strong typing of a Mesh Render related stage step action
  89606. */
  89607. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89608. /**
  89609. * Strong typing of a simple stage step action
  89610. */
  89611. export type SimpleStageAction = () => void;
  89612. /**
  89613. * Strong typing of a render target action.
  89614. */
  89615. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89616. /**
  89617. * Strong typing of a pointer move action.
  89618. */
  89619. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89620. /**
  89621. * Strong typing of a pointer up/down action.
  89622. */
  89623. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89624. /**
  89625. * Representation of a stage in the scene (Basically a list of ordered steps)
  89626. * @hidden
  89627. */
  89628. export class Stage<T extends Function> extends Array<{
  89629. index: number;
  89630. component: ISceneComponent;
  89631. action: T;
  89632. }> {
  89633. /**
  89634. * Hide ctor from the rest of the world.
  89635. * @param items The items to add.
  89636. */
  89637. private constructor();
  89638. /**
  89639. * Creates a new Stage.
  89640. * @returns A new instance of a Stage
  89641. */
  89642. static Create<T extends Function>(): Stage<T>;
  89643. /**
  89644. * Registers a step in an ordered way in the targeted stage.
  89645. * @param index Defines the position to register the step in
  89646. * @param component Defines the component attached to the step
  89647. * @param action Defines the action to launch during the step
  89648. */
  89649. registerStep(index: number, component: ISceneComponent, action: T): void;
  89650. /**
  89651. * Clears all the steps from the stage.
  89652. */
  89653. clear(): void;
  89654. }
  89655. }
  89656. declare module BABYLON {
  89657. interface Scene {
  89658. /** @hidden */
  89659. _pointerOverSprite: Nullable<Sprite>;
  89660. /** @hidden */
  89661. _pickedDownSprite: Nullable<Sprite>;
  89662. /** @hidden */
  89663. _tempSpritePickingRay: Nullable<Ray>;
  89664. /**
  89665. * All of the sprite managers added to this scene
  89666. * @see https://doc.babylonjs.com/babylon101/sprites
  89667. */
  89668. spriteManagers: Array<ISpriteManager>;
  89669. /**
  89670. * An event triggered when sprites rendering is about to start
  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. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89674. /**
  89675. * An event triggered when sprites rendering is done
  89676. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89677. */
  89678. onAfterSpritesRenderingObservable: Observable<Scene>;
  89679. /** @hidden */
  89680. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89681. /** Launch a ray to try to pick a sprite in the scene
  89682. * @param x position on screen
  89683. * @param y position on screen
  89684. * @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
  89685. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89686. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89687. * @returns a PickingInfo
  89688. */
  89689. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89690. /** Use the given ray to pick a sprite in the scene
  89691. * @param ray The ray (in world space) to use to pick meshes
  89692. * @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
  89693. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89694. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89695. * @returns a PickingInfo
  89696. */
  89697. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89698. /** @hidden */
  89699. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89700. /** Launch a ray to try to pick sprites in the scene
  89701. * @param x position on screen
  89702. * @param y position on screen
  89703. * @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
  89704. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89705. * @returns a PickingInfo array
  89706. */
  89707. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89708. /** Use the given ray to pick sprites in the scene
  89709. * @param ray The ray (in world space) to use to pick meshes
  89710. * @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
  89711. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89712. * @returns a PickingInfo array
  89713. */
  89714. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89715. /**
  89716. * Force the sprite under the pointer
  89717. * @param sprite defines the sprite to use
  89718. */
  89719. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89720. /**
  89721. * Gets the sprite under the pointer
  89722. * @returns a Sprite or null if no sprite is under the pointer
  89723. */
  89724. getPointerOverSprite(): Nullable<Sprite>;
  89725. }
  89726. /**
  89727. * Defines the sprite scene component responsible to manage sprites
  89728. * in a given scene.
  89729. */
  89730. export class SpriteSceneComponent implements ISceneComponent {
  89731. /**
  89732. * The component name helpfull to identify the component in the list of scene components.
  89733. */
  89734. readonly name: string;
  89735. /**
  89736. * The scene the component belongs to.
  89737. */
  89738. scene: Scene;
  89739. /** @hidden */
  89740. private _spritePredicate;
  89741. /**
  89742. * Creates a new instance of the component for the given scene
  89743. * @param scene Defines the scene to register the component in
  89744. */
  89745. constructor(scene: Scene);
  89746. /**
  89747. * Registers the component in a given scene
  89748. */
  89749. register(): void;
  89750. /**
  89751. * Rebuilds the elements related to this component in case of
  89752. * context lost for instance.
  89753. */
  89754. rebuild(): void;
  89755. /**
  89756. * Disposes the component and the associated ressources.
  89757. */
  89758. dispose(): void;
  89759. private _pickSpriteButKeepRay;
  89760. private _pointerMove;
  89761. private _pointerDown;
  89762. private _pointerUp;
  89763. }
  89764. }
  89765. declare module BABYLON {
  89766. /** @hidden */
  89767. export var fogFragmentDeclaration: {
  89768. name: string;
  89769. shader: string;
  89770. };
  89771. }
  89772. declare module BABYLON {
  89773. /** @hidden */
  89774. export var fogFragment: {
  89775. name: string;
  89776. shader: string;
  89777. };
  89778. }
  89779. declare module BABYLON {
  89780. /** @hidden */
  89781. export var spritesPixelShader: {
  89782. name: string;
  89783. shader: string;
  89784. };
  89785. }
  89786. declare module BABYLON {
  89787. /** @hidden */
  89788. export var fogVertexDeclaration: {
  89789. name: string;
  89790. shader: string;
  89791. };
  89792. }
  89793. declare module BABYLON {
  89794. /** @hidden */
  89795. export var spritesVertexShader: {
  89796. name: string;
  89797. shader: string;
  89798. };
  89799. }
  89800. declare module BABYLON {
  89801. /**
  89802. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89803. */
  89804. export interface ISpriteManager extends IDisposable {
  89805. /**
  89806. * Gets manager's name
  89807. */
  89808. name: string;
  89809. /**
  89810. * Restricts the camera to viewing objects with the same layerMask.
  89811. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89812. */
  89813. layerMask: number;
  89814. /**
  89815. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89816. */
  89817. isPickable: boolean;
  89818. /**
  89819. * Gets the hosting scene
  89820. */
  89821. scene: Scene;
  89822. /**
  89823. * Specifies the rendering group id for this mesh (0 by default)
  89824. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89825. */
  89826. renderingGroupId: number;
  89827. /**
  89828. * Defines the list of sprites managed by the manager.
  89829. */
  89830. sprites: Array<Sprite>;
  89831. /**
  89832. * Gets or sets the spritesheet texture
  89833. */
  89834. texture: Texture;
  89835. /** Defines the default width of a cell in the spritesheet */
  89836. cellWidth: number;
  89837. /** Defines the default height of a cell in the spritesheet */
  89838. cellHeight: number;
  89839. /**
  89840. * Tests the intersection of a sprite with a specific ray.
  89841. * @param ray The ray we are sending to test the collision
  89842. * @param camera The camera space we are sending rays in
  89843. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89844. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89845. * @returns picking info or null.
  89846. */
  89847. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89848. /**
  89849. * Intersects the sprites with a ray
  89850. * @param ray defines the ray to intersect with
  89851. * @param camera defines the current active camera
  89852. * @param predicate defines a predicate used to select candidate sprites
  89853. * @returns null if no hit or a PickingInfo array
  89854. */
  89855. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89856. /**
  89857. * Renders the list of sprites on screen.
  89858. */
  89859. render(): void;
  89860. }
  89861. /**
  89862. * Class used to manage multiple sprites on the same spritesheet
  89863. * @see https://doc.babylonjs.com/babylon101/sprites
  89864. */
  89865. export class SpriteManager implements ISpriteManager {
  89866. /** defines the manager's name */
  89867. name: string;
  89868. /** Define the Url to load snippets */
  89869. static SnippetUrl: string;
  89870. /** Snippet ID if the manager was created from the snippet server */
  89871. snippetId: string;
  89872. /** Gets the list of sprites */
  89873. sprites: Sprite[];
  89874. /** Gets or sets the rendering group id (0 by default) */
  89875. renderingGroupId: number;
  89876. /** Gets or sets camera layer mask */
  89877. layerMask: number;
  89878. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89879. fogEnabled: boolean;
  89880. /** Gets or sets a boolean indicating if the sprites are pickable */
  89881. isPickable: boolean;
  89882. /** Defines the default width of a cell in the spritesheet */
  89883. cellWidth: number;
  89884. /** Defines the default height of a cell in the spritesheet */
  89885. cellHeight: number;
  89886. /** Associative array from JSON sprite data file */
  89887. private _cellData;
  89888. /** Array of sprite names from JSON sprite data file */
  89889. private _spriteMap;
  89890. /** True when packed cell data from JSON file is ready*/
  89891. private _packedAndReady;
  89892. private _textureContent;
  89893. /**
  89894. * An event triggered when the manager is disposed.
  89895. */
  89896. onDisposeObservable: Observable<SpriteManager>;
  89897. private _onDisposeObserver;
  89898. /**
  89899. * Callback called when the manager is disposed
  89900. */
  89901. set onDispose(callback: () => void);
  89902. private _capacity;
  89903. private _fromPacked;
  89904. private _spriteTexture;
  89905. private _epsilon;
  89906. private _scene;
  89907. private _vertexData;
  89908. private _buffer;
  89909. private _vertexBuffers;
  89910. private _indexBuffer;
  89911. private _effectBase;
  89912. private _effectFog;
  89913. /**
  89914. * Gets or sets the unique id of the sprite
  89915. */
  89916. uniqueId: number;
  89917. /**
  89918. * Gets the array of sprites
  89919. */
  89920. get children(): Sprite[];
  89921. /**
  89922. * Gets the hosting scene
  89923. */
  89924. get scene(): Scene;
  89925. /**
  89926. * Gets the capacity of the manager
  89927. */
  89928. get capacity(): number;
  89929. /**
  89930. * Gets or sets the spritesheet texture
  89931. */
  89932. get texture(): Texture;
  89933. set texture(value: Texture);
  89934. private _blendMode;
  89935. /**
  89936. * Blend mode use to render the particle, it can be any of
  89937. * the static Constants.ALPHA_x properties provided in this class.
  89938. * Default value is Constants.ALPHA_COMBINE
  89939. */
  89940. get blendMode(): number;
  89941. set blendMode(blendMode: number);
  89942. /** Disables writing to the depth buffer when rendering the sprites.
  89943. * It can be handy to disable depth writing when using textures without alpha channel
  89944. * and setting some specific blend modes.
  89945. */
  89946. disableDepthWrite: boolean;
  89947. /**
  89948. * Creates a new sprite manager
  89949. * @param name defines the manager's name
  89950. * @param imgUrl defines the sprite sheet url
  89951. * @param capacity defines the maximum allowed number of sprites
  89952. * @param cellSize defines the size of a sprite cell
  89953. * @param scene defines the hosting scene
  89954. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89955. * @param samplingMode defines the smapling mode to use with spritesheet
  89956. * @param fromPacked set to false; do not alter
  89957. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89958. */
  89959. constructor(
  89960. /** defines the manager's name */
  89961. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89962. /**
  89963. * Returns the string "SpriteManager"
  89964. * @returns "SpriteManager"
  89965. */
  89966. getClassName(): string;
  89967. private _makePacked;
  89968. private _appendSpriteVertex;
  89969. private _checkTextureAlpha;
  89970. /**
  89971. * Intersects the sprites with a ray
  89972. * @param ray defines the ray to intersect with
  89973. * @param camera defines the current active camera
  89974. * @param predicate defines a predicate used to select candidate sprites
  89975. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89976. * @returns null if no hit or a PickingInfo
  89977. */
  89978. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89979. /**
  89980. * Intersects the sprites with a ray
  89981. * @param ray defines the ray to intersect with
  89982. * @param camera defines the current active camera
  89983. * @param predicate defines a predicate used to select candidate sprites
  89984. * @returns null if no hit or a PickingInfo array
  89985. */
  89986. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89987. /**
  89988. * Render all child sprites
  89989. */
  89990. render(): void;
  89991. /**
  89992. * Release associated resources
  89993. */
  89994. dispose(): void;
  89995. /**
  89996. * Serializes the sprite manager to a JSON object
  89997. * @param serializeTexture defines if the texture must be serialized as well
  89998. * @returns the JSON object
  89999. */
  90000. serialize(serializeTexture?: boolean): any;
  90001. /**
  90002. * Parses a JSON object to create a new sprite manager.
  90003. * @param parsedManager The JSON object to parse
  90004. * @param scene The scene to create the sprite managerin
  90005. * @param rootUrl The root url to use to load external dependencies like texture
  90006. * @returns the new sprite manager
  90007. */
  90008. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90009. /**
  90010. * Creates a sprite manager from a snippet saved in a remote file
  90011. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90012. * @param url defines the url to load from
  90013. * @param scene defines the hosting scene
  90014. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90015. * @returns a promise that will resolve to the new sprite manager
  90016. */
  90017. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90018. /**
  90019. * Creates a sprite manager from a snippet saved by the sprite editor
  90020. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90021. * @param scene defines the hosting scene
  90022. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90023. * @returns a promise that will resolve to the new sprite manager
  90024. */
  90025. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90026. }
  90027. }
  90028. declare module BABYLON {
  90029. /** Interface used by value gradients (color, factor, ...) */
  90030. export interface IValueGradient {
  90031. /**
  90032. * Gets or sets the gradient value (between 0 and 1)
  90033. */
  90034. gradient: number;
  90035. }
  90036. /** Class used to store color4 gradient */
  90037. export class ColorGradient implements IValueGradient {
  90038. /**
  90039. * Gets or sets the gradient value (between 0 and 1)
  90040. */
  90041. gradient: number;
  90042. /**
  90043. * Gets or sets first associated color
  90044. */
  90045. color1: Color4;
  90046. /**
  90047. * Gets or sets second associated color
  90048. */
  90049. color2?: Color4 | undefined;
  90050. /**
  90051. * Creates a new color4 gradient
  90052. * @param gradient gets or sets the gradient value (between 0 and 1)
  90053. * @param color1 gets or sets first associated color
  90054. * @param color2 gets or sets first second color
  90055. */
  90056. constructor(
  90057. /**
  90058. * Gets or sets the gradient value (between 0 and 1)
  90059. */
  90060. gradient: number,
  90061. /**
  90062. * Gets or sets first associated color
  90063. */
  90064. color1: Color4,
  90065. /**
  90066. * Gets or sets second associated color
  90067. */
  90068. color2?: Color4 | undefined);
  90069. /**
  90070. * Will get a color picked randomly between color1 and color2.
  90071. * If color2 is undefined then color1 will be used
  90072. * @param result defines the target Color4 to store the result in
  90073. */
  90074. getColorToRef(result: Color4): void;
  90075. }
  90076. /** Class used to store color 3 gradient */
  90077. export class Color3Gradient implements IValueGradient {
  90078. /**
  90079. * Gets or sets the gradient value (between 0 and 1)
  90080. */
  90081. gradient: number;
  90082. /**
  90083. * Gets or sets the associated color
  90084. */
  90085. color: Color3;
  90086. /**
  90087. * Creates a new color3 gradient
  90088. * @param gradient gets or sets the gradient value (between 0 and 1)
  90089. * @param color gets or sets associated color
  90090. */
  90091. constructor(
  90092. /**
  90093. * Gets or sets the gradient value (between 0 and 1)
  90094. */
  90095. gradient: number,
  90096. /**
  90097. * Gets or sets the associated color
  90098. */
  90099. color: Color3);
  90100. }
  90101. /** Class used to store factor gradient */
  90102. export class FactorGradient implements IValueGradient {
  90103. /**
  90104. * Gets or sets the gradient value (between 0 and 1)
  90105. */
  90106. gradient: number;
  90107. /**
  90108. * Gets or sets first associated factor
  90109. */
  90110. factor1: number;
  90111. /**
  90112. * Gets or sets second associated factor
  90113. */
  90114. factor2?: number | undefined;
  90115. /**
  90116. * Creates a new factor gradient
  90117. * @param gradient gets or sets the gradient value (between 0 and 1)
  90118. * @param factor1 gets or sets first associated factor
  90119. * @param factor2 gets or sets second associated factor
  90120. */
  90121. constructor(
  90122. /**
  90123. * Gets or sets the gradient value (between 0 and 1)
  90124. */
  90125. gradient: number,
  90126. /**
  90127. * Gets or sets first associated factor
  90128. */
  90129. factor1: number,
  90130. /**
  90131. * Gets or sets second associated factor
  90132. */
  90133. factor2?: number | undefined);
  90134. /**
  90135. * Will get a number picked randomly between factor1 and factor2.
  90136. * If factor2 is undefined then factor1 will be used
  90137. * @returns the picked number
  90138. */
  90139. getFactor(): number;
  90140. }
  90141. /**
  90142. * Helper used to simplify some generic gradient tasks
  90143. */
  90144. export class GradientHelper {
  90145. /**
  90146. * Gets the current gradient from an array of IValueGradient
  90147. * @param ratio defines the current ratio to get
  90148. * @param gradients defines the array of IValueGradient
  90149. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90150. */
  90151. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90152. }
  90153. }
  90154. declare module BABYLON {
  90155. interface ThinEngine {
  90156. /**
  90157. * Creates a raw texture
  90158. * @param data defines the data to store in the texture
  90159. * @param width defines the width of the texture
  90160. * @param height defines the height of the texture
  90161. * @param format defines the format of the data
  90162. * @param generateMipMaps defines if the engine should generate the mip levels
  90163. * @param invertY defines if data must be stored with Y axis inverted
  90164. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90165. * @param compression defines the compression used (null by default)
  90166. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90167. * @returns the raw texture inside an InternalTexture
  90168. */
  90169. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90170. /**
  90171. * Update a raw texture
  90172. * @param texture defines the texture to update
  90173. * @param data defines the data to store in the texture
  90174. * @param format defines the format of the data
  90175. * @param invertY defines if data must be stored with Y axis inverted
  90176. */
  90177. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90178. /**
  90179. * Update a raw texture
  90180. * @param texture defines the texture to update
  90181. * @param data defines the data to store in the texture
  90182. * @param format defines the format of the data
  90183. * @param invertY defines if data must be stored with Y axis inverted
  90184. * @param compression defines the compression used (null by default)
  90185. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90186. */
  90187. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  90188. /**
  90189. * Creates a new raw cube texture
  90190. * @param data defines the array of data to use to create each face
  90191. * @param size defines the size of the textures
  90192. * @param format defines the format of the data
  90193. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90194. * @param generateMipMaps defines if the engine should generate the mip levels
  90195. * @param invertY defines if data must be stored with Y axis inverted
  90196. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90197. * @param compression defines the compression used (null by default)
  90198. * @returns the cube texture as an InternalTexture
  90199. */
  90200. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90201. /**
  90202. * Update a raw cube texture
  90203. * @param texture defines the texture to udpdate
  90204. * @param data defines the data to store
  90205. * @param format defines the data format
  90206. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90207. * @param invertY defines if data must be stored with Y axis inverted
  90208. */
  90209. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90210. /**
  90211. * Update a raw cube texture
  90212. * @param texture defines the texture to udpdate
  90213. * @param data defines the data to store
  90214. * @param format defines the data format
  90215. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90216. * @param invertY defines if data must be stored with Y axis inverted
  90217. * @param compression defines the compression used (null by default)
  90218. */
  90219. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90220. /**
  90221. * Update a raw cube texture
  90222. * @param texture defines the texture to udpdate
  90223. * @param data defines the data to store
  90224. * @param format defines the data format
  90225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90226. * @param invertY defines if data must be stored with Y axis inverted
  90227. * @param compression defines the compression used (null by default)
  90228. * @param level defines which level of the texture to update
  90229. */
  90230. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90231. /**
  90232. * Creates a new raw cube texture from a specified url
  90233. * @param url defines the url where the data is located
  90234. * @param scene defines the current scene
  90235. * @param size defines the size of the textures
  90236. * @param format defines the format of the data
  90237. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90238. * @param noMipmap defines if the engine should avoid generating the mip levels
  90239. * @param callback defines a callback used to extract texture data from loaded data
  90240. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90241. * @param onLoad defines a callback called when texture is loaded
  90242. * @param onError defines a callback called if there is an error
  90243. * @returns the cube texture as an InternalTexture
  90244. */
  90245. 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;
  90246. /**
  90247. * Creates a new raw cube texture from a specified url
  90248. * @param url defines the url where the data is located
  90249. * @param scene defines the current scene
  90250. * @param size defines the size of the textures
  90251. * @param format defines the format of the data
  90252. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90253. * @param noMipmap defines if the engine should avoid generating the mip levels
  90254. * @param callback defines a callback used to extract texture data from loaded data
  90255. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90256. * @param onLoad defines a callback called when texture is loaded
  90257. * @param onError defines a callback called if there is an error
  90258. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90259. * @param invertY defines if data must be stored with Y axis inverted
  90260. * @returns the cube texture as an InternalTexture
  90261. */
  90262. 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;
  90263. /**
  90264. * Creates a new raw 3D texture
  90265. * @param data defines the data used to create the texture
  90266. * @param width defines the width of the texture
  90267. * @param height defines the height of the texture
  90268. * @param depth defines the depth of the texture
  90269. * @param format defines the format of the texture
  90270. * @param generateMipMaps defines if the engine must generate mip levels
  90271. * @param invertY defines if data must be stored with Y axis inverted
  90272. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90273. * @param compression defines the compressed used (can be null)
  90274. * @param textureType defines the compressed used (can be null)
  90275. * @returns a new raw 3D texture (stored in an InternalTexture)
  90276. */
  90277. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90278. /**
  90279. * Update a raw 3D texture
  90280. * @param texture defines the texture to update
  90281. * @param data defines the data to store
  90282. * @param format defines the data format
  90283. * @param invertY defines if data must be stored with Y axis inverted
  90284. */
  90285. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90286. /**
  90287. * Update a raw 3D texture
  90288. * @param texture defines the texture to update
  90289. * @param data defines the data to store
  90290. * @param format defines the data format
  90291. * @param invertY defines if data must be stored with Y axis inverted
  90292. * @param compression defines the used compression (can be null)
  90293. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90294. */
  90295. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90296. /**
  90297. * Creates a new raw 2D array texture
  90298. * @param data defines the data used to create the texture
  90299. * @param width defines the width of the texture
  90300. * @param height defines the height of the texture
  90301. * @param depth defines the number of layers of the texture
  90302. * @param format defines the format of the texture
  90303. * @param generateMipMaps defines if the engine must generate mip levels
  90304. * @param invertY defines if data must be stored with Y axis inverted
  90305. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90306. * @param compression defines the compressed used (can be null)
  90307. * @param textureType defines the compressed used (can be null)
  90308. * @returns a new raw 2D array texture (stored in an InternalTexture)
  90309. */
  90310. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90311. /**
  90312. * Update a raw 2D array texture
  90313. * @param texture defines the texture to update
  90314. * @param data defines the data to store
  90315. * @param format defines the data format
  90316. * @param invertY defines if data must be stored with Y axis inverted
  90317. */
  90318. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90319. /**
  90320. * Update a raw 2D array texture
  90321. * @param texture defines the texture to update
  90322. * @param data defines the data to store
  90323. * @param format defines the data format
  90324. * @param invertY defines if data must be stored with Y axis inverted
  90325. * @param compression defines the used compression (can be null)
  90326. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90327. */
  90328. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90329. }
  90330. }
  90331. declare module BABYLON {
  90332. /**
  90333. * Raw texture can help creating a texture directly from an array of data.
  90334. * This can be super useful if you either get the data from an uncompressed source or
  90335. * if you wish to create your texture pixel by pixel.
  90336. */
  90337. export class RawTexture extends Texture {
  90338. /**
  90339. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90340. */
  90341. format: number;
  90342. /**
  90343. * Instantiates a new RawTexture.
  90344. * Raw texture can help creating a texture directly from an array of data.
  90345. * This can be super useful if you either get the data from an uncompressed source or
  90346. * if you wish to create your texture pixel by pixel.
  90347. * @param data define the array of data to use to create the texture
  90348. * @param width define the width of the texture
  90349. * @param height define the height of the texture
  90350. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90351. * @param scene define the scene the texture belongs to
  90352. * @param generateMipMaps define whether mip maps should be generated or not
  90353. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90354. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90355. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90356. */
  90357. constructor(data: ArrayBufferView, width: number, height: number,
  90358. /**
  90359. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90360. */
  90361. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90362. /**
  90363. * Updates the texture underlying data.
  90364. * @param data Define the new data of the texture
  90365. */
  90366. update(data: ArrayBufferView): void;
  90367. /**
  90368. * Creates a luminance texture from some data.
  90369. * @param data Define the texture data
  90370. * @param width Define the width of the texture
  90371. * @param height Define the height of the texture
  90372. * @param scene Define the scene the texture belongs to
  90373. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90374. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90375. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90376. * @returns the luminance texture
  90377. */
  90378. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90379. /**
  90380. * Creates a luminance alpha texture from some data.
  90381. * @param data Define the texture data
  90382. * @param width Define the width of the texture
  90383. * @param height Define the height of the texture
  90384. * @param scene Define the scene the texture belongs to
  90385. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90386. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90387. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90388. * @returns the luminance alpha texture
  90389. */
  90390. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90391. /**
  90392. * Creates an alpha texture from some data.
  90393. * @param data Define the texture data
  90394. * @param width Define the width of the texture
  90395. * @param height Define the height of the texture
  90396. * @param scene Define the scene the texture belongs to
  90397. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90398. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90399. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90400. * @returns the alpha texture
  90401. */
  90402. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90403. /**
  90404. * Creates a RGB texture from some data.
  90405. * @param data Define the texture data
  90406. * @param width Define the width of the texture
  90407. * @param height Define the height of the texture
  90408. * @param scene Define the scene the texture belongs to
  90409. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90410. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90411. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90412. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90413. * @returns the RGB alpha texture
  90414. */
  90415. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90416. /**
  90417. * Creates a RGBA texture from some data.
  90418. * @param data Define the texture data
  90419. * @param width Define the width of the texture
  90420. * @param height Define the height of the texture
  90421. * @param scene Define the scene the texture belongs to
  90422. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90423. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90424. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90425. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90426. * @returns the RGBA texture
  90427. */
  90428. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90429. /**
  90430. * Creates a R texture from some data.
  90431. * @param data Define the texture data
  90432. * @param width Define the width of the texture
  90433. * @param height Define the height of the texture
  90434. * @param scene Define the scene the texture belongs to
  90435. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90436. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90437. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90438. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90439. * @returns the R texture
  90440. */
  90441. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90442. }
  90443. }
  90444. declare module BABYLON {
  90445. interface AbstractScene {
  90446. /**
  90447. * The list of procedural textures added to the scene
  90448. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90449. */
  90450. proceduralTextures: Array<ProceduralTexture>;
  90451. }
  90452. /**
  90453. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90454. * in a given scene.
  90455. */
  90456. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90457. /**
  90458. * The component name helpfull to identify the component in the list of scene components.
  90459. */
  90460. readonly name: string;
  90461. /**
  90462. * The scene the component belongs to.
  90463. */
  90464. scene: Scene;
  90465. /**
  90466. * Creates a new instance of the component for the given scene
  90467. * @param scene Defines the scene to register the component in
  90468. */
  90469. constructor(scene: Scene);
  90470. /**
  90471. * Registers the component in a given scene
  90472. */
  90473. register(): void;
  90474. /**
  90475. * Rebuilds the elements related to this component in case of
  90476. * context lost for instance.
  90477. */
  90478. rebuild(): void;
  90479. /**
  90480. * Disposes the component and the associated ressources.
  90481. */
  90482. dispose(): void;
  90483. private _beforeClear;
  90484. }
  90485. }
  90486. declare module BABYLON {
  90487. interface ThinEngine {
  90488. /**
  90489. * Creates a new render target cube texture
  90490. * @param size defines the size of the texture
  90491. * @param options defines the options used to create the texture
  90492. * @returns a new render target cube texture stored in an InternalTexture
  90493. */
  90494. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90495. }
  90496. }
  90497. declare module BABYLON {
  90498. /** @hidden */
  90499. export var proceduralVertexShader: {
  90500. name: string;
  90501. shader: string;
  90502. };
  90503. }
  90504. declare module BABYLON {
  90505. /**
  90506. * 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.
  90507. * This is the base class of any Procedural texture and contains most of the shareable code.
  90508. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90509. */
  90510. export class ProceduralTexture extends Texture {
  90511. isCube: boolean;
  90512. /**
  90513. * Define if the texture is enabled or not (disabled texture will not render)
  90514. */
  90515. isEnabled: boolean;
  90516. /**
  90517. * Define if the texture must be cleared before rendering (default is true)
  90518. */
  90519. autoClear: boolean;
  90520. /**
  90521. * Callback called when the texture is generated
  90522. */
  90523. onGenerated: () => void;
  90524. /**
  90525. * Event raised when the texture is generated
  90526. */
  90527. onGeneratedObservable: Observable<ProceduralTexture>;
  90528. /** @hidden */
  90529. _generateMipMaps: boolean;
  90530. /** @hidden **/
  90531. _effect: Effect;
  90532. /** @hidden */
  90533. _textures: {
  90534. [key: string]: Texture;
  90535. };
  90536. /** @hidden */
  90537. protected _fallbackTexture: Nullable<Texture>;
  90538. private _size;
  90539. private _currentRefreshId;
  90540. private _frameId;
  90541. private _refreshRate;
  90542. private _vertexBuffers;
  90543. private _indexBuffer;
  90544. private _uniforms;
  90545. private _samplers;
  90546. private _fragment;
  90547. private _floats;
  90548. private _ints;
  90549. private _floatsArrays;
  90550. private _colors3;
  90551. private _colors4;
  90552. private _vectors2;
  90553. private _vectors3;
  90554. private _matrices;
  90555. private _fallbackTextureUsed;
  90556. private _fullEngine;
  90557. private _cachedDefines;
  90558. private _contentUpdateId;
  90559. private _contentData;
  90560. /**
  90561. * Instantiates a new procedural texture.
  90562. * 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.
  90563. * This is the base class of any Procedural texture and contains most of the shareable code.
  90564. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90565. * @param name Define the name of the texture
  90566. * @param size Define the size of the texture to create
  90567. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90568. * @param scene Define the scene the texture belongs to
  90569. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90570. * @param generateMipMaps Define if the texture should creates mip maps or not
  90571. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90572. */
  90573. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90574. /**
  90575. * The effect that is created when initializing the post process.
  90576. * @returns The created effect corresponding the the postprocess.
  90577. */
  90578. getEffect(): Effect;
  90579. /**
  90580. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90581. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90582. */
  90583. getContent(): Nullable<ArrayBufferView>;
  90584. private _createIndexBuffer;
  90585. /** @hidden */
  90586. _rebuild(): void;
  90587. /**
  90588. * Resets the texture in order to recreate its associated resources.
  90589. * This can be called in case of context loss
  90590. */
  90591. reset(): void;
  90592. protected _getDefines(): string;
  90593. /**
  90594. * Is the texture ready to be used ? (rendered at least once)
  90595. * @returns true if ready, otherwise, false.
  90596. */
  90597. isReady(): boolean;
  90598. /**
  90599. * Resets the refresh counter of the texture and start bak from scratch.
  90600. * Could be useful to regenerate the texture if it is setup to render only once.
  90601. */
  90602. resetRefreshCounter(): void;
  90603. /**
  90604. * Set the fragment shader to use in order to render the texture.
  90605. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90606. */
  90607. setFragment(fragment: any): void;
  90608. /**
  90609. * Define the refresh rate of the texture or the rendering frequency.
  90610. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90611. */
  90612. get refreshRate(): number;
  90613. set refreshRate(value: number);
  90614. /** @hidden */
  90615. _shouldRender(): boolean;
  90616. /**
  90617. * Get the size the texture is rendering at.
  90618. * @returns the size (texture is always squared)
  90619. */
  90620. getRenderSize(): number;
  90621. /**
  90622. * Resize the texture to new value.
  90623. * @param size Define the new size the texture should have
  90624. * @param generateMipMaps Define whether the new texture should create mip maps
  90625. */
  90626. resize(size: number, generateMipMaps: boolean): void;
  90627. private _checkUniform;
  90628. /**
  90629. * Set a texture in the shader program used to render.
  90630. * @param name Define the name of the uniform samplers as defined in the shader
  90631. * @param texture Define the texture to bind to this sampler
  90632. * @return the texture itself allowing "fluent" like uniform updates
  90633. */
  90634. setTexture(name: string, texture: Texture): ProceduralTexture;
  90635. /**
  90636. * Set a float in the shader.
  90637. * @param name Define the name of the uniform as defined in the shader
  90638. * @param value Define the value to give to the uniform
  90639. * @return the texture itself allowing "fluent" like uniform updates
  90640. */
  90641. setFloat(name: string, value: number): ProceduralTexture;
  90642. /**
  90643. * Set a int in the shader.
  90644. * @param name Define the name of the uniform as defined in the shader
  90645. * @param value Define the value to give to the uniform
  90646. * @return the texture itself allowing "fluent" like uniform updates
  90647. */
  90648. setInt(name: string, value: number): ProceduralTexture;
  90649. /**
  90650. * Set an array of floats in the shader.
  90651. * @param name Define the name of the uniform as defined in the shader
  90652. * @param value Define the value to give to the uniform
  90653. * @return the texture itself allowing "fluent" like uniform updates
  90654. */
  90655. setFloats(name: string, value: number[]): ProceduralTexture;
  90656. /**
  90657. * Set a vec3 in the shader from a Color3.
  90658. * @param name Define the name of the uniform as defined in the shader
  90659. * @param value Define the value to give to the uniform
  90660. * @return the texture itself allowing "fluent" like uniform updates
  90661. */
  90662. setColor3(name: string, value: Color3): ProceduralTexture;
  90663. /**
  90664. * Set a vec4 in the shader from a Color4.
  90665. * @param name Define the name of the uniform as defined in the shader
  90666. * @param value Define the value to give to the uniform
  90667. * @return the texture itself allowing "fluent" like uniform updates
  90668. */
  90669. setColor4(name: string, value: Color4): ProceduralTexture;
  90670. /**
  90671. * Set a vec2 in the shader from a Vector2.
  90672. * @param name Define the name of the uniform as defined in the shader
  90673. * @param value Define the value to give to the uniform
  90674. * @return the texture itself allowing "fluent" like uniform updates
  90675. */
  90676. setVector2(name: string, value: Vector2): ProceduralTexture;
  90677. /**
  90678. * Set a vec3 in the shader from a Vector3.
  90679. * @param name Define the name of the uniform as defined in the shader
  90680. * @param value Define the value to give to the uniform
  90681. * @return the texture itself allowing "fluent" like uniform updates
  90682. */
  90683. setVector3(name: string, value: Vector3): ProceduralTexture;
  90684. /**
  90685. * Set a mat4 in the shader from a MAtrix.
  90686. * @param name Define the name of the uniform as defined in the shader
  90687. * @param value Define the value to give to the uniform
  90688. * @return the texture itself allowing "fluent" like uniform updates
  90689. */
  90690. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90691. /**
  90692. * Render the texture to its associated render target.
  90693. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90694. */
  90695. render(useCameraPostProcess?: boolean): void;
  90696. /**
  90697. * Clone the texture.
  90698. * @returns the cloned texture
  90699. */
  90700. clone(): ProceduralTexture;
  90701. /**
  90702. * Dispose the texture and release its asoociated resources.
  90703. */
  90704. dispose(): void;
  90705. }
  90706. }
  90707. declare module BABYLON {
  90708. /**
  90709. * This represents the base class for particle system in Babylon.
  90710. * 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.
  90711. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90712. * @example https://doc.babylonjs.com/babylon101/particles
  90713. */
  90714. export class BaseParticleSystem {
  90715. /**
  90716. * Source color is added to the destination color without alpha affecting the result
  90717. */
  90718. static BLENDMODE_ONEONE: number;
  90719. /**
  90720. * Blend current color and particle color using particle’s alpha
  90721. */
  90722. static BLENDMODE_STANDARD: number;
  90723. /**
  90724. * Add current color and particle color multiplied by particle’s alpha
  90725. */
  90726. static BLENDMODE_ADD: number;
  90727. /**
  90728. * Multiply current color with particle color
  90729. */
  90730. static BLENDMODE_MULTIPLY: number;
  90731. /**
  90732. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90733. */
  90734. static BLENDMODE_MULTIPLYADD: number;
  90735. /**
  90736. * List of animations used by the particle system.
  90737. */
  90738. animations: Animation[];
  90739. /**
  90740. * Gets or sets the unique id of the particle system
  90741. */
  90742. uniqueId: number;
  90743. /**
  90744. * The id of the Particle system.
  90745. */
  90746. id: string;
  90747. /**
  90748. * The friendly name of the Particle system.
  90749. */
  90750. name: string;
  90751. /**
  90752. * Snippet ID if the particle system was created from the snippet server
  90753. */
  90754. snippetId: string;
  90755. /**
  90756. * The rendering group used by the Particle system to chose when to render.
  90757. */
  90758. renderingGroupId: number;
  90759. /**
  90760. * The emitter represents the Mesh or position we are attaching the particle system to.
  90761. */
  90762. emitter: Nullable<AbstractMesh | Vector3>;
  90763. /**
  90764. * The maximum number of particles to emit per frame
  90765. */
  90766. emitRate: number;
  90767. /**
  90768. * If you want to launch only a few particles at once, that can be done, as well.
  90769. */
  90770. manualEmitCount: number;
  90771. /**
  90772. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90773. */
  90774. updateSpeed: number;
  90775. /**
  90776. * The amount of time the particle system is running (depends of the overall update speed).
  90777. */
  90778. targetStopDuration: number;
  90779. /**
  90780. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90781. */
  90782. disposeOnStop: boolean;
  90783. /**
  90784. * Minimum power of emitting particles.
  90785. */
  90786. minEmitPower: number;
  90787. /**
  90788. * Maximum power of emitting particles.
  90789. */
  90790. maxEmitPower: number;
  90791. /**
  90792. * Minimum life time of emitting particles.
  90793. */
  90794. minLifeTime: number;
  90795. /**
  90796. * Maximum life time of emitting particles.
  90797. */
  90798. maxLifeTime: number;
  90799. /**
  90800. * Minimum Size of emitting particles.
  90801. */
  90802. minSize: number;
  90803. /**
  90804. * Maximum Size of emitting particles.
  90805. */
  90806. maxSize: number;
  90807. /**
  90808. * Minimum scale of emitting particles on X axis.
  90809. */
  90810. minScaleX: number;
  90811. /**
  90812. * Maximum scale of emitting particles on X axis.
  90813. */
  90814. maxScaleX: number;
  90815. /**
  90816. * Minimum scale of emitting particles on Y axis.
  90817. */
  90818. minScaleY: number;
  90819. /**
  90820. * Maximum scale of emitting particles on Y axis.
  90821. */
  90822. maxScaleY: number;
  90823. /**
  90824. * Gets or sets the minimal initial rotation in radians.
  90825. */
  90826. minInitialRotation: number;
  90827. /**
  90828. * Gets or sets the maximal initial rotation in radians.
  90829. */
  90830. maxInitialRotation: number;
  90831. /**
  90832. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90833. */
  90834. minAngularSpeed: number;
  90835. /**
  90836. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90837. */
  90838. maxAngularSpeed: number;
  90839. /**
  90840. * The texture used to render each particle. (this can be a spritesheet)
  90841. */
  90842. particleTexture: Nullable<Texture>;
  90843. /**
  90844. * The layer mask we are rendering the particles through.
  90845. */
  90846. layerMask: number;
  90847. /**
  90848. * This can help using your own shader to render the particle system.
  90849. * The according effect will be created
  90850. */
  90851. customShader: any;
  90852. /**
  90853. * By default particle system starts as soon as they are created. This prevents the
  90854. * automatic start to happen and let you decide when to start emitting particles.
  90855. */
  90856. preventAutoStart: boolean;
  90857. private _noiseTexture;
  90858. /**
  90859. * Gets or sets a texture used to add random noise to particle positions
  90860. */
  90861. get noiseTexture(): Nullable<ProceduralTexture>;
  90862. set noiseTexture(value: Nullable<ProceduralTexture>);
  90863. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90864. noiseStrength: Vector3;
  90865. /**
  90866. * Callback triggered when the particle animation is ending.
  90867. */
  90868. onAnimationEnd: Nullable<() => void>;
  90869. /**
  90870. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90871. */
  90872. blendMode: number;
  90873. /**
  90874. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90875. * to override the particles.
  90876. */
  90877. forceDepthWrite: boolean;
  90878. /** 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 */
  90879. preWarmCycles: number;
  90880. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90881. preWarmStepOffset: number;
  90882. /**
  90883. * 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)
  90884. */
  90885. spriteCellChangeSpeed: number;
  90886. /**
  90887. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90888. */
  90889. startSpriteCellID: number;
  90890. /**
  90891. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90892. */
  90893. endSpriteCellID: number;
  90894. /**
  90895. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90896. */
  90897. spriteCellWidth: number;
  90898. /**
  90899. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90900. */
  90901. spriteCellHeight: number;
  90902. /**
  90903. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90904. */
  90905. spriteRandomStartCell: boolean;
  90906. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90907. translationPivot: Vector2;
  90908. /** @hidden */
  90909. protected _isAnimationSheetEnabled: boolean;
  90910. /**
  90911. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90912. */
  90913. beginAnimationOnStart: boolean;
  90914. /**
  90915. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90916. */
  90917. beginAnimationFrom: number;
  90918. /**
  90919. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90920. */
  90921. beginAnimationTo: number;
  90922. /**
  90923. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90924. */
  90925. beginAnimationLoop: boolean;
  90926. /**
  90927. * Gets or sets a world offset applied to all particles
  90928. */
  90929. worldOffset: Vector3;
  90930. /**
  90931. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90932. */
  90933. get isAnimationSheetEnabled(): boolean;
  90934. set isAnimationSheetEnabled(value: boolean);
  90935. /**
  90936. * Get hosting scene
  90937. * @returns the scene
  90938. */
  90939. getScene(): Scene;
  90940. /**
  90941. * You can use gravity if you want to give an orientation to your particles.
  90942. */
  90943. gravity: Vector3;
  90944. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90945. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90946. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90947. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90948. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90949. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90950. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90951. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90952. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90953. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90954. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90955. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90956. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90957. /**
  90958. * Defines the delay in milliseconds before starting the system (0 by default)
  90959. */
  90960. startDelay: number;
  90961. /**
  90962. * Gets the current list of drag gradients.
  90963. * You must use addDragGradient and removeDragGradient to udpate this list
  90964. * @returns the list of drag gradients
  90965. */
  90966. getDragGradients(): Nullable<Array<FactorGradient>>;
  90967. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90968. limitVelocityDamping: number;
  90969. /**
  90970. * Gets the current list of limit velocity gradients.
  90971. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90972. * @returns the list of limit velocity gradients
  90973. */
  90974. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90975. /**
  90976. * Gets the current list of color gradients.
  90977. * You must use addColorGradient and removeColorGradient to udpate this list
  90978. * @returns the list of color gradients
  90979. */
  90980. getColorGradients(): Nullable<Array<ColorGradient>>;
  90981. /**
  90982. * Gets the current list of size gradients.
  90983. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90984. * @returns the list of size gradients
  90985. */
  90986. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90987. /**
  90988. * Gets the current list of color remap gradients.
  90989. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90990. * @returns the list of color remap gradients
  90991. */
  90992. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90993. /**
  90994. * Gets the current list of alpha remap gradients.
  90995. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90996. * @returns the list of alpha remap gradients
  90997. */
  90998. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90999. /**
  91000. * Gets the current list of life time gradients.
  91001. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91002. * @returns the list of life time gradients
  91003. */
  91004. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91005. /**
  91006. * Gets the current list of angular speed gradients.
  91007. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91008. * @returns the list of angular speed gradients
  91009. */
  91010. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91011. /**
  91012. * Gets the current list of velocity gradients.
  91013. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91014. * @returns the list of velocity gradients
  91015. */
  91016. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91017. /**
  91018. * Gets the current list of start size gradients.
  91019. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91020. * @returns the list of start size gradients
  91021. */
  91022. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91023. /**
  91024. * Gets the current list of emit rate gradients.
  91025. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91026. * @returns the list of emit rate gradients
  91027. */
  91028. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91029. /**
  91030. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91031. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91032. */
  91033. get direction1(): Vector3;
  91034. set direction1(value: Vector3);
  91035. /**
  91036. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91037. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91038. */
  91039. get direction2(): Vector3;
  91040. set direction2(value: Vector3);
  91041. /**
  91042. * 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.
  91043. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91044. */
  91045. get minEmitBox(): Vector3;
  91046. set minEmitBox(value: Vector3);
  91047. /**
  91048. * 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.
  91049. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91050. */
  91051. get maxEmitBox(): Vector3;
  91052. set maxEmitBox(value: Vector3);
  91053. /**
  91054. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91055. */
  91056. color1: Color4;
  91057. /**
  91058. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91059. */
  91060. color2: Color4;
  91061. /**
  91062. * Color the particle will have at the end of its lifetime
  91063. */
  91064. colorDead: Color4;
  91065. /**
  91066. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91067. */
  91068. textureMask: Color4;
  91069. /**
  91070. * The particle emitter type defines the emitter used by the particle system.
  91071. * It can be for example box, sphere, or cone...
  91072. */
  91073. particleEmitterType: IParticleEmitterType;
  91074. /** @hidden */
  91075. _isSubEmitter: boolean;
  91076. /**
  91077. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91078. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91079. */
  91080. billboardMode: number;
  91081. protected _isBillboardBased: boolean;
  91082. /**
  91083. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91084. */
  91085. get isBillboardBased(): boolean;
  91086. set isBillboardBased(value: boolean);
  91087. /**
  91088. * The scene the particle system belongs to.
  91089. */
  91090. protected _scene: Scene;
  91091. /**
  91092. * Local cache of defines for image processing.
  91093. */
  91094. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91095. /**
  91096. * Default configuration related to image processing available in the standard Material.
  91097. */
  91098. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91099. /**
  91100. * Gets the image processing configuration used either in this material.
  91101. */
  91102. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  91103. /**
  91104. * Sets the Default image processing configuration used either in the this material.
  91105. *
  91106. * If sets to null, the scene one is in use.
  91107. */
  91108. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  91109. /**
  91110. * Attaches a new image processing configuration to the Standard Material.
  91111. * @param configuration
  91112. */
  91113. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91114. /** @hidden */
  91115. protected _reset(): void;
  91116. /** @hidden */
  91117. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91118. /**
  91119. * Instantiates a particle system.
  91120. * 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.
  91121. * @param name The name of the particle system
  91122. */
  91123. constructor(name: string);
  91124. /**
  91125. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91126. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91127. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91128. * @returns the emitter
  91129. */
  91130. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91131. /**
  91132. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91133. * @param radius The radius of the hemisphere to emit from
  91134. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91135. * @returns the emitter
  91136. */
  91137. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91138. /**
  91139. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91140. * @param radius The radius of the sphere to emit from
  91141. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91142. * @returns the emitter
  91143. */
  91144. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91145. /**
  91146. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91147. * @param radius The radius of the sphere to emit from
  91148. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91149. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91150. * @returns the emitter
  91151. */
  91152. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91153. /**
  91154. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91155. * @param radius The radius of the emission cylinder
  91156. * @param height The height of the emission cylinder
  91157. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91158. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91159. * @returns the emitter
  91160. */
  91161. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91162. /**
  91163. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91164. * @param radius The radius of the cylinder to emit from
  91165. * @param height The height of the emission cylinder
  91166. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91167. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91168. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91169. * @returns the emitter
  91170. */
  91171. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  91172. /**
  91173. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91174. * @param radius The radius of the cone to emit from
  91175. * @param angle The base angle of the cone
  91176. * @returns the emitter
  91177. */
  91178. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  91179. /**
  91180. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91181. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91182. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91183. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91184. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91185. * @returns the emitter
  91186. */
  91187. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91188. }
  91189. }
  91190. declare module BABYLON {
  91191. /**
  91192. * Type of sub emitter
  91193. */
  91194. export enum SubEmitterType {
  91195. /**
  91196. * Attached to the particle over it's lifetime
  91197. */
  91198. ATTACHED = 0,
  91199. /**
  91200. * Created when the particle dies
  91201. */
  91202. END = 1
  91203. }
  91204. /**
  91205. * Sub emitter class used to emit particles from an existing particle
  91206. */
  91207. export class SubEmitter {
  91208. /**
  91209. * the particle system to be used by the sub emitter
  91210. */
  91211. particleSystem: ParticleSystem;
  91212. /**
  91213. * Type of the submitter (Default: END)
  91214. */
  91215. type: SubEmitterType;
  91216. /**
  91217. * 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)
  91218. * Note: This only is supported when using an emitter of type Mesh
  91219. */
  91220. inheritDirection: boolean;
  91221. /**
  91222. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  91223. */
  91224. inheritedVelocityAmount: number;
  91225. /**
  91226. * Creates a sub emitter
  91227. * @param particleSystem the particle system to be used by the sub emitter
  91228. */
  91229. constructor(
  91230. /**
  91231. * the particle system to be used by the sub emitter
  91232. */
  91233. particleSystem: ParticleSystem);
  91234. /**
  91235. * Clones the sub emitter
  91236. * @returns the cloned sub emitter
  91237. */
  91238. clone(): SubEmitter;
  91239. /**
  91240. * Serialize current object to a JSON object
  91241. * @returns the serialized object
  91242. */
  91243. serialize(): any;
  91244. /** @hidden */
  91245. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  91246. /**
  91247. * Creates a new SubEmitter from a serialized JSON version
  91248. * @param serializationObject defines the JSON object to read from
  91249. * @param scene defines the hosting scene
  91250. * @param rootUrl defines the rootUrl for data loading
  91251. * @returns a new SubEmitter
  91252. */
  91253. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  91254. /** Release associated resources */
  91255. dispose(): void;
  91256. }
  91257. }
  91258. declare module BABYLON {
  91259. /** @hidden */
  91260. export var imageProcessingDeclaration: {
  91261. name: string;
  91262. shader: string;
  91263. };
  91264. }
  91265. declare module BABYLON {
  91266. /** @hidden */
  91267. export var imageProcessingFunctions: {
  91268. name: string;
  91269. shader: string;
  91270. };
  91271. }
  91272. declare module BABYLON {
  91273. /** @hidden */
  91274. export var particlesPixelShader: {
  91275. name: string;
  91276. shader: string;
  91277. };
  91278. }
  91279. declare module BABYLON {
  91280. /** @hidden */
  91281. export var particlesVertexShader: {
  91282. name: string;
  91283. shader: string;
  91284. };
  91285. }
  91286. declare module BABYLON {
  91287. /**
  91288. * This represents a particle system in Babylon.
  91289. * 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.
  91290. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91291. * @example https://doc.babylonjs.com/babylon101/particles
  91292. */
  91293. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  91294. /**
  91295. * Billboard mode will only apply to Y axis
  91296. */
  91297. static readonly BILLBOARDMODE_Y: number;
  91298. /**
  91299. * Billboard mode will apply to all axes
  91300. */
  91301. static readonly BILLBOARDMODE_ALL: number;
  91302. /**
  91303. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  91304. */
  91305. static readonly BILLBOARDMODE_STRETCHED: number;
  91306. /**
  91307. * This function can be defined to provide custom update for active particles.
  91308. * This function will be called instead of regular update (age, position, color, etc.).
  91309. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  91310. */
  91311. updateFunction: (particles: Particle[]) => void;
  91312. private _emitterWorldMatrix;
  91313. /**
  91314. * This function can be defined to specify initial direction for every new particle.
  91315. * It by default use the emitterType defined function
  91316. */
  91317. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91318. /**
  91319. * This function can be defined to specify initial position for every new particle.
  91320. * It by default use the emitterType defined function
  91321. */
  91322. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91323. /**
  91324. * @hidden
  91325. */
  91326. _inheritedVelocityOffset: Vector3;
  91327. /**
  91328. * An event triggered when the system is disposed
  91329. */
  91330. onDisposeObservable: Observable<IParticleSystem>;
  91331. private _onDisposeObserver;
  91332. /**
  91333. * Sets a callback that will be triggered when the system is disposed
  91334. */
  91335. set onDispose(callback: () => void);
  91336. private _particles;
  91337. private _epsilon;
  91338. private _capacity;
  91339. private _stockParticles;
  91340. private _newPartsExcess;
  91341. private _vertexData;
  91342. private _vertexBuffer;
  91343. private _vertexBuffers;
  91344. private _spriteBuffer;
  91345. private _indexBuffer;
  91346. private _effect;
  91347. private _customEffect;
  91348. private _cachedDefines;
  91349. private _scaledColorStep;
  91350. private _colorDiff;
  91351. private _scaledDirection;
  91352. private _scaledGravity;
  91353. private _currentRenderId;
  91354. private _alive;
  91355. private _useInstancing;
  91356. private _started;
  91357. private _stopped;
  91358. private _actualFrame;
  91359. private _scaledUpdateSpeed;
  91360. private _vertexBufferSize;
  91361. /** @hidden */
  91362. _currentEmitRateGradient: Nullable<FactorGradient>;
  91363. /** @hidden */
  91364. _currentEmitRate1: number;
  91365. /** @hidden */
  91366. _currentEmitRate2: number;
  91367. /** @hidden */
  91368. _currentStartSizeGradient: Nullable<FactorGradient>;
  91369. /** @hidden */
  91370. _currentStartSize1: number;
  91371. /** @hidden */
  91372. _currentStartSize2: number;
  91373. private readonly _rawTextureWidth;
  91374. private _rampGradientsTexture;
  91375. private _useRampGradients;
  91376. /** Gets or sets a boolean indicating that ramp gradients must be used
  91377. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91378. */
  91379. get useRampGradients(): boolean;
  91380. set useRampGradients(value: boolean);
  91381. /**
  91382. * 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.
  91383. * 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: [])
  91384. */
  91385. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91386. private _subEmitters;
  91387. /**
  91388. * @hidden
  91389. * If the particle systems emitter should be disposed when the particle system is disposed
  91390. */
  91391. _disposeEmitterOnDispose: boolean;
  91392. /**
  91393. * The current active Sub-systems, this property is used by the root particle system only.
  91394. */
  91395. activeSubSystems: Array<ParticleSystem>;
  91396. /**
  91397. * Specifies if the particles are updated in emitter local space or world space
  91398. */
  91399. isLocal: boolean;
  91400. private _rootParticleSystem;
  91401. /**
  91402. * Gets the current list of active particles
  91403. */
  91404. get particles(): Particle[];
  91405. /**
  91406. * Gets the number of particles active at the same time.
  91407. * @returns The number of active particles.
  91408. */
  91409. getActiveCount(): number;
  91410. /**
  91411. * Returns the string "ParticleSystem"
  91412. * @returns a string containing the class name
  91413. */
  91414. getClassName(): string;
  91415. /**
  91416. * Gets a boolean indicating that the system is stopping
  91417. * @returns true if the system is currently stopping
  91418. */
  91419. isStopping(): boolean;
  91420. /**
  91421. * Gets the custom effect used to render the particles
  91422. * @param blendMode Blend mode for which the effect should be retrieved
  91423. * @returns The effect
  91424. */
  91425. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91426. /**
  91427. * Sets the custom effect used to render the particles
  91428. * @param effect The effect to set
  91429. * @param blendMode Blend mode for which the effect should be set
  91430. */
  91431. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91432. /** @hidden */
  91433. private _onBeforeDrawParticlesObservable;
  91434. /**
  91435. * Observable that will be called just before the particles are drawn
  91436. */
  91437. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91438. /**
  91439. * Gets the name of the particle vertex shader
  91440. */
  91441. get vertexShaderName(): string;
  91442. /**
  91443. * Instantiates a particle system.
  91444. * 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.
  91445. * @param name The name of the particle system
  91446. * @param capacity The max number of particles alive at the same time
  91447. * @param scene The scene the particle system belongs to
  91448. * @param customEffect a custom effect used to change the way particles are rendered by default
  91449. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91450. * @param epsilon Offset used to render the particles
  91451. */
  91452. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91453. private _addFactorGradient;
  91454. private _removeFactorGradient;
  91455. /**
  91456. * Adds a new life time gradient
  91457. * @param gradient defines the gradient to use (between 0 and 1)
  91458. * @param factor defines the life time factor to affect to the specified gradient
  91459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91460. * @returns the current particle system
  91461. */
  91462. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91463. /**
  91464. * Remove a specific life time gradient
  91465. * @param gradient defines the gradient to remove
  91466. * @returns the current particle system
  91467. */
  91468. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91469. /**
  91470. * Adds a new size gradient
  91471. * @param gradient defines the gradient to use (between 0 and 1)
  91472. * @param factor defines the size factor to affect to the specified gradient
  91473. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91474. * @returns the current particle system
  91475. */
  91476. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91477. /**
  91478. * Remove a specific size gradient
  91479. * @param gradient defines the gradient to remove
  91480. * @returns the current particle system
  91481. */
  91482. removeSizeGradient(gradient: number): IParticleSystem;
  91483. /**
  91484. * Adds a new color remap gradient
  91485. * @param gradient defines the gradient to use (between 0 and 1)
  91486. * @param min defines the color remap minimal range
  91487. * @param max defines the color remap maximal range
  91488. * @returns the current particle system
  91489. */
  91490. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91491. /**
  91492. * Remove a specific color remap gradient
  91493. * @param gradient defines the gradient to remove
  91494. * @returns the current particle system
  91495. */
  91496. removeColorRemapGradient(gradient: number): IParticleSystem;
  91497. /**
  91498. * Adds a new alpha remap gradient
  91499. * @param gradient defines the gradient to use (between 0 and 1)
  91500. * @param min defines the alpha remap minimal range
  91501. * @param max defines the alpha remap maximal range
  91502. * @returns the current particle system
  91503. */
  91504. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91505. /**
  91506. * Remove a specific alpha remap gradient
  91507. * @param gradient defines the gradient to remove
  91508. * @returns the current particle system
  91509. */
  91510. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  91511. /**
  91512. * Adds a new angular speed gradient
  91513. * @param gradient defines the gradient to use (between 0 and 1)
  91514. * @param factor defines the angular speed to affect to the specified gradient
  91515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91516. * @returns the current particle system
  91517. */
  91518. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91519. /**
  91520. * Remove a specific angular speed gradient
  91521. * @param gradient defines the gradient to remove
  91522. * @returns the current particle system
  91523. */
  91524. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91525. /**
  91526. * Adds a new velocity gradient
  91527. * @param gradient defines the gradient to use (between 0 and 1)
  91528. * @param factor defines the velocity to affect to the specified gradient
  91529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91530. * @returns the current particle system
  91531. */
  91532. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91533. /**
  91534. * Remove a specific velocity gradient
  91535. * @param gradient defines the gradient to remove
  91536. * @returns the current particle system
  91537. */
  91538. removeVelocityGradient(gradient: number): IParticleSystem;
  91539. /**
  91540. * Adds a new limit velocity gradient
  91541. * @param gradient defines the gradient to use (between 0 and 1)
  91542. * @param factor defines the limit velocity value to affect to the specified gradient
  91543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91544. * @returns the current particle system
  91545. */
  91546. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91547. /**
  91548. * Remove a specific limit velocity gradient
  91549. * @param gradient defines the gradient to remove
  91550. * @returns the current particle system
  91551. */
  91552. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91553. /**
  91554. * Adds a new drag gradient
  91555. * @param gradient defines the gradient to use (between 0 and 1)
  91556. * @param factor defines the drag value to affect to the specified gradient
  91557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91558. * @returns the current particle system
  91559. */
  91560. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91561. /**
  91562. * Remove a specific drag gradient
  91563. * @param gradient defines the gradient to remove
  91564. * @returns the current particle system
  91565. */
  91566. removeDragGradient(gradient: number): IParticleSystem;
  91567. /**
  91568. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91569. * @param gradient defines the gradient to use (between 0 and 1)
  91570. * @param factor defines the emit rate value to affect to the specified gradient
  91571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91572. * @returns the current particle system
  91573. */
  91574. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91575. /**
  91576. * Remove a specific emit rate gradient
  91577. * @param gradient defines the gradient to remove
  91578. * @returns the current particle system
  91579. */
  91580. removeEmitRateGradient(gradient: number): IParticleSystem;
  91581. /**
  91582. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91583. * @param gradient defines the gradient to use (between 0 and 1)
  91584. * @param factor defines the start size value to affect to the specified gradient
  91585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91586. * @returns the current particle system
  91587. */
  91588. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91589. /**
  91590. * Remove a specific start size gradient
  91591. * @param gradient defines the gradient to remove
  91592. * @returns the current particle system
  91593. */
  91594. removeStartSizeGradient(gradient: number): IParticleSystem;
  91595. private _createRampGradientTexture;
  91596. /**
  91597. * Gets the current list of ramp gradients.
  91598. * You must use addRampGradient and removeRampGradient to udpate this list
  91599. * @returns the list of ramp gradients
  91600. */
  91601. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91602. /** Force the system to rebuild all gradients that need to be resync */
  91603. forceRefreshGradients(): void;
  91604. private _syncRampGradientTexture;
  91605. /**
  91606. * Adds a new ramp gradient used to remap particle colors
  91607. * @param gradient defines the gradient to use (between 0 and 1)
  91608. * @param color defines the color to affect to the specified gradient
  91609. * @returns the current particle system
  91610. */
  91611. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91612. /**
  91613. * Remove a specific ramp gradient
  91614. * @param gradient defines the gradient to remove
  91615. * @returns the current particle system
  91616. */
  91617. removeRampGradient(gradient: number): ParticleSystem;
  91618. /**
  91619. * Adds a new color gradient
  91620. * @param gradient defines the gradient to use (between 0 and 1)
  91621. * @param color1 defines the color to affect to the specified gradient
  91622. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91623. * @returns this particle system
  91624. */
  91625. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91626. /**
  91627. * Remove a specific color gradient
  91628. * @param gradient defines the gradient to remove
  91629. * @returns this particle system
  91630. */
  91631. removeColorGradient(gradient: number): IParticleSystem;
  91632. private _fetchR;
  91633. protected _reset(): void;
  91634. private _resetEffect;
  91635. private _createVertexBuffers;
  91636. private _createIndexBuffer;
  91637. /**
  91638. * Gets the maximum number of particles active at the same time.
  91639. * @returns The max number of active particles.
  91640. */
  91641. getCapacity(): number;
  91642. /**
  91643. * Gets whether there are still active particles in the system.
  91644. * @returns True if it is alive, otherwise false.
  91645. */
  91646. isAlive(): boolean;
  91647. /**
  91648. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91649. * @returns True if it has been started, otherwise false.
  91650. */
  91651. isStarted(): boolean;
  91652. private _prepareSubEmitterInternalArray;
  91653. /**
  91654. * Starts the particle system and begins to emit
  91655. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91656. */
  91657. start(delay?: number): void;
  91658. /**
  91659. * Stops the particle system.
  91660. * @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.
  91661. */
  91662. stop(stopSubEmitters?: boolean): void;
  91663. /**
  91664. * Remove all active particles
  91665. */
  91666. reset(): void;
  91667. /**
  91668. * @hidden (for internal use only)
  91669. */
  91670. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91671. /**
  91672. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91673. * Its lifetime will start back at 0.
  91674. */
  91675. recycleParticle: (particle: Particle) => void;
  91676. private _stopSubEmitters;
  91677. private _createParticle;
  91678. private _removeFromRoot;
  91679. private _emitFromParticle;
  91680. private _update;
  91681. /** @hidden */
  91682. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91683. /** @hidden */
  91684. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91685. /**
  91686. * Fill the defines array according to the current settings of the particle system
  91687. * @param defines Array to be updated
  91688. * @param blendMode blend mode to take into account when updating the array
  91689. */
  91690. fillDefines(defines: Array<string>, blendMode: number): void;
  91691. /**
  91692. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91693. * @param uniforms Uniforms array to fill
  91694. * @param attributes Attributes array to fill
  91695. * @param samplers Samplers array to fill
  91696. */
  91697. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91698. /** @hidden */
  91699. private _getEffect;
  91700. /**
  91701. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91702. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91703. */
  91704. animate(preWarmOnly?: boolean): void;
  91705. private _appendParticleVertices;
  91706. /**
  91707. * Rebuilds the particle system.
  91708. */
  91709. rebuild(): void;
  91710. /**
  91711. * Is this system ready to be used/rendered
  91712. * @return true if the system is ready
  91713. */
  91714. isReady(): boolean;
  91715. private _render;
  91716. /**
  91717. * Renders the particle system in its current state.
  91718. * @returns the current number of particles
  91719. */
  91720. render(): number;
  91721. /**
  91722. * Disposes the particle system and free the associated resources
  91723. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91724. */
  91725. dispose(disposeTexture?: boolean): void;
  91726. /**
  91727. * Clones the particle system.
  91728. * @param name The name of the cloned object
  91729. * @param newEmitter The new emitter to use
  91730. * @returns the cloned particle system
  91731. */
  91732. clone(name: string, newEmitter: any): ParticleSystem;
  91733. /**
  91734. * Serializes the particle system to a JSON object
  91735. * @param serializeTexture defines if the texture must be serialized as well
  91736. * @returns the JSON object
  91737. */
  91738. serialize(serializeTexture?: boolean): any;
  91739. /** @hidden */
  91740. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91741. /** @hidden */
  91742. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91743. /**
  91744. * Parses a JSON object to create a particle system.
  91745. * @param parsedParticleSystem The JSON object to parse
  91746. * @param scene The scene to create the particle system in
  91747. * @param rootUrl The root url to use to load external dependencies like texture
  91748. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91749. * @returns the Parsed particle system
  91750. */
  91751. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91752. }
  91753. }
  91754. declare module BABYLON {
  91755. /**
  91756. * A particle represents one of the element emitted by a particle system.
  91757. * This is mainly define by its coordinates, direction, velocity and age.
  91758. */
  91759. export class Particle {
  91760. /**
  91761. * The particle system the particle belongs to.
  91762. */
  91763. particleSystem: ParticleSystem;
  91764. private static _Count;
  91765. /**
  91766. * Unique ID of the particle
  91767. */
  91768. id: number;
  91769. /**
  91770. * The world position of the particle in the scene.
  91771. */
  91772. position: Vector3;
  91773. /**
  91774. * The world direction of the particle in the scene.
  91775. */
  91776. direction: Vector3;
  91777. /**
  91778. * The color of the particle.
  91779. */
  91780. color: Color4;
  91781. /**
  91782. * The color change of the particle per step.
  91783. */
  91784. colorStep: Color4;
  91785. /**
  91786. * Defines how long will the life of the particle be.
  91787. */
  91788. lifeTime: number;
  91789. /**
  91790. * The current age of the particle.
  91791. */
  91792. age: number;
  91793. /**
  91794. * The current size of the particle.
  91795. */
  91796. size: number;
  91797. /**
  91798. * The current scale of the particle.
  91799. */
  91800. scale: Vector2;
  91801. /**
  91802. * The current angle of the particle.
  91803. */
  91804. angle: number;
  91805. /**
  91806. * Defines how fast is the angle changing.
  91807. */
  91808. angularSpeed: number;
  91809. /**
  91810. * Defines the cell index used by the particle to be rendered from a sprite.
  91811. */
  91812. cellIndex: number;
  91813. /**
  91814. * The information required to support color remapping
  91815. */
  91816. remapData: Vector4;
  91817. /** @hidden */
  91818. _randomCellOffset?: number;
  91819. /** @hidden */
  91820. _initialDirection: Nullable<Vector3>;
  91821. /** @hidden */
  91822. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91823. /** @hidden */
  91824. _initialStartSpriteCellID: number;
  91825. /** @hidden */
  91826. _initialEndSpriteCellID: number;
  91827. /** @hidden */
  91828. _currentColorGradient: Nullable<ColorGradient>;
  91829. /** @hidden */
  91830. _currentColor1: Color4;
  91831. /** @hidden */
  91832. _currentColor2: Color4;
  91833. /** @hidden */
  91834. _currentSizeGradient: Nullable<FactorGradient>;
  91835. /** @hidden */
  91836. _currentSize1: number;
  91837. /** @hidden */
  91838. _currentSize2: number;
  91839. /** @hidden */
  91840. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91841. /** @hidden */
  91842. _currentAngularSpeed1: number;
  91843. /** @hidden */
  91844. _currentAngularSpeed2: number;
  91845. /** @hidden */
  91846. _currentVelocityGradient: Nullable<FactorGradient>;
  91847. /** @hidden */
  91848. _currentVelocity1: number;
  91849. /** @hidden */
  91850. _currentVelocity2: number;
  91851. /** @hidden */
  91852. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91853. /** @hidden */
  91854. _currentLimitVelocity1: number;
  91855. /** @hidden */
  91856. _currentLimitVelocity2: number;
  91857. /** @hidden */
  91858. _currentDragGradient: Nullable<FactorGradient>;
  91859. /** @hidden */
  91860. _currentDrag1: number;
  91861. /** @hidden */
  91862. _currentDrag2: number;
  91863. /** @hidden */
  91864. _randomNoiseCoordinates1: Vector3;
  91865. /** @hidden */
  91866. _randomNoiseCoordinates2: Vector3;
  91867. /** @hidden */
  91868. _localPosition?: Vector3;
  91869. /**
  91870. * Creates a new instance Particle
  91871. * @param particleSystem the particle system the particle belongs to
  91872. */
  91873. constructor(
  91874. /**
  91875. * The particle system the particle belongs to.
  91876. */
  91877. particleSystem: ParticleSystem);
  91878. private updateCellInfoFromSystem;
  91879. /**
  91880. * Defines how the sprite cell index is updated for the particle
  91881. */
  91882. updateCellIndex(): void;
  91883. /** @hidden */
  91884. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91885. /** @hidden */
  91886. _inheritParticleInfoToSubEmitters(): void;
  91887. /** @hidden */
  91888. _reset(): void;
  91889. /**
  91890. * Copy the properties of particle to another one.
  91891. * @param other the particle to copy the information to.
  91892. */
  91893. copyTo(other: Particle): void;
  91894. }
  91895. }
  91896. declare module BABYLON {
  91897. /**
  91898. * Particle emitter represents a volume emitting particles.
  91899. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91900. */
  91901. export interface IParticleEmitterType {
  91902. /**
  91903. * Called by the particle System when the direction is computed for the created particle.
  91904. * @param worldMatrix is the world matrix of the particle system
  91905. * @param directionToUpdate is the direction vector to update with the result
  91906. * @param particle is the particle we are computed the direction for
  91907. * @param isLocal defines if the direction should be set in local space
  91908. */
  91909. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91910. /**
  91911. * Called by the particle System when the position is computed for the created particle.
  91912. * @param worldMatrix is the world matrix of the particle system
  91913. * @param positionToUpdate is the position vector to update with the result
  91914. * @param particle is the particle we are computed the position for
  91915. * @param isLocal defines if the position should be set in local space
  91916. */
  91917. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91918. /**
  91919. * Clones the current emitter and returns a copy of it
  91920. * @returns the new emitter
  91921. */
  91922. clone(): IParticleEmitterType;
  91923. /**
  91924. * Called by the GPUParticleSystem to setup the update shader
  91925. * @param effect defines the update shader
  91926. */
  91927. applyToShader(effect: Effect): void;
  91928. /**
  91929. * Returns a string to use to update the GPU particles update shader
  91930. * @returns the effect defines string
  91931. */
  91932. getEffectDefines(): string;
  91933. /**
  91934. * Returns a string representing the class name
  91935. * @returns a string containing the class name
  91936. */
  91937. getClassName(): string;
  91938. /**
  91939. * Serializes the particle system to a JSON object.
  91940. * @returns the JSON object
  91941. */
  91942. serialize(): any;
  91943. /**
  91944. * Parse properties from a JSON object
  91945. * @param serializationObject defines the JSON object
  91946. * @param scene defines the hosting scene
  91947. */
  91948. parse(serializationObject: any, scene: Scene): void;
  91949. }
  91950. }
  91951. declare module BABYLON {
  91952. /**
  91953. * Particle emitter emitting particles from the inside of a box.
  91954. * It emits the particles randomly between 2 given directions.
  91955. */
  91956. export class BoxParticleEmitter implements IParticleEmitterType {
  91957. /**
  91958. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91959. */
  91960. direction1: Vector3;
  91961. /**
  91962. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91963. */
  91964. direction2: Vector3;
  91965. /**
  91966. * 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.
  91967. */
  91968. minEmitBox: Vector3;
  91969. /**
  91970. * 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.
  91971. */
  91972. maxEmitBox: Vector3;
  91973. /**
  91974. * Creates a new instance BoxParticleEmitter
  91975. */
  91976. constructor();
  91977. /**
  91978. * Called by the particle System when the direction is computed for the created particle.
  91979. * @param worldMatrix is the world matrix of the particle system
  91980. * @param directionToUpdate is the direction vector to update with the result
  91981. * @param particle is the particle we are computed the direction for
  91982. * @param isLocal defines if the direction should be set in local space
  91983. */
  91984. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91985. /**
  91986. * Called by the particle System when the position is computed for the created particle.
  91987. * @param worldMatrix is the world matrix of the particle system
  91988. * @param positionToUpdate is the position vector to update with the result
  91989. * @param particle is the particle we are computed the position for
  91990. * @param isLocal defines if the position should be set in local space
  91991. */
  91992. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91993. /**
  91994. * Clones the current emitter and returns a copy of it
  91995. * @returns the new emitter
  91996. */
  91997. clone(): BoxParticleEmitter;
  91998. /**
  91999. * Called by the GPUParticleSystem to setup the update shader
  92000. * @param effect defines the update shader
  92001. */
  92002. applyToShader(effect: Effect): void;
  92003. /**
  92004. * Returns a string to use to update the GPU particles update shader
  92005. * @returns a string containng the defines string
  92006. */
  92007. getEffectDefines(): string;
  92008. /**
  92009. * Returns the string "BoxParticleEmitter"
  92010. * @returns a string containing the class name
  92011. */
  92012. getClassName(): string;
  92013. /**
  92014. * Serializes the particle system to a JSON object.
  92015. * @returns the JSON object
  92016. */
  92017. serialize(): any;
  92018. /**
  92019. * Parse properties from a JSON object
  92020. * @param serializationObject defines the JSON object
  92021. */
  92022. parse(serializationObject: any): void;
  92023. }
  92024. }
  92025. declare module BABYLON {
  92026. /**
  92027. * Particle emitter emitting particles from the inside of a cone.
  92028. * It emits the particles alongside the cone volume from the base to the particle.
  92029. * The emission direction might be randomized.
  92030. */
  92031. export class ConeParticleEmitter implements IParticleEmitterType {
  92032. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92033. directionRandomizer: number;
  92034. private _radius;
  92035. private _angle;
  92036. private _height;
  92037. /**
  92038. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92039. */
  92040. radiusRange: number;
  92041. /**
  92042. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92043. */
  92044. heightRange: number;
  92045. /**
  92046. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92047. */
  92048. emitFromSpawnPointOnly: boolean;
  92049. /**
  92050. * Gets or sets the radius of the emission cone
  92051. */
  92052. get radius(): number;
  92053. set radius(value: number);
  92054. /**
  92055. * Gets or sets the angle of the emission cone
  92056. */
  92057. get angle(): number;
  92058. set angle(value: number);
  92059. private _buildHeight;
  92060. /**
  92061. * Creates a new instance ConeParticleEmitter
  92062. * @param radius the radius of the emission cone (1 by default)
  92063. * @param angle the cone base angle (PI by default)
  92064. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92065. */
  92066. constructor(radius?: number, angle?: number,
  92067. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92068. directionRandomizer?: number);
  92069. /**
  92070. * Called by the particle System when the direction is computed for the created particle.
  92071. * @param worldMatrix is the world matrix of the particle system
  92072. * @param directionToUpdate is the direction vector to update with the result
  92073. * @param particle is the particle we are computed the direction for
  92074. * @param isLocal defines if the direction should be set in local space
  92075. */
  92076. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92077. /**
  92078. * Called by the particle System when the position is computed for the created particle.
  92079. * @param worldMatrix is the world matrix of the particle system
  92080. * @param positionToUpdate is the position vector to update with the result
  92081. * @param particle is the particle we are computed the position for
  92082. * @param isLocal defines if the position should be set in local space
  92083. */
  92084. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92085. /**
  92086. * Clones the current emitter and returns a copy of it
  92087. * @returns the new emitter
  92088. */
  92089. clone(): ConeParticleEmitter;
  92090. /**
  92091. * Called by the GPUParticleSystem to setup the update shader
  92092. * @param effect defines the update shader
  92093. */
  92094. applyToShader(effect: Effect): void;
  92095. /**
  92096. * Returns a string to use to update the GPU particles update shader
  92097. * @returns a string containng the defines string
  92098. */
  92099. getEffectDefines(): string;
  92100. /**
  92101. * Returns the string "ConeParticleEmitter"
  92102. * @returns a string containing the class name
  92103. */
  92104. getClassName(): string;
  92105. /**
  92106. * Serializes the particle system to a JSON object.
  92107. * @returns the JSON object
  92108. */
  92109. serialize(): any;
  92110. /**
  92111. * Parse properties from a JSON object
  92112. * @param serializationObject defines the JSON object
  92113. */
  92114. parse(serializationObject: any): void;
  92115. }
  92116. }
  92117. declare module BABYLON {
  92118. /**
  92119. * Particle emitter emitting particles from the inside of a cylinder.
  92120. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  92121. */
  92122. export class CylinderParticleEmitter implements IParticleEmitterType {
  92123. /**
  92124. * The radius of the emission cylinder.
  92125. */
  92126. radius: number;
  92127. /**
  92128. * The height of the emission cylinder.
  92129. */
  92130. height: number;
  92131. /**
  92132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92133. */
  92134. radiusRange: number;
  92135. /**
  92136. * How much to randomize the particle direction [0-1].
  92137. */
  92138. directionRandomizer: number;
  92139. /**
  92140. * Creates a new instance CylinderParticleEmitter
  92141. * @param radius the radius of the emission cylinder (1 by default)
  92142. * @param height the height of the emission cylinder (1 by default)
  92143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92144. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92145. */
  92146. constructor(
  92147. /**
  92148. * The radius of the emission cylinder.
  92149. */
  92150. radius?: number,
  92151. /**
  92152. * The height of the emission cylinder.
  92153. */
  92154. height?: number,
  92155. /**
  92156. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92157. */
  92158. radiusRange?: number,
  92159. /**
  92160. * How much to randomize the particle direction [0-1].
  92161. */
  92162. directionRandomizer?: number);
  92163. /**
  92164. * Called by the particle System when the direction is computed for the created particle.
  92165. * @param worldMatrix is the world matrix of the particle system
  92166. * @param directionToUpdate is the direction vector to update with the result
  92167. * @param particle is the particle we are computed the direction for
  92168. * @param isLocal defines if the direction should be set in local space
  92169. */
  92170. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92171. /**
  92172. * Called by the particle System when the position is computed for the created particle.
  92173. * @param worldMatrix is the world matrix of the particle system
  92174. * @param positionToUpdate is the position vector to update with the result
  92175. * @param particle is the particle we are computed the position for
  92176. * @param isLocal defines if the position should be set in local space
  92177. */
  92178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92179. /**
  92180. * Clones the current emitter and returns a copy of it
  92181. * @returns the new emitter
  92182. */
  92183. clone(): CylinderParticleEmitter;
  92184. /**
  92185. * Called by the GPUParticleSystem to setup the update shader
  92186. * @param effect defines the update shader
  92187. */
  92188. applyToShader(effect: Effect): void;
  92189. /**
  92190. * Returns a string to use to update the GPU particles update shader
  92191. * @returns a string containng the defines string
  92192. */
  92193. getEffectDefines(): string;
  92194. /**
  92195. * Returns the string "CylinderParticleEmitter"
  92196. * @returns a string containing the class name
  92197. */
  92198. getClassName(): string;
  92199. /**
  92200. * Serializes the particle system to a JSON object.
  92201. * @returns the JSON object
  92202. */
  92203. serialize(): any;
  92204. /**
  92205. * Parse properties from a JSON object
  92206. * @param serializationObject defines the JSON object
  92207. */
  92208. parse(serializationObject: any): void;
  92209. }
  92210. /**
  92211. * Particle emitter emitting particles from the inside of a cylinder.
  92212. * It emits the particles randomly between two vectors.
  92213. */
  92214. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  92215. /**
  92216. * The min limit of the emission direction.
  92217. */
  92218. direction1: Vector3;
  92219. /**
  92220. * The max limit of the emission direction.
  92221. */
  92222. direction2: Vector3;
  92223. /**
  92224. * Creates a new instance CylinderDirectedParticleEmitter
  92225. * @param radius the radius of the emission cylinder (1 by default)
  92226. * @param height the height of the emission cylinder (1 by default)
  92227. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92228. * @param direction1 the min limit of the emission direction (up vector by default)
  92229. * @param direction2 the max limit of the emission direction (up vector by default)
  92230. */
  92231. constructor(radius?: number, height?: number, radiusRange?: number,
  92232. /**
  92233. * The min limit of the emission direction.
  92234. */
  92235. direction1?: Vector3,
  92236. /**
  92237. * The max limit of the emission direction.
  92238. */
  92239. direction2?: Vector3);
  92240. /**
  92241. * Called by the particle System when the direction is computed for the created particle.
  92242. * @param worldMatrix is the world matrix of the particle system
  92243. * @param directionToUpdate is the direction vector to update with the result
  92244. * @param particle is the particle we are computed the direction for
  92245. */
  92246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92247. /**
  92248. * Clones the current emitter and returns a copy of it
  92249. * @returns the new emitter
  92250. */
  92251. clone(): CylinderDirectedParticleEmitter;
  92252. /**
  92253. * Called by the GPUParticleSystem to setup the update shader
  92254. * @param effect defines the update shader
  92255. */
  92256. applyToShader(effect: Effect): void;
  92257. /**
  92258. * Returns a string to use to update the GPU particles update shader
  92259. * @returns a string containng the defines string
  92260. */
  92261. getEffectDefines(): string;
  92262. /**
  92263. * Returns the string "CylinderDirectedParticleEmitter"
  92264. * @returns a string containing the class name
  92265. */
  92266. getClassName(): string;
  92267. /**
  92268. * Serializes the particle system to a JSON object.
  92269. * @returns the JSON object
  92270. */
  92271. serialize(): any;
  92272. /**
  92273. * Parse properties from a JSON object
  92274. * @param serializationObject defines the JSON object
  92275. */
  92276. parse(serializationObject: any): void;
  92277. }
  92278. }
  92279. declare module BABYLON {
  92280. /**
  92281. * Particle emitter emitting particles from the inside of a hemisphere.
  92282. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  92283. */
  92284. export class HemisphericParticleEmitter implements IParticleEmitterType {
  92285. /**
  92286. * The radius of the emission hemisphere.
  92287. */
  92288. radius: number;
  92289. /**
  92290. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92291. */
  92292. radiusRange: number;
  92293. /**
  92294. * How much to randomize the particle direction [0-1].
  92295. */
  92296. directionRandomizer: number;
  92297. /**
  92298. * Creates a new instance HemisphericParticleEmitter
  92299. * @param radius the radius of the emission hemisphere (1 by default)
  92300. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92301. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92302. */
  92303. constructor(
  92304. /**
  92305. * The radius of the emission hemisphere.
  92306. */
  92307. radius?: number,
  92308. /**
  92309. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92310. */
  92311. radiusRange?: number,
  92312. /**
  92313. * How much to randomize the particle direction [0-1].
  92314. */
  92315. directionRandomizer?: number);
  92316. /**
  92317. * Called by the particle System when the direction is computed for the created particle.
  92318. * @param worldMatrix is the world matrix of the particle system
  92319. * @param directionToUpdate is the direction vector to update with the result
  92320. * @param particle is the particle we are computed the direction for
  92321. * @param isLocal defines if the direction should be set in local space
  92322. */
  92323. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92324. /**
  92325. * Called by the particle System when the position is computed for the created particle.
  92326. * @param worldMatrix is the world matrix of the particle system
  92327. * @param positionToUpdate is the position vector to update with the result
  92328. * @param particle is the particle we are computed the position for
  92329. * @param isLocal defines if the position should be set in local space
  92330. */
  92331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92332. /**
  92333. * Clones the current emitter and returns a copy of it
  92334. * @returns the new emitter
  92335. */
  92336. clone(): HemisphericParticleEmitter;
  92337. /**
  92338. * Called by the GPUParticleSystem to setup the update shader
  92339. * @param effect defines the update shader
  92340. */
  92341. applyToShader(effect: Effect): void;
  92342. /**
  92343. * Returns a string to use to update the GPU particles update shader
  92344. * @returns a string containng the defines string
  92345. */
  92346. getEffectDefines(): string;
  92347. /**
  92348. * Returns the string "HemisphericParticleEmitter"
  92349. * @returns a string containing the class name
  92350. */
  92351. getClassName(): string;
  92352. /**
  92353. * Serializes the particle system to a JSON object.
  92354. * @returns the JSON object
  92355. */
  92356. serialize(): any;
  92357. /**
  92358. * Parse properties from a JSON object
  92359. * @param serializationObject defines the JSON object
  92360. */
  92361. parse(serializationObject: any): void;
  92362. }
  92363. }
  92364. declare module BABYLON {
  92365. /**
  92366. * Particle emitter emitting particles from a point.
  92367. * It emits the particles randomly between 2 given directions.
  92368. */
  92369. export class PointParticleEmitter implements IParticleEmitterType {
  92370. /**
  92371. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92372. */
  92373. direction1: Vector3;
  92374. /**
  92375. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92376. */
  92377. direction2: Vector3;
  92378. /**
  92379. * Creates a new instance PointParticleEmitter
  92380. */
  92381. constructor();
  92382. /**
  92383. * Called by the particle System when the direction is computed for the created particle.
  92384. * @param worldMatrix is the world matrix of the particle system
  92385. * @param directionToUpdate is the direction vector to update with the result
  92386. * @param particle is the particle we are computed the direction for
  92387. * @param isLocal defines if the direction should be set in local space
  92388. */
  92389. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92390. /**
  92391. * Called by the particle System when the position is computed for the created particle.
  92392. * @param worldMatrix is the world matrix of the particle system
  92393. * @param positionToUpdate is the position vector to update with the result
  92394. * @param particle is the particle we are computed the position for
  92395. * @param isLocal defines if the position should be set in local space
  92396. */
  92397. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92398. /**
  92399. * Clones the current emitter and returns a copy of it
  92400. * @returns the new emitter
  92401. */
  92402. clone(): PointParticleEmitter;
  92403. /**
  92404. * Called by the GPUParticleSystem to setup the update shader
  92405. * @param effect defines the update shader
  92406. */
  92407. applyToShader(effect: Effect): void;
  92408. /**
  92409. * Returns a string to use to update the GPU particles update shader
  92410. * @returns a string containng the defines string
  92411. */
  92412. getEffectDefines(): string;
  92413. /**
  92414. * Returns the string "PointParticleEmitter"
  92415. * @returns a string containing the class name
  92416. */
  92417. getClassName(): string;
  92418. /**
  92419. * Serializes the particle system to a JSON object.
  92420. * @returns the JSON object
  92421. */
  92422. serialize(): any;
  92423. /**
  92424. * Parse properties from a JSON object
  92425. * @param serializationObject defines the JSON object
  92426. */
  92427. parse(serializationObject: any): void;
  92428. }
  92429. }
  92430. declare module BABYLON {
  92431. /**
  92432. * Particle emitter emitting particles from the inside of a sphere.
  92433. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92434. */
  92435. export class SphereParticleEmitter implements IParticleEmitterType {
  92436. /**
  92437. * The radius of the emission sphere.
  92438. */
  92439. radius: number;
  92440. /**
  92441. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92442. */
  92443. radiusRange: number;
  92444. /**
  92445. * How much to randomize the particle direction [0-1].
  92446. */
  92447. directionRandomizer: number;
  92448. /**
  92449. * Creates a new instance SphereParticleEmitter
  92450. * @param radius the radius of the emission sphere (1 by default)
  92451. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92453. */
  92454. constructor(
  92455. /**
  92456. * The radius of the emission sphere.
  92457. */
  92458. radius?: number,
  92459. /**
  92460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92461. */
  92462. radiusRange?: number,
  92463. /**
  92464. * How much to randomize the particle direction [0-1].
  92465. */
  92466. directionRandomizer?: number);
  92467. /**
  92468. * Called by the particle System when the direction is computed for the created particle.
  92469. * @param worldMatrix is the world matrix of the particle system
  92470. * @param directionToUpdate is the direction vector to update with the result
  92471. * @param particle is the particle we are computed the direction for
  92472. * @param isLocal defines if the direction should be set in local space
  92473. */
  92474. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92475. /**
  92476. * Called by the particle System when the position is computed for the created particle.
  92477. * @param worldMatrix is the world matrix of the particle system
  92478. * @param positionToUpdate is the position vector to update with the result
  92479. * @param particle is the particle we are computed the position for
  92480. * @param isLocal defines if the position should be set in local space
  92481. */
  92482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92483. /**
  92484. * Clones the current emitter and returns a copy of it
  92485. * @returns the new emitter
  92486. */
  92487. clone(): SphereParticleEmitter;
  92488. /**
  92489. * Called by the GPUParticleSystem to setup the update shader
  92490. * @param effect defines the update shader
  92491. */
  92492. applyToShader(effect: Effect): void;
  92493. /**
  92494. * Returns a string to use to update the GPU particles update shader
  92495. * @returns a string containng the defines string
  92496. */
  92497. getEffectDefines(): string;
  92498. /**
  92499. * Returns the string "SphereParticleEmitter"
  92500. * @returns a string containing the class name
  92501. */
  92502. getClassName(): string;
  92503. /**
  92504. * Serializes the particle system to a JSON object.
  92505. * @returns the JSON object
  92506. */
  92507. serialize(): any;
  92508. /**
  92509. * Parse properties from a JSON object
  92510. * @param serializationObject defines the JSON object
  92511. */
  92512. parse(serializationObject: any): void;
  92513. }
  92514. /**
  92515. * Particle emitter emitting particles from the inside of a sphere.
  92516. * It emits the particles randomly between two vectors.
  92517. */
  92518. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  92519. /**
  92520. * The min limit of the emission direction.
  92521. */
  92522. direction1: Vector3;
  92523. /**
  92524. * The max limit of the emission direction.
  92525. */
  92526. direction2: Vector3;
  92527. /**
  92528. * Creates a new instance SphereDirectedParticleEmitter
  92529. * @param radius the radius of the emission sphere (1 by default)
  92530. * @param direction1 the min limit of the emission direction (up vector by default)
  92531. * @param direction2 the max limit of the emission direction (up vector by default)
  92532. */
  92533. constructor(radius?: number,
  92534. /**
  92535. * The min limit of the emission direction.
  92536. */
  92537. direction1?: Vector3,
  92538. /**
  92539. * The max limit of the emission direction.
  92540. */
  92541. direction2?: Vector3);
  92542. /**
  92543. * Called by the particle System when the direction is computed for the created particle.
  92544. * @param worldMatrix is the world matrix of the particle system
  92545. * @param directionToUpdate is the direction vector to update with the result
  92546. * @param particle is the particle we are computed the direction for
  92547. */
  92548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92549. /**
  92550. * Clones the current emitter and returns a copy of it
  92551. * @returns the new emitter
  92552. */
  92553. clone(): SphereDirectedParticleEmitter;
  92554. /**
  92555. * Called by the GPUParticleSystem to setup the update shader
  92556. * @param effect defines the update shader
  92557. */
  92558. applyToShader(effect: Effect): void;
  92559. /**
  92560. * Returns a string to use to update the GPU particles update shader
  92561. * @returns a string containng the defines string
  92562. */
  92563. getEffectDefines(): string;
  92564. /**
  92565. * Returns the string "SphereDirectedParticleEmitter"
  92566. * @returns a string containing the class name
  92567. */
  92568. getClassName(): string;
  92569. /**
  92570. * Serializes the particle system to a JSON object.
  92571. * @returns the JSON object
  92572. */
  92573. serialize(): any;
  92574. /**
  92575. * Parse properties from a JSON object
  92576. * @param serializationObject defines the JSON object
  92577. */
  92578. parse(serializationObject: any): void;
  92579. }
  92580. }
  92581. declare module BABYLON {
  92582. /**
  92583. * Particle emitter emitting particles from a custom list of positions.
  92584. */
  92585. export class CustomParticleEmitter implements IParticleEmitterType {
  92586. /**
  92587. * Gets or sets the position generator that will create the inital position of each particle.
  92588. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92589. */
  92590. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92591. /**
  92592. * Gets or sets the destination generator that will create the final destination of each particle.
  92593. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92594. */
  92595. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92596. /**
  92597. * Creates a new instance CustomParticleEmitter
  92598. */
  92599. constructor();
  92600. /**
  92601. * Called by the particle System when the direction is computed for the created particle.
  92602. * @param worldMatrix is the world matrix of the particle system
  92603. * @param directionToUpdate is the direction vector to update with the result
  92604. * @param particle is the particle we are computed the direction for
  92605. * @param isLocal defines if the direction should be set in local space
  92606. */
  92607. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92608. /**
  92609. * Called by the particle System when the position is computed for the created particle.
  92610. * @param worldMatrix is the world matrix of the particle system
  92611. * @param positionToUpdate is the position vector to update with the result
  92612. * @param particle is the particle we are computed the position for
  92613. * @param isLocal defines if the position should be set in local space
  92614. */
  92615. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92616. /**
  92617. * Clones the current emitter and returns a copy of it
  92618. * @returns the new emitter
  92619. */
  92620. clone(): CustomParticleEmitter;
  92621. /**
  92622. * Called by the GPUParticleSystem to setup the update shader
  92623. * @param effect defines the update shader
  92624. */
  92625. applyToShader(effect: Effect): void;
  92626. /**
  92627. * Returns a string to use to update the GPU particles update shader
  92628. * @returns a string containng the defines string
  92629. */
  92630. getEffectDefines(): string;
  92631. /**
  92632. * Returns the string "PointParticleEmitter"
  92633. * @returns a string containing the class name
  92634. */
  92635. getClassName(): string;
  92636. /**
  92637. * Serializes the particle system to a JSON object.
  92638. * @returns the JSON object
  92639. */
  92640. serialize(): any;
  92641. /**
  92642. * Parse properties from a JSON object
  92643. * @param serializationObject defines the JSON object
  92644. */
  92645. parse(serializationObject: any): void;
  92646. }
  92647. }
  92648. declare module BABYLON {
  92649. /**
  92650. * Particle emitter emitting particles from the inside of a box.
  92651. * It emits the particles randomly between 2 given directions.
  92652. */
  92653. export class MeshParticleEmitter implements IParticleEmitterType {
  92654. private _indices;
  92655. private _positions;
  92656. private _normals;
  92657. private _storedNormal;
  92658. private _mesh;
  92659. /**
  92660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92661. */
  92662. direction1: Vector3;
  92663. /**
  92664. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92665. */
  92666. direction2: Vector3;
  92667. /**
  92668. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92669. */
  92670. useMeshNormalsForDirection: boolean;
  92671. /** Defines the mesh to use as source */
  92672. get mesh(): Nullable<AbstractMesh>;
  92673. set mesh(value: Nullable<AbstractMesh>);
  92674. /**
  92675. * Creates a new instance MeshParticleEmitter
  92676. * @param mesh defines the mesh to use as source
  92677. */
  92678. constructor(mesh?: Nullable<AbstractMesh>);
  92679. /**
  92680. * Called by the particle System when the direction is computed for the created particle.
  92681. * @param worldMatrix is the world matrix of the particle system
  92682. * @param directionToUpdate is the direction vector to update with the result
  92683. * @param particle is the particle we are computed the direction for
  92684. * @param isLocal defines if the direction should be set in local space
  92685. */
  92686. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92687. /**
  92688. * Called by the particle System when the position is computed for the created particle.
  92689. * @param worldMatrix is the world matrix of the particle system
  92690. * @param positionToUpdate is the position vector to update with the result
  92691. * @param particle is the particle we are computed the position for
  92692. * @param isLocal defines if the position should be set in local space
  92693. */
  92694. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92695. /**
  92696. * Clones the current emitter and returns a copy of it
  92697. * @returns the new emitter
  92698. */
  92699. clone(): MeshParticleEmitter;
  92700. /**
  92701. * Called by the GPUParticleSystem to setup the update shader
  92702. * @param effect defines the update shader
  92703. */
  92704. applyToShader(effect: Effect): void;
  92705. /**
  92706. * Returns a string to use to update the GPU particles update shader
  92707. * @returns a string containng the defines string
  92708. */
  92709. getEffectDefines(): string;
  92710. /**
  92711. * Returns the string "BoxParticleEmitter"
  92712. * @returns a string containing the class name
  92713. */
  92714. getClassName(): string;
  92715. /**
  92716. * Serializes the particle system to a JSON object.
  92717. * @returns the JSON object
  92718. */
  92719. serialize(): any;
  92720. /**
  92721. * Parse properties from a JSON object
  92722. * @param serializationObject defines the JSON object
  92723. * @param scene defines the hosting scene
  92724. */
  92725. parse(serializationObject: any, scene: Scene): void;
  92726. }
  92727. }
  92728. declare module BABYLON {
  92729. /**
  92730. * Interface representing a particle system in Babylon.js.
  92731. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92732. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92733. */
  92734. export interface IParticleSystem {
  92735. /**
  92736. * List of animations used by the particle system.
  92737. */
  92738. animations: Animation[];
  92739. /**
  92740. * The id of the Particle system.
  92741. */
  92742. id: string;
  92743. /**
  92744. * The name of the Particle system.
  92745. */
  92746. name: string;
  92747. /**
  92748. * The emitter represents the Mesh or position we are attaching the particle system to.
  92749. */
  92750. emitter: Nullable<AbstractMesh | Vector3>;
  92751. /**
  92752. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92753. */
  92754. isBillboardBased: boolean;
  92755. /**
  92756. * The rendering group used by the Particle system to chose when to render.
  92757. */
  92758. renderingGroupId: number;
  92759. /**
  92760. * The layer mask we are rendering the particles through.
  92761. */
  92762. layerMask: number;
  92763. /**
  92764. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92765. */
  92766. updateSpeed: number;
  92767. /**
  92768. * The amount of time the particle system is running (depends of the overall update speed).
  92769. */
  92770. targetStopDuration: number;
  92771. /**
  92772. * The texture used to render each particle. (this can be a spritesheet)
  92773. */
  92774. particleTexture: Nullable<Texture>;
  92775. /**
  92776. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92777. */
  92778. blendMode: number;
  92779. /**
  92780. * Minimum life time of emitting particles.
  92781. */
  92782. minLifeTime: number;
  92783. /**
  92784. * Maximum life time of emitting particles.
  92785. */
  92786. maxLifeTime: number;
  92787. /**
  92788. * Minimum Size of emitting particles.
  92789. */
  92790. minSize: number;
  92791. /**
  92792. * Maximum Size of emitting particles.
  92793. */
  92794. maxSize: number;
  92795. /**
  92796. * Minimum scale of emitting particles on X axis.
  92797. */
  92798. minScaleX: number;
  92799. /**
  92800. * Maximum scale of emitting particles on X axis.
  92801. */
  92802. maxScaleX: number;
  92803. /**
  92804. * Minimum scale of emitting particles on Y axis.
  92805. */
  92806. minScaleY: number;
  92807. /**
  92808. * Maximum scale of emitting particles on Y axis.
  92809. */
  92810. maxScaleY: number;
  92811. /**
  92812. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92813. */
  92814. color1: Color4;
  92815. /**
  92816. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92817. */
  92818. color2: Color4;
  92819. /**
  92820. * Color the particle will have at the end of its lifetime.
  92821. */
  92822. colorDead: Color4;
  92823. /**
  92824. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92825. */
  92826. emitRate: number;
  92827. /**
  92828. * You can use gravity if you want to give an orientation to your particles.
  92829. */
  92830. gravity: Vector3;
  92831. /**
  92832. * Minimum power of emitting particles.
  92833. */
  92834. minEmitPower: number;
  92835. /**
  92836. * Maximum power of emitting particles.
  92837. */
  92838. maxEmitPower: number;
  92839. /**
  92840. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92841. */
  92842. minAngularSpeed: number;
  92843. /**
  92844. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92845. */
  92846. maxAngularSpeed: number;
  92847. /**
  92848. * Gets or sets the minimal initial rotation in radians.
  92849. */
  92850. minInitialRotation: number;
  92851. /**
  92852. * Gets or sets the maximal initial rotation in radians.
  92853. */
  92854. maxInitialRotation: number;
  92855. /**
  92856. * The particle emitter type defines the emitter used by the particle system.
  92857. * It can be for example box, sphere, or cone...
  92858. */
  92859. particleEmitterType: Nullable<IParticleEmitterType>;
  92860. /**
  92861. * Defines the delay in milliseconds before starting the system (0 by default)
  92862. */
  92863. startDelay: number;
  92864. /**
  92865. * 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
  92866. */
  92867. preWarmCycles: number;
  92868. /**
  92869. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92870. */
  92871. preWarmStepOffset: number;
  92872. /**
  92873. * 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)
  92874. */
  92875. spriteCellChangeSpeed: number;
  92876. /**
  92877. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92878. */
  92879. startSpriteCellID: number;
  92880. /**
  92881. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92882. */
  92883. endSpriteCellID: number;
  92884. /**
  92885. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92886. */
  92887. spriteCellWidth: number;
  92888. /**
  92889. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92890. */
  92891. spriteCellHeight: number;
  92892. /**
  92893. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92894. */
  92895. spriteRandomStartCell: boolean;
  92896. /**
  92897. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92898. */
  92899. isAnimationSheetEnabled: boolean;
  92900. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92901. translationPivot: Vector2;
  92902. /**
  92903. * Gets or sets a texture used to add random noise to particle positions
  92904. */
  92905. noiseTexture: Nullable<BaseTexture>;
  92906. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92907. noiseStrength: Vector3;
  92908. /**
  92909. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92910. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92911. */
  92912. billboardMode: number;
  92913. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92914. limitVelocityDamping: number;
  92915. /**
  92916. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92917. */
  92918. beginAnimationOnStart: boolean;
  92919. /**
  92920. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92921. */
  92922. beginAnimationFrom: number;
  92923. /**
  92924. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92925. */
  92926. beginAnimationTo: number;
  92927. /**
  92928. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92929. */
  92930. beginAnimationLoop: boolean;
  92931. /**
  92932. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92933. */
  92934. disposeOnStop: boolean;
  92935. /**
  92936. * Specifies if the particles are updated in emitter local space or world space
  92937. */
  92938. isLocal: boolean;
  92939. /** Snippet ID if the particle system was created from the snippet server */
  92940. snippetId: string;
  92941. /**
  92942. * Gets the maximum number of particles active at the same time.
  92943. * @returns The max number of active particles.
  92944. */
  92945. getCapacity(): number;
  92946. /**
  92947. * Gets the number of particles active at the same time.
  92948. * @returns The number of active particles.
  92949. */
  92950. getActiveCount(): number;
  92951. /**
  92952. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92953. * @returns True if it has been started, otherwise false.
  92954. */
  92955. isStarted(): boolean;
  92956. /**
  92957. * Animates the particle system for this frame.
  92958. */
  92959. animate(): void;
  92960. /**
  92961. * Renders the particle system in its current state.
  92962. * @returns the current number of particles
  92963. */
  92964. render(): number;
  92965. /**
  92966. * Dispose the particle system and frees its associated resources.
  92967. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92968. */
  92969. dispose(disposeTexture?: boolean): void;
  92970. /**
  92971. * An event triggered when the system is disposed
  92972. */
  92973. onDisposeObservable: Observable<IParticleSystem>;
  92974. /**
  92975. * Clones the particle system.
  92976. * @param name The name of the cloned object
  92977. * @param newEmitter The new emitter to use
  92978. * @returns the cloned particle system
  92979. */
  92980. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92981. /**
  92982. * Serializes the particle system to a JSON object
  92983. * @param serializeTexture defines if the texture must be serialized as well
  92984. * @returns the JSON object
  92985. */
  92986. serialize(serializeTexture: boolean): any;
  92987. /**
  92988. * Rebuild the particle system
  92989. */
  92990. rebuild(): void;
  92991. /** Force the system to rebuild all gradients that need to be resync */
  92992. forceRefreshGradients(): void;
  92993. /**
  92994. * Starts the particle system and begins to emit
  92995. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92996. */
  92997. start(delay?: number): void;
  92998. /**
  92999. * Stops the particle system.
  93000. */
  93001. stop(): void;
  93002. /**
  93003. * Remove all active particles
  93004. */
  93005. reset(): void;
  93006. /**
  93007. * Gets a boolean indicating that the system is stopping
  93008. * @returns true if the system is currently stopping
  93009. */
  93010. isStopping(): boolean;
  93011. /**
  93012. * Is this system ready to be used/rendered
  93013. * @return true if the system is ready
  93014. */
  93015. isReady(): boolean;
  93016. /**
  93017. * Returns the string "ParticleSystem"
  93018. * @returns a string containing the class name
  93019. */
  93020. getClassName(): string;
  93021. /**
  93022. * Gets the custom effect used to render the particles
  93023. * @param blendMode Blend mode for which the effect should be retrieved
  93024. * @returns The effect
  93025. */
  93026. getCustomEffect(blendMode: number): Nullable<Effect>;
  93027. /**
  93028. * Sets the custom effect used to render the particles
  93029. * @param effect The effect to set
  93030. * @param blendMode Blend mode for which the effect should be set
  93031. */
  93032. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93033. /**
  93034. * Fill the defines array according to the current settings of the particle system
  93035. * @param defines Array to be updated
  93036. * @param blendMode blend mode to take into account when updating the array
  93037. */
  93038. fillDefines(defines: Array<string>, blendMode: number): void;
  93039. /**
  93040. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93041. * @param uniforms Uniforms array to fill
  93042. * @param attributes Attributes array to fill
  93043. * @param samplers Samplers array to fill
  93044. */
  93045. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93046. /**
  93047. * Observable that will be called just before the particles are drawn
  93048. */
  93049. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93050. /**
  93051. * Gets the name of the particle vertex shader
  93052. */
  93053. vertexShaderName: string;
  93054. /**
  93055. * Adds a new color gradient
  93056. * @param gradient defines the gradient to use (between 0 and 1)
  93057. * @param color1 defines the color to affect to the specified gradient
  93058. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93059. * @returns the current particle system
  93060. */
  93061. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93062. /**
  93063. * Remove a specific color gradient
  93064. * @param gradient defines the gradient to remove
  93065. * @returns the current particle system
  93066. */
  93067. removeColorGradient(gradient: number): IParticleSystem;
  93068. /**
  93069. * Adds a new size gradient
  93070. * @param gradient defines the gradient to use (between 0 and 1)
  93071. * @param factor defines the size factor to affect to the specified gradient
  93072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93073. * @returns the current particle system
  93074. */
  93075. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93076. /**
  93077. * Remove a specific size gradient
  93078. * @param gradient defines the gradient to remove
  93079. * @returns the current particle system
  93080. */
  93081. removeSizeGradient(gradient: number): IParticleSystem;
  93082. /**
  93083. * Gets the current list of color gradients.
  93084. * You must use addColorGradient and removeColorGradient to udpate this list
  93085. * @returns the list of color gradients
  93086. */
  93087. getColorGradients(): Nullable<Array<ColorGradient>>;
  93088. /**
  93089. * Gets the current list of size gradients.
  93090. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93091. * @returns the list of size gradients
  93092. */
  93093. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93094. /**
  93095. * Gets the current list of angular speed gradients.
  93096. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93097. * @returns the list of angular speed gradients
  93098. */
  93099. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93100. /**
  93101. * Adds a new angular speed gradient
  93102. * @param gradient defines the gradient to use (between 0 and 1)
  93103. * @param factor defines the angular speed to affect to the specified gradient
  93104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93105. * @returns the current particle system
  93106. */
  93107. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93108. /**
  93109. * Remove a specific angular speed gradient
  93110. * @param gradient defines the gradient to remove
  93111. * @returns the current particle system
  93112. */
  93113. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93114. /**
  93115. * Gets the current list of velocity gradients.
  93116. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93117. * @returns the list of velocity gradients
  93118. */
  93119. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93120. /**
  93121. * Adds a new velocity gradient
  93122. * @param gradient defines the gradient to use (between 0 and 1)
  93123. * @param factor defines the velocity to affect to the specified gradient
  93124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93125. * @returns the current particle system
  93126. */
  93127. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93128. /**
  93129. * Remove a specific velocity gradient
  93130. * @param gradient defines the gradient to remove
  93131. * @returns the current particle system
  93132. */
  93133. removeVelocityGradient(gradient: number): IParticleSystem;
  93134. /**
  93135. * Gets the current list of limit velocity gradients.
  93136. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93137. * @returns the list of limit velocity gradients
  93138. */
  93139. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93140. /**
  93141. * Adds a new limit velocity gradient
  93142. * @param gradient defines the gradient to use (between 0 and 1)
  93143. * @param factor defines the limit velocity to affect to the specified gradient
  93144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93145. * @returns the current particle system
  93146. */
  93147. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93148. /**
  93149. * Remove a specific limit velocity gradient
  93150. * @param gradient defines the gradient to remove
  93151. * @returns the current particle system
  93152. */
  93153. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93154. /**
  93155. * Adds a new drag gradient
  93156. * @param gradient defines the gradient to use (between 0 and 1)
  93157. * @param factor defines the drag to affect to the specified gradient
  93158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93159. * @returns the current particle system
  93160. */
  93161. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93162. /**
  93163. * Remove a specific drag gradient
  93164. * @param gradient defines the gradient to remove
  93165. * @returns the current particle system
  93166. */
  93167. removeDragGradient(gradient: number): IParticleSystem;
  93168. /**
  93169. * Gets the current list of drag gradients.
  93170. * You must use addDragGradient and removeDragGradient to udpate this list
  93171. * @returns the list of drag gradients
  93172. */
  93173. getDragGradients(): Nullable<Array<FactorGradient>>;
  93174. /**
  93175. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93176. * @param gradient defines the gradient to use (between 0 and 1)
  93177. * @param factor defines the emit rate to affect to the specified gradient
  93178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93179. * @returns the current particle system
  93180. */
  93181. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93182. /**
  93183. * Remove a specific emit rate gradient
  93184. * @param gradient defines the gradient to remove
  93185. * @returns the current particle system
  93186. */
  93187. removeEmitRateGradient(gradient: number): IParticleSystem;
  93188. /**
  93189. * Gets the current list of emit rate gradients.
  93190. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93191. * @returns the list of emit rate gradients
  93192. */
  93193. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93194. /**
  93195. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93196. * @param gradient defines the gradient to use (between 0 and 1)
  93197. * @param factor defines the start size to affect to the specified gradient
  93198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93199. * @returns the current particle system
  93200. */
  93201. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93202. /**
  93203. * Remove a specific start size gradient
  93204. * @param gradient defines the gradient to remove
  93205. * @returns the current particle system
  93206. */
  93207. removeStartSizeGradient(gradient: number): IParticleSystem;
  93208. /**
  93209. * Gets the current list of start size gradients.
  93210. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93211. * @returns the list of start size gradients
  93212. */
  93213. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93214. /**
  93215. * Adds a new life time gradient
  93216. * @param gradient defines the gradient to use (between 0 and 1)
  93217. * @param factor defines the life time factor to affect to the specified gradient
  93218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93219. * @returns the current particle system
  93220. */
  93221. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93222. /**
  93223. * Remove a specific life time gradient
  93224. * @param gradient defines the gradient to remove
  93225. * @returns the current particle system
  93226. */
  93227. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93228. /**
  93229. * Gets the current list of life time gradients.
  93230. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93231. * @returns the list of life time gradients
  93232. */
  93233. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93234. /**
  93235. * Gets the current list of color gradients.
  93236. * You must use addColorGradient and removeColorGradient to udpate this list
  93237. * @returns the list of color gradients
  93238. */
  93239. getColorGradients(): Nullable<Array<ColorGradient>>;
  93240. /**
  93241. * Adds a new ramp gradient used to remap particle colors
  93242. * @param gradient defines the gradient to use (between 0 and 1)
  93243. * @param color defines the color to affect to the specified gradient
  93244. * @returns the current particle system
  93245. */
  93246. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  93247. /**
  93248. * Gets the current list of ramp gradients.
  93249. * You must use addRampGradient and removeRampGradient to udpate this list
  93250. * @returns the list of ramp gradients
  93251. */
  93252. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93253. /** Gets or sets a boolean indicating that ramp gradients must be used
  93254. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93255. */
  93256. useRampGradients: boolean;
  93257. /**
  93258. * Adds a new color remap gradient
  93259. * @param gradient defines the gradient to use (between 0 and 1)
  93260. * @param min defines the color remap minimal range
  93261. * @param max defines the color remap maximal range
  93262. * @returns the current particle system
  93263. */
  93264. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93265. /**
  93266. * Gets the current list of color remap gradients.
  93267. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93268. * @returns the list of color remap gradients
  93269. */
  93270. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93271. /**
  93272. * Adds a new alpha remap gradient
  93273. * @param gradient defines the gradient to use (between 0 and 1)
  93274. * @param min defines the alpha remap minimal range
  93275. * @param max defines the alpha remap maximal range
  93276. * @returns the current particle system
  93277. */
  93278. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93279. /**
  93280. * Gets the current list of alpha remap gradients.
  93281. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93282. * @returns the list of alpha remap gradients
  93283. */
  93284. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93285. /**
  93286. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93287. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93288. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93289. * @returns the emitter
  93290. */
  93291. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93292. /**
  93293. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93294. * @param radius The radius of the hemisphere to emit from
  93295. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93296. * @returns the emitter
  93297. */
  93298. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  93299. /**
  93300. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93301. * @param radius The radius of the sphere to emit from
  93302. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93303. * @returns the emitter
  93304. */
  93305. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  93306. /**
  93307. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93308. * @param radius The radius of the sphere to emit from
  93309. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93310. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93311. * @returns the emitter
  93312. */
  93313. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93314. /**
  93315. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93316. * @param radius The radius of the emission cylinder
  93317. * @param height The height of the emission cylinder
  93318. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93319. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93320. * @returns the emitter
  93321. */
  93322. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  93323. /**
  93324. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93325. * @param radius The radius of the cylinder to emit from
  93326. * @param height The height of the emission cylinder
  93327. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93328. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93329. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93330. * @returns the emitter
  93331. */
  93332. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93333. /**
  93334. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93335. * @param radius The radius of the cone to emit from
  93336. * @param angle The base angle of the cone
  93337. * @returns the emitter
  93338. */
  93339. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  93340. /**
  93341. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93342. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93343. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93344. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93345. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93346. * @returns the emitter
  93347. */
  93348. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93349. /**
  93350. * Get hosting scene
  93351. * @returns the scene
  93352. */
  93353. getScene(): Scene;
  93354. }
  93355. }
  93356. declare module BABYLON {
  93357. /**
  93358. * 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.
  93359. * @see https://doc.babylonjs.com/how_to/transformnode
  93360. */
  93361. export class TransformNode extends Node {
  93362. /**
  93363. * Object will not rotate to face the camera
  93364. */
  93365. static BILLBOARDMODE_NONE: number;
  93366. /**
  93367. * Object will rotate to face the camera but only on the x axis
  93368. */
  93369. static BILLBOARDMODE_X: number;
  93370. /**
  93371. * Object will rotate to face the camera but only on the y axis
  93372. */
  93373. static BILLBOARDMODE_Y: number;
  93374. /**
  93375. * Object will rotate to face the camera but only on the z axis
  93376. */
  93377. static BILLBOARDMODE_Z: number;
  93378. /**
  93379. * Object will rotate to face the camera
  93380. */
  93381. static BILLBOARDMODE_ALL: number;
  93382. /**
  93383. * Object will rotate to face the camera's position instead of orientation
  93384. */
  93385. static BILLBOARDMODE_USE_POSITION: number;
  93386. private static _TmpRotation;
  93387. private static _TmpScaling;
  93388. private static _TmpTranslation;
  93389. private _forward;
  93390. private _forwardInverted;
  93391. private _up;
  93392. private _right;
  93393. private _rightInverted;
  93394. private _position;
  93395. private _rotation;
  93396. private _rotationQuaternion;
  93397. protected _scaling: Vector3;
  93398. protected _isDirty: boolean;
  93399. private _transformToBoneReferal;
  93400. private _isAbsoluteSynced;
  93401. private _billboardMode;
  93402. /**
  93403. * Gets or sets the billboard mode. Default is 0.
  93404. *
  93405. * | Value | Type | Description |
  93406. * | --- | --- | --- |
  93407. * | 0 | BILLBOARDMODE_NONE | |
  93408. * | 1 | BILLBOARDMODE_X | |
  93409. * | 2 | BILLBOARDMODE_Y | |
  93410. * | 4 | BILLBOARDMODE_Z | |
  93411. * | 7 | BILLBOARDMODE_ALL | |
  93412. *
  93413. */
  93414. get billboardMode(): number;
  93415. set billboardMode(value: number);
  93416. private _preserveParentRotationForBillboard;
  93417. /**
  93418. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93419. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93420. */
  93421. get preserveParentRotationForBillboard(): boolean;
  93422. set preserveParentRotationForBillboard(value: boolean);
  93423. /**
  93424. * 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
  93425. */
  93426. scalingDeterminant: number;
  93427. private _infiniteDistance;
  93428. /**
  93429. * Gets or sets the distance of the object to max, often used by skybox
  93430. */
  93431. get infiniteDistance(): boolean;
  93432. set infiniteDistance(value: boolean);
  93433. /**
  93434. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93435. * By default the system will update normals to compensate
  93436. */
  93437. ignoreNonUniformScaling: boolean;
  93438. /**
  93439. * 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
  93440. */
  93441. reIntegrateRotationIntoRotationQuaternion: boolean;
  93442. /** @hidden */
  93443. _poseMatrix: Nullable<Matrix>;
  93444. /** @hidden */
  93445. _localMatrix: Matrix;
  93446. private _usePivotMatrix;
  93447. private _absolutePosition;
  93448. private _absoluteScaling;
  93449. private _absoluteRotationQuaternion;
  93450. private _pivotMatrix;
  93451. private _pivotMatrixInverse;
  93452. protected _postMultiplyPivotMatrix: boolean;
  93453. protected _isWorldMatrixFrozen: boolean;
  93454. /** @hidden */
  93455. _indexInSceneTransformNodesArray: number;
  93456. /**
  93457. * An event triggered after the world matrix is updated
  93458. */
  93459. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93460. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93461. /**
  93462. * Gets a string identifying the name of the class
  93463. * @returns "TransformNode" string
  93464. */
  93465. getClassName(): string;
  93466. /**
  93467. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93468. */
  93469. get position(): Vector3;
  93470. set position(newPosition: Vector3);
  93471. /**
  93472. * 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)).
  93473. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93474. */
  93475. get rotation(): Vector3;
  93476. set rotation(newRotation: Vector3);
  93477. /**
  93478. * 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)).
  93479. */
  93480. get scaling(): Vector3;
  93481. set scaling(newScaling: Vector3);
  93482. /**
  93483. * 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).
  93484. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93485. */
  93486. get rotationQuaternion(): Nullable<Quaternion>;
  93487. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  93488. /**
  93489. * The forward direction of that transform in world space.
  93490. */
  93491. get forward(): Vector3;
  93492. /**
  93493. * The up direction of that transform in world space.
  93494. */
  93495. get up(): Vector3;
  93496. /**
  93497. * The right direction of that transform in world space.
  93498. */
  93499. get right(): Vector3;
  93500. /**
  93501. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93502. * @param matrix the matrix to copy the pose from
  93503. * @returns this TransformNode.
  93504. */
  93505. updatePoseMatrix(matrix: Matrix): TransformNode;
  93506. /**
  93507. * Returns the mesh Pose matrix.
  93508. * @returns the pose matrix
  93509. */
  93510. getPoseMatrix(): Matrix;
  93511. /** @hidden */
  93512. _isSynchronized(): boolean;
  93513. /** @hidden */
  93514. _initCache(): void;
  93515. /**
  93516. * Flag the transform node as dirty (Forcing it to update everything)
  93517. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93518. * @returns this transform node
  93519. */
  93520. markAsDirty(property: string): TransformNode;
  93521. /**
  93522. * Returns the current mesh absolute position.
  93523. * Returns a Vector3.
  93524. */
  93525. get absolutePosition(): Vector3;
  93526. /**
  93527. * Returns the current mesh absolute scaling.
  93528. * Returns a Vector3.
  93529. */
  93530. get absoluteScaling(): Vector3;
  93531. /**
  93532. * Returns the current mesh absolute rotation.
  93533. * Returns a Quaternion.
  93534. */
  93535. get absoluteRotationQuaternion(): Quaternion;
  93536. /**
  93537. * Sets a new matrix to apply before all other transformation
  93538. * @param matrix defines the transform matrix
  93539. * @returns the current TransformNode
  93540. */
  93541. setPreTransformMatrix(matrix: Matrix): TransformNode;
  93542. /**
  93543. * Sets a new pivot matrix to the current node
  93544. * @param matrix defines the new pivot matrix to use
  93545. * @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
  93546. * @returns the current TransformNode
  93547. */
  93548. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  93549. /**
  93550. * Returns the mesh pivot matrix.
  93551. * Default : Identity.
  93552. * @returns the matrix
  93553. */
  93554. getPivotMatrix(): Matrix;
  93555. /**
  93556. * Instantiate (when possible) or clone that node with its hierarchy
  93557. * @param newParent defines the new parent to use for the instance (or clone)
  93558. * @param options defines options to configure how copy is done
  93559. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  93560. * @returns an instance (or a clone) of the current node with its hiearchy
  93561. */
  93562. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93563. doNotInstantiate: boolean;
  93564. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93565. /**
  93566. * Prevents the World matrix to be computed any longer
  93567. * @param newWorldMatrix defines an optional matrix to use as world matrix
  93568. * @returns the TransformNode.
  93569. */
  93570. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  93571. /**
  93572. * Allows back the World matrix computation.
  93573. * @returns the TransformNode.
  93574. */
  93575. unfreezeWorldMatrix(): this;
  93576. /**
  93577. * True if the World matrix has been frozen.
  93578. */
  93579. get isWorldMatrixFrozen(): boolean;
  93580. /**
  93581. * Retuns the mesh absolute position in the World.
  93582. * @returns a Vector3.
  93583. */
  93584. getAbsolutePosition(): Vector3;
  93585. /**
  93586. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93587. * @param absolutePosition the absolute position to set
  93588. * @returns the TransformNode.
  93589. */
  93590. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93591. /**
  93592. * Sets the mesh position in its local space.
  93593. * @param vector3 the position to set in localspace
  93594. * @returns the TransformNode.
  93595. */
  93596. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93597. /**
  93598. * Returns the mesh position in the local space from the current World matrix values.
  93599. * @returns a new Vector3.
  93600. */
  93601. getPositionExpressedInLocalSpace(): Vector3;
  93602. /**
  93603. * Translates the mesh along the passed Vector3 in its local space.
  93604. * @param vector3 the distance to translate in localspace
  93605. * @returns the TransformNode.
  93606. */
  93607. locallyTranslate(vector3: Vector3): TransformNode;
  93608. private static _lookAtVectorCache;
  93609. /**
  93610. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93611. * @param targetPoint the position (must be in same space as current mesh) to look at
  93612. * @param yawCor optional yaw (y-axis) correction in radians
  93613. * @param pitchCor optional pitch (x-axis) correction in radians
  93614. * @param rollCor optional roll (z-axis) correction in radians
  93615. * @param space the choosen space of the target
  93616. * @returns the TransformNode.
  93617. */
  93618. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93619. /**
  93620. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93621. * This Vector3 is expressed in the World space.
  93622. * @param localAxis axis to rotate
  93623. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93624. */
  93625. getDirection(localAxis: Vector3): Vector3;
  93626. /**
  93627. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93628. * localAxis is expressed in the mesh local space.
  93629. * result is computed in the Wordl space from the mesh World matrix.
  93630. * @param localAxis axis to rotate
  93631. * @param result the resulting transformnode
  93632. * @returns this TransformNode.
  93633. */
  93634. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93635. /**
  93636. * Sets this transform node rotation to the given local axis.
  93637. * @param localAxis the axis in local space
  93638. * @param yawCor optional yaw (y-axis) correction in radians
  93639. * @param pitchCor optional pitch (x-axis) correction in radians
  93640. * @param rollCor optional roll (z-axis) correction in radians
  93641. * @returns this TransformNode
  93642. */
  93643. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93644. /**
  93645. * Sets a new pivot point to the current node
  93646. * @param point defines the new pivot point to use
  93647. * @param space defines if the point is in world or local space (local by default)
  93648. * @returns the current TransformNode
  93649. */
  93650. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93651. /**
  93652. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93653. * @returns the pivot point
  93654. */
  93655. getPivotPoint(): Vector3;
  93656. /**
  93657. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93658. * @param result the vector3 to store the result
  93659. * @returns this TransformNode.
  93660. */
  93661. getPivotPointToRef(result: Vector3): TransformNode;
  93662. /**
  93663. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93664. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93665. */
  93666. getAbsolutePivotPoint(): Vector3;
  93667. /**
  93668. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93669. * @param result vector3 to store the result
  93670. * @returns this TransformNode.
  93671. */
  93672. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93673. /**
  93674. * Defines the passed node as the parent of the current node.
  93675. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93676. * @see https://doc.babylonjs.com/how_to/parenting
  93677. * @param node the node ot set as the parent
  93678. * @returns this TransformNode.
  93679. */
  93680. setParent(node: Nullable<Node>): TransformNode;
  93681. private _nonUniformScaling;
  93682. /**
  93683. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93684. */
  93685. get nonUniformScaling(): boolean;
  93686. /** @hidden */
  93687. _updateNonUniformScalingState(value: boolean): boolean;
  93688. /**
  93689. * Attach the current TransformNode to another TransformNode associated with a bone
  93690. * @param bone Bone affecting the TransformNode
  93691. * @param affectedTransformNode TransformNode associated with the bone
  93692. * @returns this object
  93693. */
  93694. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93695. /**
  93696. * Detach the transform node if its associated with a bone
  93697. * @returns this object
  93698. */
  93699. detachFromBone(): TransformNode;
  93700. private static _rotationAxisCache;
  93701. /**
  93702. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93703. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93704. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93705. * The passed axis is also normalized.
  93706. * @param axis the axis to rotate around
  93707. * @param amount the amount to rotate in radians
  93708. * @param space Space to rotate in (Default: local)
  93709. * @returns the TransformNode.
  93710. */
  93711. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93712. /**
  93713. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93714. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93715. * The passed axis is also normalized. .
  93716. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93717. * @param point the point to rotate around
  93718. * @param axis the axis to rotate around
  93719. * @param amount the amount to rotate in radians
  93720. * @returns the TransformNode
  93721. */
  93722. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93723. /**
  93724. * Translates the mesh along the axis vector for the passed distance in the given space.
  93725. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93726. * @param axis the axis to translate in
  93727. * @param distance the distance to translate
  93728. * @param space Space to rotate in (Default: local)
  93729. * @returns the TransformNode.
  93730. */
  93731. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93732. /**
  93733. * Adds a rotation step to the mesh current rotation.
  93734. * x, y, z are Euler angles expressed in radians.
  93735. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93736. * This means this rotation is made in the mesh local space only.
  93737. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93738. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93739. * ```javascript
  93740. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93741. * ```
  93742. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93743. * 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.
  93744. * @param x Rotation to add
  93745. * @param y Rotation to add
  93746. * @param z Rotation to add
  93747. * @returns the TransformNode.
  93748. */
  93749. addRotation(x: number, y: number, z: number): TransformNode;
  93750. /**
  93751. * @hidden
  93752. */
  93753. protected _getEffectiveParent(): Nullable<Node>;
  93754. /**
  93755. * Computes the world matrix of the node
  93756. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93757. * @returns the world matrix
  93758. */
  93759. computeWorldMatrix(force?: boolean): Matrix;
  93760. /**
  93761. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93762. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93763. */
  93764. resetLocalMatrix(independentOfChildren?: boolean): void;
  93765. protected _afterComputeWorldMatrix(): void;
  93766. /**
  93767. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93768. * @param func callback function to add
  93769. *
  93770. * @returns the TransformNode.
  93771. */
  93772. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93773. /**
  93774. * Removes a registered callback function.
  93775. * @param func callback function to remove
  93776. * @returns the TransformNode.
  93777. */
  93778. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93779. /**
  93780. * Gets the position of the current mesh in camera space
  93781. * @param camera defines the camera to use
  93782. * @returns a position
  93783. */
  93784. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93785. /**
  93786. * Returns the distance from the mesh to the active camera
  93787. * @param camera defines the camera to use
  93788. * @returns the distance
  93789. */
  93790. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93791. /**
  93792. * Clone the current transform node
  93793. * @param name Name of the new clone
  93794. * @param newParent New parent for the clone
  93795. * @param doNotCloneChildren Do not clone children hierarchy
  93796. * @returns the new transform node
  93797. */
  93798. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93799. /**
  93800. * Serializes the objects information.
  93801. * @param currentSerializationObject defines the object to serialize in
  93802. * @returns the serialized object
  93803. */
  93804. serialize(currentSerializationObject?: any): any;
  93805. /**
  93806. * Returns a new TransformNode object parsed from the source provided.
  93807. * @param parsedTransformNode is the source.
  93808. * @param scene the scne the object belongs to
  93809. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93810. * @returns a new TransformNode object parsed from the source provided.
  93811. */
  93812. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93813. /**
  93814. * Get all child-transformNodes of this node
  93815. * @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
  93816. * @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
  93817. * @returns an array of TransformNode
  93818. */
  93819. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93820. /**
  93821. * Releases resources associated with this transform node.
  93822. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93823. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93824. */
  93825. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93826. /**
  93827. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93828. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93829. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93830. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93831. * @returns the current mesh
  93832. */
  93833. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93834. private _syncAbsoluteScalingAndRotation;
  93835. }
  93836. }
  93837. declare module BABYLON {
  93838. /**
  93839. * Class used to override all child animations of a given target
  93840. */
  93841. export class AnimationPropertiesOverride {
  93842. /**
  93843. * Gets or sets a value indicating if animation blending must be used
  93844. */
  93845. enableBlending: boolean;
  93846. /**
  93847. * Gets or sets the blending speed to use when enableBlending is true
  93848. */
  93849. blendingSpeed: number;
  93850. /**
  93851. * Gets or sets the default loop mode to use
  93852. */
  93853. loopMode: number;
  93854. }
  93855. }
  93856. declare module BABYLON {
  93857. /**
  93858. * Class used to store bone information
  93859. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93860. */
  93861. export class Bone extends Node {
  93862. /**
  93863. * defines the bone name
  93864. */
  93865. name: string;
  93866. private static _tmpVecs;
  93867. private static _tmpQuat;
  93868. private static _tmpMats;
  93869. /**
  93870. * Gets the list of child bones
  93871. */
  93872. children: Bone[];
  93873. /** Gets the animations associated with this bone */
  93874. animations: Animation[];
  93875. /**
  93876. * Gets or sets bone length
  93877. */
  93878. length: number;
  93879. /**
  93880. * @hidden Internal only
  93881. * Set this value to map this bone to a different index in the transform matrices
  93882. * Set this value to -1 to exclude the bone from the transform matrices
  93883. */
  93884. _index: Nullable<number>;
  93885. private _skeleton;
  93886. private _localMatrix;
  93887. private _restPose;
  93888. private _baseMatrix;
  93889. private _absoluteTransform;
  93890. private _invertedAbsoluteTransform;
  93891. private _parent;
  93892. private _scalingDeterminant;
  93893. private _worldTransform;
  93894. private _localScaling;
  93895. private _localRotation;
  93896. private _localPosition;
  93897. private _needToDecompose;
  93898. private _needToCompose;
  93899. /** @hidden */
  93900. _linkedTransformNode: Nullable<TransformNode>;
  93901. /** @hidden */
  93902. _waitingTransformNodeId: Nullable<string>;
  93903. /** @hidden */
  93904. get _matrix(): Matrix;
  93905. /** @hidden */
  93906. set _matrix(value: Matrix);
  93907. /**
  93908. * Create a new bone
  93909. * @param name defines the bone name
  93910. * @param skeleton defines the parent skeleton
  93911. * @param parentBone defines the parent (can be null if the bone is the root)
  93912. * @param localMatrix defines the local matrix
  93913. * @param restPose defines the rest pose matrix
  93914. * @param baseMatrix defines the base matrix
  93915. * @param index defines index of the bone in the hiearchy
  93916. */
  93917. constructor(
  93918. /**
  93919. * defines the bone name
  93920. */
  93921. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93922. /**
  93923. * Gets the current object class name.
  93924. * @return the class name
  93925. */
  93926. getClassName(): string;
  93927. /**
  93928. * Gets the parent skeleton
  93929. * @returns a skeleton
  93930. */
  93931. getSkeleton(): Skeleton;
  93932. /**
  93933. * Gets parent bone
  93934. * @returns a bone or null if the bone is the root of the bone hierarchy
  93935. */
  93936. getParent(): Nullable<Bone>;
  93937. /**
  93938. * Returns an array containing the root bones
  93939. * @returns an array containing the root bones
  93940. */
  93941. getChildren(): Array<Bone>;
  93942. /**
  93943. * Gets the node index in matrix array generated for rendering
  93944. * @returns the node index
  93945. */
  93946. getIndex(): number;
  93947. /**
  93948. * Sets the parent bone
  93949. * @param parent defines the parent (can be null if the bone is the root)
  93950. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93951. */
  93952. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93953. /**
  93954. * Gets the local matrix
  93955. * @returns a matrix
  93956. */
  93957. getLocalMatrix(): Matrix;
  93958. /**
  93959. * Gets the base matrix (initial matrix which remains unchanged)
  93960. * @returns a matrix
  93961. */
  93962. getBaseMatrix(): Matrix;
  93963. /**
  93964. * Gets the rest pose matrix
  93965. * @returns a matrix
  93966. */
  93967. getRestPose(): Matrix;
  93968. /**
  93969. * Sets the rest pose matrix
  93970. * @param matrix the local-space rest pose to set for this bone
  93971. */
  93972. setRestPose(matrix: Matrix): void;
  93973. /**
  93974. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93975. */
  93976. getWorldMatrix(): Matrix;
  93977. /**
  93978. * Sets the local matrix to rest pose matrix
  93979. */
  93980. returnToRest(): void;
  93981. /**
  93982. * Gets the inverse of the absolute transform matrix.
  93983. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93984. * @returns a matrix
  93985. */
  93986. getInvertedAbsoluteTransform(): Matrix;
  93987. /**
  93988. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93989. * @returns a matrix
  93990. */
  93991. getAbsoluteTransform(): Matrix;
  93992. /**
  93993. * Links with the given transform node.
  93994. * The local matrix of this bone is copied from the transform node every frame.
  93995. * @param transformNode defines the transform node to link to
  93996. */
  93997. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93998. /**
  93999. * Gets the node used to drive the bone's transformation
  94000. * @returns a transform node or null
  94001. */
  94002. getTransformNode(): Nullable<TransformNode>;
  94003. /** Gets or sets current position (in local space) */
  94004. get position(): Vector3;
  94005. set position(newPosition: Vector3);
  94006. /** Gets or sets current rotation (in local space) */
  94007. get rotation(): Vector3;
  94008. set rotation(newRotation: Vector3);
  94009. /** Gets or sets current rotation quaternion (in local space) */
  94010. get rotationQuaternion(): Quaternion;
  94011. set rotationQuaternion(newRotation: Quaternion);
  94012. /** Gets or sets current scaling (in local space) */
  94013. get scaling(): Vector3;
  94014. set scaling(newScaling: Vector3);
  94015. /**
  94016. * Gets the animation properties override
  94017. */
  94018. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94019. private _decompose;
  94020. private _compose;
  94021. /**
  94022. * Update the base and local matrices
  94023. * @param matrix defines the new base or local matrix
  94024. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94025. * @param updateLocalMatrix defines if the local matrix should be updated
  94026. */
  94027. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94028. /** @hidden */
  94029. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94030. /**
  94031. * Flag the bone as dirty (Forcing it to update everything)
  94032. */
  94033. markAsDirty(): void;
  94034. /** @hidden */
  94035. _markAsDirtyAndCompose(): void;
  94036. private _markAsDirtyAndDecompose;
  94037. /**
  94038. * Translate the bone in local or world space
  94039. * @param vec The amount to translate the bone
  94040. * @param space The space that the translation is in
  94041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94042. */
  94043. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94044. /**
  94045. * Set the postion of the bone in local or world space
  94046. * @param position The position to set the bone
  94047. * @param space The space that the position is in
  94048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94049. */
  94050. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94051. /**
  94052. * Set the absolute position of the bone (world space)
  94053. * @param position The position to set the bone
  94054. * @param mesh The mesh that this bone is attached to
  94055. */
  94056. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94057. /**
  94058. * Scale the bone on the x, y and z axes (in local space)
  94059. * @param x The amount to scale the bone on the x axis
  94060. * @param y The amount to scale the bone on the y axis
  94061. * @param z The amount to scale the bone on the z axis
  94062. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  94063. */
  94064. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  94065. /**
  94066. * Set the bone scaling in local space
  94067. * @param scale defines the scaling vector
  94068. */
  94069. setScale(scale: Vector3): void;
  94070. /**
  94071. * Gets the current scaling in local space
  94072. * @returns the current scaling vector
  94073. */
  94074. getScale(): Vector3;
  94075. /**
  94076. * Gets the current scaling in local space and stores it in a target vector
  94077. * @param result defines the target vector
  94078. */
  94079. getScaleToRef(result: Vector3): void;
  94080. /**
  94081. * Set the yaw, pitch, and roll of the bone in local or world space
  94082. * @param yaw The rotation of the bone on the y axis
  94083. * @param pitch The rotation of the bone on the x axis
  94084. * @param roll The rotation of the bone on the z axis
  94085. * @param space The space that the axes of rotation are in
  94086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94087. */
  94088. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  94089. /**
  94090. * Add a rotation to the bone on an axis in local or world space
  94091. * @param axis The axis to rotate the bone on
  94092. * @param amount The amount to rotate the bone
  94093. * @param space The space that the axis is in
  94094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94095. */
  94096. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  94097. /**
  94098. * Set the rotation of the bone to a particular axis angle in local or world space
  94099. * @param axis The axis to rotate the bone on
  94100. * @param angle The angle that the bone should be rotated to
  94101. * @param space The space that the axis is in
  94102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94103. */
  94104. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  94105. /**
  94106. * Set the euler rotation of the bone in local of world space
  94107. * @param rotation The euler rotation that the bone should be set to
  94108. * @param space The space that the rotation is in
  94109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94110. */
  94111. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94112. /**
  94113. * Set the quaternion rotation of the bone in local of world space
  94114. * @param quat The quaternion rotation that the bone should be set to
  94115. * @param space The space that the rotation is in
  94116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94117. */
  94118. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  94119. /**
  94120. * Set the rotation matrix of the bone in local of world space
  94121. * @param rotMat The rotation matrix that the bone should be set to
  94122. * @param space The space that the rotation is in
  94123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94124. */
  94125. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  94126. private _rotateWithMatrix;
  94127. private _getNegativeRotationToRef;
  94128. /**
  94129. * Get the position of the bone in local or world space
  94130. * @param space The space that the returned position is in
  94131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94132. * @returns The position of the bone
  94133. */
  94134. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94135. /**
  94136. * Copy the position of the bone to a vector3 in local or world space
  94137. * @param space The space that the returned position is in
  94138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94139. * @param result The vector3 to copy the position to
  94140. */
  94141. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  94142. /**
  94143. * Get the absolute position of the bone (world space)
  94144. * @param mesh The mesh that this bone is attached to
  94145. * @returns The absolute position of the bone
  94146. */
  94147. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  94148. /**
  94149. * Copy the absolute position of the bone (world space) to the result param
  94150. * @param mesh The mesh that this bone is attached to
  94151. * @param result The vector3 to copy the absolute position to
  94152. */
  94153. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  94154. /**
  94155. * Compute the absolute transforms of this bone and its children
  94156. */
  94157. computeAbsoluteTransforms(): void;
  94158. /**
  94159. * Get the world direction from an axis that is in the local space of the bone
  94160. * @param localAxis The local direction that is used to compute the world direction
  94161. * @param mesh The mesh that this bone is attached to
  94162. * @returns The world direction
  94163. */
  94164. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94165. /**
  94166. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  94167. * @param localAxis The local direction that is used to compute the world direction
  94168. * @param mesh The mesh that this bone is attached to
  94169. * @param result The vector3 that the world direction will be copied to
  94170. */
  94171. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94172. /**
  94173. * Get the euler rotation of the bone in local or world space
  94174. * @param space The space that the rotation should be in
  94175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94176. * @returns The euler rotation
  94177. */
  94178. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94179. /**
  94180. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  94181. * @param space The space that the rotation should be in
  94182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94183. * @param result The vector3 that the rotation should be copied to
  94184. */
  94185. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94186. /**
  94187. * Get the quaternion rotation of the bone in either local or world space
  94188. * @param space The space that the rotation should be in
  94189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94190. * @returns The quaternion rotation
  94191. */
  94192. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  94193. /**
  94194. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  94195. * @param space The space that the rotation should be in
  94196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94197. * @param result The quaternion that the rotation should be copied to
  94198. */
  94199. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  94200. /**
  94201. * Get the rotation matrix of the bone in local or world space
  94202. * @param space The space that the rotation should be in
  94203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94204. * @returns The rotation matrix
  94205. */
  94206. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  94207. /**
  94208. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  94209. * @param space The space that the rotation should be in
  94210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94211. * @param result The quaternion that the rotation should be copied to
  94212. */
  94213. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  94214. /**
  94215. * Get the world position of a point that is in the local space of the bone
  94216. * @param position The local position
  94217. * @param mesh The mesh that this bone is attached to
  94218. * @returns The world position
  94219. */
  94220. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94221. /**
  94222. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  94223. * @param position The local position
  94224. * @param mesh The mesh that this bone is attached to
  94225. * @param result The vector3 that the world position should be copied to
  94226. */
  94227. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94228. /**
  94229. * Get the local position of a point that is in world space
  94230. * @param position The world position
  94231. * @param mesh The mesh that this bone is attached to
  94232. * @returns The local position
  94233. */
  94234. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94235. /**
  94236. * Get the local position of a point that is in world space and copy it to the result param
  94237. * @param position The world position
  94238. * @param mesh The mesh that this bone is attached to
  94239. * @param result The vector3 that the local position should be copied to
  94240. */
  94241. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94242. }
  94243. }
  94244. declare module BABYLON {
  94245. /**
  94246. * Defines a runtime animation
  94247. */
  94248. export class RuntimeAnimation {
  94249. private _events;
  94250. /**
  94251. * The current frame of the runtime animation
  94252. */
  94253. private _currentFrame;
  94254. /**
  94255. * The animation used by the runtime animation
  94256. */
  94257. private _animation;
  94258. /**
  94259. * The target of the runtime animation
  94260. */
  94261. private _target;
  94262. /**
  94263. * The initiating animatable
  94264. */
  94265. private _host;
  94266. /**
  94267. * The original value of the runtime animation
  94268. */
  94269. private _originalValue;
  94270. /**
  94271. * The original blend value of the runtime animation
  94272. */
  94273. private _originalBlendValue;
  94274. /**
  94275. * The offsets cache of the runtime animation
  94276. */
  94277. private _offsetsCache;
  94278. /**
  94279. * The high limits cache of the runtime animation
  94280. */
  94281. private _highLimitsCache;
  94282. /**
  94283. * Specifies if the runtime animation has been stopped
  94284. */
  94285. private _stopped;
  94286. /**
  94287. * The blending factor of the runtime animation
  94288. */
  94289. private _blendingFactor;
  94290. /**
  94291. * The BabylonJS scene
  94292. */
  94293. private _scene;
  94294. /**
  94295. * The current value of the runtime animation
  94296. */
  94297. private _currentValue;
  94298. /** @hidden */
  94299. _animationState: _IAnimationState;
  94300. /**
  94301. * The active target of the runtime animation
  94302. */
  94303. private _activeTargets;
  94304. private _currentActiveTarget;
  94305. private _directTarget;
  94306. /**
  94307. * The target path of the runtime animation
  94308. */
  94309. private _targetPath;
  94310. /**
  94311. * The weight of the runtime animation
  94312. */
  94313. private _weight;
  94314. /**
  94315. * The ratio offset of the runtime animation
  94316. */
  94317. private _ratioOffset;
  94318. /**
  94319. * The previous delay of the runtime animation
  94320. */
  94321. private _previousDelay;
  94322. /**
  94323. * The previous ratio of the runtime animation
  94324. */
  94325. private _previousRatio;
  94326. private _enableBlending;
  94327. private _keys;
  94328. private _minFrame;
  94329. private _maxFrame;
  94330. private _minValue;
  94331. private _maxValue;
  94332. private _targetIsArray;
  94333. /**
  94334. * Gets the current frame of the runtime animation
  94335. */
  94336. get currentFrame(): number;
  94337. /**
  94338. * Gets the weight of the runtime animation
  94339. */
  94340. get weight(): number;
  94341. /**
  94342. * Gets the current value of the runtime animation
  94343. */
  94344. get currentValue(): any;
  94345. /**
  94346. * Gets the target path of the runtime animation
  94347. */
  94348. get targetPath(): string;
  94349. /**
  94350. * Gets the actual target of the runtime animation
  94351. */
  94352. get target(): any;
  94353. /**
  94354. * Gets the additive state of the runtime animation
  94355. */
  94356. get isAdditive(): boolean;
  94357. /** @hidden */
  94358. _onLoop: () => void;
  94359. /**
  94360. * Create a new RuntimeAnimation object
  94361. * @param target defines the target of the animation
  94362. * @param animation defines the source animation object
  94363. * @param scene defines the hosting scene
  94364. * @param host defines the initiating Animatable
  94365. */
  94366. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94367. private _preparePath;
  94368. /**
  94369. * Gets the animation from the runtime animation
  94370. */
  94371. get animation(): Animation;
  94372. /**
  94373. * Resets the runtime animation to the beginning
  94374. * @param restoreOriginal defines whether to restore the target property to the original value
  94375. */
  94376. reset(restoreOriginal?: boolean): void;
  94377. /**
  94378. * Specifies if the runtime animation is stopped
  94379. * @returns Boolean specifying if the runtime animation is stopped
  94380. */
  94381. isStopped(): boolean;
  94382. /**
  94383. * Disposes of the runtime animation
  94384. */
  94385. dispose(): void;
  94386. /**
  94387. * Apply the interpolated value to the target
  94388. * @param currentValue defines the value computed by the animation
  94389. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94390. */
  94391. setValue(currentValue: any, weight: number): void;
  94392. private _getOriginalValues;
  94393. private _setValue;
  94394. /**
  94395. * Gets the loop pmode of the runtime animation
  94396. * @returns Loop Mode
  94397. */
  94398. private _getCorrectLoopMode;
  94399. /**
  94400. * Move the current animation to a given frame
  94401. * @param frame defines the frame to move to
  94402. */
  94403. goToFrame(frame: number): void;
  94404. /**
  94405. * @hidden Internal use only
  94406. */
  94407. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94408. /**
  94409. * Execute the current animation
  94410. * @param delay defines the delay to add to the current frame
  94411. * @param from defines the lower bound of the animation range
  94412. * @param to defines the upper bound of the animation range
  94413. * @param loop defines if the current animation must loop
  94414. * @param speedRatio defines the current speed ratio
  94415. * @param weight defines the weight of the animation (default is -1 so no weight)
  94416. * @param onLoop optional callback called when animation loops
  94417. * @returns a boolean indicating if the animation is running
  94418. */
  94419. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94420. }
  94421. }
  94422. declare module BABYLON {
  94423. /**
  94424. * Class used to store an actual running animation
  94425. */
  94426. export class Animatable {
  94427. /** defines the target object */
  94428. target: any;
  94429. /** defines the starting frame number (default is 0) */
  94430. fromFrame: number;
  94431. /** defines the ending frame number (default is 100) */
  94432. toFrame: number;
  94433. /** defines if the animation must loop (default is false) */
  94434. loopAnimation: boolean;
  94435. /** defines a callback to call when animation ends if it is not looping */
  94436. onAnimationEnd?: (() => void) | null | undefined;
  94437. /** defines a callback to call when animation loops */
  94438. onAnimationLoop?: (() => void) | null | undefined;
  94439. /** defines whether the animation should be evaluated additively */
  94440. isAdditive: boolean;
  94441. private _localDelayOffset;
  94442. private _pausedDelay;
  94443. private _runtimeAnimations;
  94444. private _paused;
  94445. private _scene;
  94446. private _speedRatio;
  94447. private _weight;
  94448. private _syncRoot;
  94449. /**
  94450. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94451. * This will only apply for non looping animation (default is true)
  94452. */
  94453. disposeOnEnd: boolean;
  94454. /**
  94455. * Gets a boolean indicating if the animation has started
  94456. */
  94457. animationStarted: boolean;
  94458. /**
  94459. * Observer raised when the animation ends
  94460. */
  94461. onAnimationEndObservable: Observable<Animatable>;
  94462. /**
  94463. * Observer raised when the animation loops
  94464. */
  94465. onAnimationLoopObservable: Observable<Animatable>;
  94466. /**
  94467. * Gets the root Animatable used to synchronize and normalize animations
  94468. */
  94469. get syncRoot(): Nullable<Animatable>;
  94470. /**
  94471. * Gets the current frame of the first RuntimeAnimation
  94472. * Used to synchronize Animatables
  94473. */
  94474. get masterFrame(): number;
  94475. /**
  94476. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  94477. */
  94478. get weight(): number;
  94479. set weight(value: number);
  94480. /**
  94481. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  94482. */
  94483. get speedRatio(): number;
  94484. set speedRatio(value: number);
  94485. /**
  94486. * Creates a new Animatable
  94487. * @param scene defines the hosting scene
  94488. * @param target defines the target object
  94489. * @param fromFrame defines the starting frame number (default is 0)
  94490. * @param toFrame defines the ending frame number (default is 100)
  94491. * @param loopAnimation defines if the animation must loop (default is false)
  94492. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  94493. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  94494. * @param animations defines a group of animation to add to the new Animatable
  94495. * @param onAnimationLoop defines a callback to call when animation loops
  94496. * @param isAdditive defines whether the animation should be evaluated additively
  94497. */
  94498. constructor(scene: Scene,
  94499. /** defines the target object */
  94500. target: any,
  94501. /** defines the starting frame number (default is 0) */
  94502. fromFrame?: number,
  94503. /** defines the ending frame number (default is 100) */
  94504. toFrame?: number,
  94505. /** defines if the animation must loop (default is false) */
  94506. loopAnimation?: boolean, speedRatio?: number,
  94507. /** defines a callback to call when animation ends if it is not looping */
  94508. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  94509. /** defines a callback to call when animation loops */
  94510. onAnimationLoop?: (() => void) | null | undefined,
  94511. /** defines whether the animation should be evaluated additively */
  94512. isAdditive?: boolean);
  94513. /**
  94514. * Synchronize and normalize current Animatable with a source Animatable
  94515. * This is useful when using animation weights and when animations are not of the same length
  94516. * @param root defines the root Animatable to synchronize with
  94517. * @returns the current Animatable
  94518. */
  94519. syncWith(root: Animatable): Animatable;
  94520. /**
  94521. * Gets the list of runtime animations
  94522. * @returns an array of RuntimeAnimation
  94523. */
  94524. getAnimations(): RuntimeAnimation[];
  94525. /**
  94526. * Adds more animations to the current animatable
  94527. * @param target defines the target of the animations
  94528. * @param animations defines the new animations to add
  94529. */
  94530. appendAnimations(target: any, animations: Animation[]): void;
  94531. /**
  94532. * Gets the source animation for a specific property
  94533. * @param property defines the propertyu to look for
  94534. * @returns null or the source animation for the given property
  94535. */
  94536. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  94537. /**
  94538. * Gets the runtime animation for a specific property
  94539. * @param property defines the propertyu to look for
  94540. * @returns null or the runtime animation for the given property
  94541. */
  94542. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  94543. /**
  94544. * Resets the animatable to its original state
  94545. */
  94546. reset(): void;
  94547. /**
  94548. * Allows the animatable to blend with current running animations
  94549. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94550. * @param blendingSpeed defines the blending speed to use
  94551. */
  94552. enableBlending(blendingSpeed: number): void;
  94553. /**
  94554. * Disable animation blending
  94555. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94556. */
  94557. disableBlending(): void;
  94558. /**
  94559. * Jump directly to a given frame
  94560. * @param frame defines the frame to jump to
  94561. */
  94562. goToFrame(frame: number): void;
  94563. /**
  94564. * Pause the animation
  94565. */
  94566. pause(): void;
  94567. /**
  94568. * Restart the animation
  94569. */
  94570. restart(): void;
  94571. private _raiseOnAnimationEnd;
  94572. /**
  94573. * Stop and delete the current animation
  94574. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  94575. * @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)
  94576. */
  94577. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  94578. /**
  94579. * Wait asynchronously for the animation to end
  94580. * @returns a promise which will be fullfilled when the animation ends
  94581. */
  94582. waitAsync(): Promise<Animatable>;
  94583. /** @hidden */
  94584. _animate(delay: number): boolean;
  94585. }
  94586. interface Scene {
  94587. /** @hidden */
  94588. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94589. /** @hidden */
  94590. _processLateAnimationBindingsForMatrices(holder: {
  94591. totalWeight: number;
  94592. totalAdditiveWeight: number;
  94593. animations: RuntimeAnimation[];
  94594. additiveAnimations: RuntimeAnimation[];
  94595. originalValue: Matrix;
  94596. }): any;
  94597. /** @hidden */
  94598. _processLateAnimationBindingsForQuaternions(holder: {
  94599. totalWeight: number;
  94600. totalAdditiveWeight: number;
  94601. animations: RuntimeAnimation[];
  94602. additiveAnimations: RuntimeAnimation[];
  94603. originalValue: Quaternion;
  94604. }, refQuaternion: Quaternion): Quaternion;
  94605. /** @hidden */
  94606. _processLateAnimationBindings(): void;
  94607. /**
  94608. * Will start the animation sequence of a given target
  94609. * @param target defines the target
  94610. * @param from defines from which frame should animation start
  94611. * @param to defines until which frame should animation run.
  94612. * @param weight defines the weight to apply to the animation (1.0 by default)
  94613. * @param loop defines if the animation loops
  94614. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94615. * @param onAnimationEnd defines the function to be executed when the animation ends
  94616. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94617. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94618. * @param onAnimationLoop defines the callback to call when an animation loops
  94619. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94620. * @returns the animatable object created for this animation
  94621. */
  94622. 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;
  94623. /**
  94624. * Will start the animation sequence of a given target
  94625. * @param target defines the target
  94626. * @param from defines from which frame should animation start
  94627. * @param to defines until which frame should animation run.
  94628. * @param loop defines if the animation loops
  94629. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94630. * @param onAnimationEnd defines the function to be executed when the animation ends
  94631. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94632. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94633. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94634. * @param onAnimationLoop defines the callback to call when an animation loops
  94635. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94636. * @returns the animatable object created for this animation
  94637. */
  94638. 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;
  94639. /**
  94640. * Will start the animation sequence of a given target and its hierarchy
  94641. * @param target defines the target
  94642. * @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.
  94643. * @param from defines from which frame should animation start
  94644. * @param to defines until which frame should animation run.
  94645. * @param loop defines if the animation loops
  94646. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94647. * @param onAnimationEnd defines the function to be executed when the animation ends
  94648. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94649. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94650. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94651. * @param onAnimationLoop defines the callback to call when an animation loops
  94652. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94653. * @returns the list of created animatables
  94654. */
  94655. 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[];
  94656. /**
  94657. * Begin a new animation on a given node
  94658. * @param target defines the target where the animation will take place
  94659. * @param animations defines the list of animations to start
  94660. * @param from defines the initial value
  94661. * @param to defines the final value
  94662. * @param loop defines if you want animation to loop (off by default)
  94663. * @param speedRatio defines the speed ratio to apply to all animations
  94664. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94665. * @param onAnimationLoop defines the callback to call when an animation loops
  94666. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94667. * @returns the list of created animatables
  94668. */
  94669. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94670. /**
  94671. * Begin a new animation on a given node and its hierarchy
  94672. * @param target defines the root node where the animation will take place
  94673. * @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.
  94674. * @param animations defines the list of animations to start
  94675. * @param from defines the initial value
  94676. * @param to defines the final value
  94677. * @param loop defines if you want animation to loop (off by default)
  94678. * @param speedRatio defines the speed ratio to apply to all animations
  94679. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94680. * @param onAnimationLoop defines the callback to call when an animation loops
  94681. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94682. * @returns the list of animatables created for all nodes
  94683. */
  94684. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94685. /**
  94686. * Gets the animatable associated with a specific target
  94687. * @param target defines the target of the animatable
  94688. * @returns the required animatable if found
  94689. */
  94690. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94691. /**
  94692. * Gets all animatables associated with a given target
  94693. * @param target defines the target to look animatables for
  94694. * @returns an array of Animatables
  94695. */
  94696. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94697. /**
  94698. * Stops and removes all animations that have been applied to the scene
  94699. */
  94700. stopAllAnimations(): void;
  94701. /**
  94702. * Gets the current delta time used by animation engine
  94703. */
  94704. deltaTime: number;
  94705. }
  94706. interface Bone {
  94707. /**
  94708. * Copy an animation range from another bone
  94709. * @param source defines the source bone
  94710. * @param rangeName defines the range name to copy
  94711. * @param frameOffset defines the frame offset
  94712. * @param rescaleAsRequired defines if rescaling must be applied if required
  94713. * @param skelDimensionsRatio defines the scaling ratio
  94714. * @returns true if operation was successful
  94715. */
  94716. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94717. }
  94718. }
  94719. declare module BABYLON {
  94720. /**
  94721. * Class used to handle skinning animations
  94722. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94723. */
  94724. export class Skeleton implements IAnimatable {
  94725. /** defines the skeleton name */
  94726. name: string;
  94727. /** defines the skeleton Id */
  94728. id: string;
  94729. /**
  94730. * Defines the list of child bones
  94731. */
  94732. bones: Bone[];
  94733. /**
  94734. * Defines an estimate of the dimension of the skeleton at rest
  94735. */
  94736. dimensionsAtRest: Vector3;
  94737. /**
  94738. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94739. */
  94740. needInitialSkinMatrix: boolean;
  94741. /**
  94742. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94743. */
  94744. overrideMesh: Nullable<AbstractMesh>;
  94745. /**
  94746. * Gets the list of animations attached to this skeleton
  94747. */
  94748. animations: Array<Animation>;
  94749. private _scene;
  94750. private _isDirty;
  94751. private _transformMatrices;
  94752. private _transformMatrixTexture;
  94753. private _meshesWithPoseMatrix;
  94754. private _animatables;
  94755. private _identity;
  94756. private _synchronizedWithMesh;
  94757. private _ranges;
  94758. private _lastAbsoluteTransformsUpdateId;
  94759. private _canUseTextureForBones;
  94760. private _uniqueId;
  94761. /** @hidden */
  94762. _numBonesWithLinkedTransformNode: number;
  94763. /** @hidden */
  94764. _hasWaitingData: Nullable<boolean>;
  94765. /**
  94766. * Specifies if the skeleton should be serialized
  94767. */
  94768. doNotSerialize: boolean;
  94769. private _useTextureToStoreBoneMatrices;
  94770. /**
  94771. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94772. * Please note that this option is not available if the hardware does not support it
  94773. */
  94774. get useTextureToStoreBoneMatrices(): boolean;
  94775. set useTextureToStoreBoneMatrices(value: boolean);
  94776. private _animationPropertiesOverride;
  94777. /**
  94778. * Gets or sets the animation properties override
  94779. */
  94780. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94781. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94782. /**
  94783. * List of inspectable custom properties (used by the Inspector)
  94784. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94785. */
  94786. inspectableCustomProperties: IInspectable[];
  94787. /**
  94788. * An observable triggered before computing the skeleton's matrices
  94789. */
  94790. onBeforeComputeObservable: Observable<Skeleton>;
  94791. /**
  94792. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94793. */
  94794. get isUsingTextureForMatrices(): boolean;
  94795. /**
  94796. * Gets the unique ID of this skeleton
  94797. */
  94798. get uniqueId(): number;
  94799. /**
  94800. * Creates a new skeleton
  94801. * @param name defines the skeleton name
  94802. * @param id defines the skeleton Id
  94803. * @param scene defines the hosting scene
  94804. */
  94805. constructor(
  94806. /** defines the skeleton name */
  94807. name: string,
  94808. /** defines the skeleton Id */
  94809. id: string, scene: Scene);
  94810. /**
  94811. * Gets the current object class name.
  94812. * @return the class name
  94813. */
  94814. getClassName(): string;
  94815. /**
  94816. * Returns an array containing the root bones
  94817. * @returns an array containing the root bones
  94818. */
  94819. getChildren(): Array<Bone>;
  94820. /**
  94821. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94822. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94823. * @returns a Float32Array containing matrices data
  94824. */
  94825. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94826. /**
  94827. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94828. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94829. * @returns a raw texture containing the data
  94830. */
  94831. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94832. /**
  94833. * Gets the current hosting scene
  94834. * @returns a scene object
  94835. */
  94836. getScene(): Scene;
  94837. /**
  94838. * Gets a string representing the current skeleton data
  94839. * @param fullDetails defines a boolean indicating if we want a verbose version
  94840. * @returns a string representing the current skeleton data
  94841. */
  94842. toString(fullDetails?: boolean): string;
  94843. /**
  94844. * Get bone's index searching by name
  94845. * @param name defines bone's name to search for
  94846. * @return the indice of the bone. Returns -1 if not found
  94847. */
  94848. getBoneIndexByName(name: string): number;
  94849. /**
  94850. * Creater a new animation range
  94851. * @param name defines the name of the range
  94852. * @param from defines the start key
  94853. * @param to defines the end key
  94854. */
  94855. createAnimationRange(name: string, from: number, to: number): void;
  94856. /**
  94857. * Delete a specific animation range
  94858. * @param name defines the name of the range
  94859. * @param deleteFrames defines if frames must be removed as well
  94860. */
  94861. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94862. /**
  94863. * Gets a specific animation range
  94864. * @param name defines the name of the range to look for
  94865. * @returns the requested animation range or null if not found
  94866. */
  94867. getAnimationRange(name: string): Nullable<AnimationRange>;
  94868. /**
  94869. * Gets the list of all animation ranges defined on this skeleton
  94870. * @returns an array
  94871. */
  94872. getAnimationRanges(): Nullable<AnimationRange>[];
  94873. /**
  94874. * Copy animation range from a source skeleton.
  94875. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94876. * @param source defines the source skeleton
  94877. * @param name defines the name of the range to copy
  94878. * @param rescaleAsRequired defines if rescaling must be applied if required
  94879. * @returns true if operation was successful
  94880. */
  94881. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94882. /**
  94883. * Forces the skeleton to go to rest pose
  94884. */
  94885. returnToRest(): void;
  94886. private _getHighestAnimationFrame;
  94887. /**
  94888. * Begin a specific animation range
  94889. * @param name defines the name of the range to start
  94890. * @param loop defines if looping must be turned on (false by default)
  94891. * @param speedRatio defines the speed ratio to apply (1 by default)
  94892. * @param onAnimationEnd defines a callback which will be called when animation will end
  94893. * @returns a new animatable
  94894. */
  94895. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94896. /**
  94897. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94898. * @param skeleton defines the Skeleton containing the animation range to convert
  94899. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94900. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94901. * @returns the original skeleton
  94902. */
  94903. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94904. /** @hidden */
  94905. _markAsDirty(): void;
  94906. /** @hidden */
  94907. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94908. /** @hidden */
  94909. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94910. private _computeTransformMatrices;
  94911. /**
  94912. * Build all resources required to render a skeleton
  94913. */
  94914. prepare(): void;
  94915. /**
  94916. * Gets the list of animatables currently running for this skeleton
  94917. * @returns an array of animatables
  94918. */
  94919. getAnimatables(): IAnimatable[];
  94920. /**
  94921. * Clone the current skeleton
  94922. * @param name defines the name of the new skeleton
  94923. * @param id defines the id of the new skeleton
  94924. * @returns the new skeleton
  94925. */
  94926. clone(name: string, id?: string): Skeleton;
  94927. /**
  94928. * Enable animation blending for this skeleton
  94929. * @param blendingSpeed defines the blending speed to apply
  94930. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94931. */
  94932. enableBlending(blendingSpeed?: number): void;
  94933. /**
  94934. * Releases all resources associated with the current skeleton
  94935. */
  94936. dispose(): void;
  94937. /**
  94938. * Serialize the skeleton in a JSON object
  94939. * @returns a JSON object
  94940. */
  94941. serialize(): any;
  94942. /**
  94943. * Creates a new skeleton from serialized data
  94944. * @param parsedSkeleton defines the serialized data
  94945. * @param scene defines the hosting scene
  94946. * @returns a new skeleton
  94947. */
  94948. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94949. /**
  94950. * Compute all node absolute transforms
  94951. * @param forceUpdate defines if computation must be done even if cache is up to date
  94952. */
  94953. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94954. /**
  94955. * Gets the root pose matrix
  94956. * @returns a matrix
  94957. */
  94958. getPoseMatrix(): Nullable<Matrix>;
  94959. /**
  94960. * Sorts bones per internal index
  94961. */
  94962. sortBones(): void;
  94963. private _sortBones;
  94964. }
  94965. }
  94966. declare module BABYLON {
  94967. /**
  94968. * Creates an instance based on a source mesh.
  94969. */
  94970. export class InstancedMesh extends AbstractMesh {
  94971. private _sourceMesh;
  94972. private _currentLOD;
  94973. /** @hidden */
  94974. _indexInSourceMeshInstanceArray: number;
  94975. constructor(name: string, source: Mesh);
  94976. /**
  94977. * Returns the string "InstancedMesh".
  94978. */
  94979. getClassName(): string;
  94980. /** Gets the list of lights affecting that mesh */
  94981. get lightSources(): Light[];
  94982. _resyncLightSources(): void;
  94983. _resyncLightSource(light: Light): void;
  94984. _removeLightSource(light: Light, dispose: boolean): void;
  94985. /**
  94986. * If the source mesh receives shadows
  94987. */
  94988. get receiveShadows(): boolean;
  94989. /**
  94990. * The material of the source mesh
  94991. */
  94992. get material(): Nullable<Material>;
  94993. /**
  94994. * Visibility of the source mesh
  94995. */
  94996. get visibility(): number;
  94997. /**
  94998. * Skeleton of the source mesh
  94999. */
  95000. get skeleton(): Nullable<Skeleton>;
  95001. /**
  95002. * Rendering ground id of the source mesh
  95003. */
  95004. get renderingGroupId(): number;
  95005. set renderingGroupId(value: number);
  95006. /**
  95007. * Returns the total number of vertices (integer).
  95008. */
  95009. getTotalVertices(): number;
  95010. /**
  95011. * Returns a positive integer : the total number of indices in this mesh geometry.
  95012. * @returns the numner of indices or zero if the mesh has no geometry.
  95013. */
  95014. getTotalIndices(): number;
  95015. /**
  95016. * The source mesh of the instance
  95017. */
  95018. get sourceMesh(): Mesh;
  95019. /**
  95020. * Creates a new InstancedMesh object from the mesh model.
  95021. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95022. * @param name defines the name of the new instance
  95023. * @returns a new InstancedMesh
  95024. */
  95025. createInstance(name: string): InstancedMesh;
  95026. /**
  95027. * Is this node ready to be used/rendered
  95028. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95029. * @return {boolean} is it ready
  95030. */
  95031. isReady(completeCheck?: boolean): boolean;
  95032. /**
  95033. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95034. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95035. * @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.
  95036. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95037. */
  95038. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95039. /**
  95040. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95041. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95042. * The `data` are either a numeric array either a Float32Array.
  95043. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95044. * 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).
  95045. * Note that a new underlying VertexBuffer object is created each call.
  95046. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95047. *
  95048. * Possible `kind` values :
  95049. * - VertexBuffer.PositionKind
  95050. * - VertexBuffer.UVKind
  95051. * - VertexBuffer.UV2Kind
  95052. * - VertexBuffer.UV3Kind
  95053. * - VertexBuffer.UV4Kind
  95054. * - VertexBuffer.UV5Kind
  95055. * - VertexBuffer.UV6Kind
  95056. * - VertexBuffer.ColorKind
  95057. * - VertexBuffer.MatricesIndicesKind
  95058. * - VertexBuffer.MatricesIndicesExtraKind
  95059. * - VertexBuffer.MatricesWeightsKind
  95060. * - VertexBuffer.MatricesWeightsExtraKind
  95061. *
  95062. * Returns the Mesh.
  95063. */
  95064. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95065. /**
  95066. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95067. * If the mesh has no geometry, it is simply returned as it is.
  95068. * The `data` are either a numeric array either a Float32Array.
  95069. * No new underlying VertexBuffer object is created.
  95070. * 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.
  95071. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  95072. *
  95073. * Possible `kind` values :
  95074. * - VertexBuffer.PositionKind
  95075. * - VertexBuffer.UVKind
  95076. * - VertexBuffer.UV2Kind
  95077. * - VertexBuffer.UV3Kind
  95078. * - VertexBuffer.UV4Kind
  95079. * - VertexBuffer.UV5Kind
  95080. * - VertexBuffer.UV6Kind
  95081. * - VertexBuffer.ColorKind
  95082. * - VertexBuffer.MatricesIndicesKind
  95083. * - VertexBuffer.MatricesIndicesExtraKind
  95084. * - VertexBuffer.MatricesWeightsKind
  95085. * - VertexBuffer.MatricesWeightsExtraKind
  95086. *
  95087. * Returns the Mesh.
  95088. */
  95089. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  95090. /**
  95091. * Sets the mesh indices.
  95092. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  95093. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95094. * This method creates a new index buffer each call.
  95095. * Returns the Mesh.
  95096. */
  95097. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  95098. /**
  95099. * Boolean : True if the mesh owns the requested kind of data.
  95100. */
  95101. isVerticesDataPresent(kind: string): boolean;
  95102. /**
  95103. * Returns an array of indices (IndicesArray).
  95104. */
  95105. getIndices(): Nullable<IndicesArray>;
  95106. get _positions(): Nullable<Vector3[]>;
  95107. /**
  95108. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95109. * This means the mesh underlying bounding box and sphere are recomputed.
  95110. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95111. * @returns the current mesh
  95112. */
  95113. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  95114. /** @hidden */
  95115. _preActivate(): InstancedMesh;
  95116. /** @hidden */
  95117. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95118. /** @hidden */
  95119. _postActivate(): void;
  95120. getWorldMatrix(): Matrix;
  95121. get isAnInstance(): boolean;
  95122. /**
  95123. * Returns the current associated LOD AbstractMesh.
  95124. */
  95125. getLOD(camera: Camera): AbstractMesh;
  95126. /** @hidden */
  95127. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95128. /** @hidden */
  95129. _syncSubMeshes(): InstancedMesh;
  95130. /** @hidden */
  95131. _generatePointsArray(): boolean;
  95132. /**
  95133. * Creates a new InstancedMesh from the current mesh.
  95134. * - name (string) : the cloned mesh name
  95135. * - newParent (optional Node) : the optional Node to parent the clone to.
  95136. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  95137. *
  95138. * Returns the clone.
  95139. */
  95140. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  95141. /**
  95142. * Disposes the InstancedMesh.
  95143. * Returns nothing.
  95144. */
  95145. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95146. }
  95147. interface Mesh {
  95148. /**
  95149. * Register a custom buffer that will be instanced
  95150. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95151. * @param kind defines the buffer kind
  95152. * @param stride defines the stride in floats
  95153. */
  95154. registerInstancedBuffer(kind: string, stride: number): void;
  95155. /**
  95156. * true to use the edge renderer for all instances of this mesh
  95157. */
  95158. edgesShareWithInstances: boolean;
  95159. /** @hidden */
  95160. _userInstancedBuffersStorage: {
  95161. data: {
  95162. [key: string]: Float32Array;
  95163. };
  95164. sizes: {
  95165. [key: string]: number;
  95166. };
  95167. vertexBuffers: {
  95168. [key: string]: Nullable<VertexBuffer>;
  95169. };
  95170. strides: {
  95171. [key: string]: number;
  95172. };
  95173. };
  95174. }
  95175. interface AbstractMesh {
  95176. /**
  95177. * Object used to store instanced buffers defined by user
  95178. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95179. */
  95180. instancedBuffers: {
  95181. [key: string]: any;
  95182. };
  95183. }
  95184. }
  95185. declare module BABYLON {
  95186. /**
  95187. * Defines the options associated with the creation of a shader material.
  95188. */
  95189. export interface IShaderMaterialOptions {
  95190. /**
  95191. * Does the material work in alpha blend mode
  95192. */
  95193. needAlphaBlending: boolean;
  95194. /**
  95195. * Does the material work in alpha test mode
  95196. */
  95197. needAlphaTesting: boolean;
  95198. /**
  95199. * The list of attribute names used in the shader
  95200. */
  95201. attributes: string[];
  95202. /**
  95203. * The list of unifrom names used in the shader
  95204. */
  95205. uniforms: string[];
  95206. /**
  95207. * The list of UBO names used in the shader
  95208. */
  95209. uniformBuffers: string[];
  95210. /**
  95211. * The list of sampler names used in the shader
  95212. */
  95213. samplers: string[];
  95214. /**
  95215. * The list of defines used in the shader
  95216. */
  95217. defines: string[];
  95218. }
  95219. /**
  95220. * 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.
  95221. *
  95222. * This returned material effects how the mesh will look based on the code in the shaders.
  95223. *
  95224. * @see https://doc.babylonjs.com/how_to/shader_material
  95225. */
  95226. export class ShaderMaterial extends Material {
  95227. private _shaderPath;
  95228. private _options;
  95229. private _textures;
  95230. private _textureArrays;
  95231. private _floats;
  95232. private _ints;
  95233. private _floatsArrays;
  95234. private _colors3;
  95235. private _colors3Arrays;
  95236. private _colors4;
  95237. private _colors4Arrays;
  95238. private _vectors2;
  95239. private _vectors3;
  95240. private _vectors4;
  95241. private _matrices;
  95242. private _matrixArrays;
  95243. private _matrices3x3;
  95244. private _matrices2x2;
  95245. private _vectors2Arrays;
  95246. private _vectors3Arrays;
  95247. private _vectors4Arrays;
  95248. private _cachedWorldViewMatrix;
  95249. private _cachedWorldViewProjectionMatrix;
  95250. private _renderId;
  95251. private _multiview;
  95252. private _cachedDefines;
  95253. /** Define the Url to load snippets */
  95254. static SnippetUrl: string;
  95255. /** Snippet ID if the material was created from the snippet server */
  95256. snippetId: string;
  95257. /**
  95258. * Instantiate a new shader material.
  95259. * 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.
  95260. * This returned material effects how the mesh will look based on the code in the shaders.
  95261. * @see https://doc.babylonjs.com/how_to/shader_material
  95262. * @param name Define the name of the material in the scene
  95263. * @param scene Define the scene the material belongs to
  95264. * @param shaderPath Defines the route to the shader code in one of three ways:
  95265. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  95266. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  95267. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  95268. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  95269. * @param options Define the options used to create the shader
  95270. */
  95271. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  95272. /**
  95273. * Gets the shader path used to define the shader code
  95274. * It can be modified to trigger a new compilation
  95275. */
  95276. get shaderPath(): any;
  95277. /**
  95278. * Sets the shader path used to define the shader code
  95279. * It can be modified to trigger a new compilation
  95280. */
  95281. set shaderPath(shaderPath: any);
  95282. /**
  95283. * Gets the options used to compile the shader.
  95284. * They can be modified to trigger a new compilation
  95285. */
  95286. get options(): IShaderMaterialOptions;
  95287. /**
  95288. * Gets the current class name of the material e.g. "ShaderMaterial"
  95289. * Mainly use in serialization.
  95290. * @returns the class name
  95291. */
  95292. getClassName(): string;
  95293. /**
  95294. * Specifies if the material will require alpha blending
  95295. * @returns a boolean specifying if alpha blending is needed
  95296. */
  95297. needAlphaBlending(): boolean;
  95298. /**
  95299. * Specifies if this material should be rendered in alpha test mode
  95300. * @returns a boolean specifying if an alpha test is needed.
  95301. */
  95302. needAlphaTesting(): boolean;
  95303. private _checkUniform;
  95304. /**
  95305. * Set a texture in the shader.
  95306. * @param name Define the name of the uniform samplers as defined in the shader
  95307. * @param texture Define the texture to bind to this sampler
  95308. * @return the material itself allowing "fluent" like uniform updates
  95309. */
  95310. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  95311. /**
  95312. * Set a texture array in the shader.
  95313. * @param name Define the name of the uniform sampler array as defined in the shader
  95314. * @param textures Define the list of textures to bind to this sampler
  95315. * @return the material itself allowing "fluent" like uniform updates
  95316. */
  95317. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  95318. /**
  95319. * Set a float in the shader.
  95320. * @param name Define the name of the uniform as defined in the shader
  95321. * @param value Define the value to give to the uniform
  95322. * @return the material itself allowing "fluent" like uniform updates
  95323. */
  95324. setFloat(name: string, value: number): ShaderMaterial;
  95325. /**
  95326. * Set a int in the shader.
  95327. * @param name Define the name of the uniform as defined in the shader
  95328. * @param value Define the value to give to the uniform
  95329. * @return the material itself allowing "fluent" like uniform updates
  95330. */
  95331. setInt(name: string, value: number): ShaderMaterial;
  95332. /**
  95333. * Set an array of floats in the shader.
  95334. * @param name Define the name of the uniform as defined in the shader
  95335. * @param value Define the value to give to the uniform
  95336. * @return the material itself allowing "fluent" like uniform updates
  95337. */
  95338. setFloats(name: string, value: number[]): ShaderMaterial;
  95339. /**
  95340. * Set a vec3 in the shader from a Color3.
  95341. * @param name Define the name of the uniform as defined in the shader
  95342. * @param value Define the value to give to the uniform
  95343. * @return the material itself allowing "fluent" like uniform updates
  95344. */
  95345. setColor3(name: string, value: Color3): ShaderMaterial;
  95346. /**
  95347. * Set a vec3 array in the shader from a Color3 array.
  95348. * @param name Define the name of the uniform as defined in the shader
  95349. * @param value Define the value to give to the uniform
  95350. * @return the material itself allowing "fluent" like uniform updates
  95351. */
  95352. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  95353. /**
  95354. * Set a vec4 in the shader from a Color4.
  95355. * @param name Define the name of the uniform as defined in the shader
  95356. * @param value Define the value to give to the uniform
  95357. * @return the material itself allowing "fluent" like uniform updates
  95358. */
  95359. setColor4(name: string, value: Color4): ShaderMaterial;
  95360. /**
  95361. * Set a vec4 array in the shader from a Color4 array.
  95362. * @param name Define the name of the uniform as defined in the shader
  95363. * @param value Define the value to give to the uniform
  95364. * @return the material itself allowing "fluent" like uniform updates
  95365. */
  95366. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95367. /**
  95368. * Set a vec2 in the shader from a Vector2.
  95369. * @param name Define the name of the uniform as defined in the shader
  95370. * @param value Define the value to give to the uniform
  95371. * @return the material itself allowing "fluent" like uniform updates
  95372. */
  95373. setVector2(name: string, value: Vector2): ShaderMaterial;
  95374. /**
  95375. * Set a vec3 in the shader from a Vector3.
  95376. * @param name Define the name of the uniform as defined in the shader
  95377. * @param value Define the value to give to the uniform
  95378. * @return the material itself allowing "fluent" like uniform updates
  95379. */
  95380. setVector3(name: string, value: Vector3): ShaderMaterial;
  95381. /**
  95382. * Set a vec4 in the shader from a Vector4.
  95383. * @param name Define the name of the uniform as defined in the shader
  95384. * @param value Define the value to give to the uniform
  95385. * @return the material itself allowing "fluent" like uniform updates
  95386. */
  95387. setVector4(name: string, value: Vector4): ShaderMaterial;
  95388. /**
  95389. * Set a mat4 in the shader from a Matrix.
  95390. * @param name Define the name of the uniform as defined in the shader
  95391. * @param value Define the value to give to the uniform
  95392. * @return the material itself allowing "fluent" like uniform updates
  95393. */
  95394. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95395. /**
  95396. * Set a float32Array in the shader from a matrix array.
  95397. * @param name Define the name of the uniform as defined in the shader
  95398. * @param value Define the value to give to the uniform
  95399. * @return the material itself allowing "fluent" like uniform updates
  95400. */
  95401. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95402. /**
  95403. * Set a mat3 in the shader from a Float32Array.
  95404. * @param name Define the name of the uniform as defined in the shader
  95405. * @param value Define the value to give to the uniform
  95406. * @return the material itself allowing "fluent" like uniform updates
  95407. */
  95408. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95409. /**
  95410. * Set a mat2 in the shader from a Float32Array.
  95411. * @param name Define the name of the uniform as defined in the shader
  95412. * @param value Define the value to give to the uniform
  95413. * @return the material itself allowing "fluent" like uniform updates
  95414. */
  95415. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95416. /**
  95417. * Set a vec2 array in the shader from a number array.
  95418. * @param name Define the name of the uniform as defined in the shader
  95419. * @param value Define the value to give to the uniform
  95420. * @return the material itself allowing "fluent" like uniform updates
  95421. */
  95422. setArray2(name: string, value: number[]): ShaderMaterial;
  95423. /**
  95424. * Set a vec3 array in the shader from a number array.
  95425. * @param name Define the name of the uniform as defined in the shader
  95426. * @param value Define the value to give to the uniform
  95427. * @return the material itself allowing "fluent" like uniform updates
  95428. */
  95429. setArray3(name: string, value: number[]): ShaderMaterial;
  95430. /**
  95431. * Set a vec4 array in the shader from a number array.
  95432. * @param name Define the name of the uniform as defined in the shader
  95433. * @param value Define the value to give to the uniform
  95434. * @return the material itself allowing "fluent" like uniform updates
  95435. */
  95436. setArray4(name: string, value: number[]): ShaderMaterial;
  95437. private _checkCache;
  95438. /**
  95439. * Specifies that the submesh is ready to be used
  95440. * @param mesh defines the mesh to check
  95441. * @param subMesh defines which submesh to check
  95442. * @param useInstances specifies that instances should be used
  95443. * @returns a boolean indicating that the submesh is ready or not
  95444. */
  95445. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95446. /**
  95447. * Checks if the material is ready to render the requested mesh
  95448. * @param mesh Define the mesh to render
  95449. * @param useInstances Define whether or not the material is used with instances
  95450. * @returns true if ready, otherwise false
  95451. */
  95452. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95453. /**
  95454. * Binds the world matrix to the material
  95455. * @param world defines the world transformation matrix
  95456. * @param effectOverride - If provided, use this effect instead of internal effect
  95457. */
  95458. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  95459. /**
  95460. * Binds the submesh to this material by preparing the effect and shader to draw
  95461. * @param world defines the world transformation matrix
  95462. * @param mesh defines the mesh containing the submesh
  95463. * @param subMesh defines the submesh to bind the material to
  95464. */
  95465. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95466. /**
  95467. * Binds the material to the mesh
  95468. * @param world defines the world transformation matrix
  95469. * @param mesh defines the mesh to bind the material to
  95470. * @param effectOverride - If provided, use this effect instead of internal effect
  95471. */
  95472. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  95473. protected _afterBind(mesh?: Mesh): void;
  95474. /**
  95475. * Gets the active textures from the material
  95476. * @returns an array of textures
  95477. */
  95478. getActiveTextures(): BaseTexture[];
  95479. /**
  95480. * Specifies if the material uses a texture
  95481. * @param texture defines the texture to check against the material
  95482. * @returns a boolean specifying if the material uses the texture
  95483. */
  95484. hasTexture(texture: BaseTexture): boolean;
  95485. /**
  95486. * Makes a duplicate of the material, and gives it a new name
  95487. * @param name defines the new name for the duplicated material
  95488. * @returns the cloned material
  95489. */
  95490. clone(name: string): ShaderMaterial;
  95491. /**
  95492. * Disposes the material
  95493. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95494. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95495. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95496. */
  95497. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95498. /**
  95499. * Serializes this material in a JSON representation
  95500. * @returns the serialized material object
  95501. */
  95502. serialize(): any;
  95503. /**
  95504. * Creates a shader material from parsed shader material data
  95505. * @param source defines the JSON represnetation of the material
  95506. * @param scene defines the hosting scene
  95507. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95508. * @returns a new material
  95509. */
  95510. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  95511. /**
  95512. * Creates a new ShaderMaterial from a snippet saved in a remote file
  95513. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  95514. * @param url defines the url to load from
  95515. * @param scene defines the hosting scene
  95516. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95517. * @returns a promise that will resolve to the new ShaderMaterial
  95518. */
  95519. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95520. /**
  95521. * Creates a ShaderMaterial from a snippet saved by the Inspector
  95522. * @param snippetId defines the snippet to load
  95523. * @param scene defines the hosting scene
  95524. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95525. * @returns a promise that will resolve to the new ShaderMaterial
  95526. */
  95527. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95528. }
  95529. }
  95530. declare module BABYLON {
  95531. /** @hidden */
  95532. export var colorPixelShader: {
  95533. name: string;
  95534. shader: string;
  95535. };
  95536. }
  95537. declare module BABYLON {
  95538. /** @hidden */
  95539. export var colorVertexShader: {
  95540. name: string;
  95541. shader: string;
  95542. };
  95543. }
  95544. declare module BABYLON {
  95545. /**
  95546. * Line mesh
  95547. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  95548. */
  95549. export class LinesMesh extends Mesh {
  95550. /**
  95551. * If vertex color should be applied to the mesh
  95552. */
  95553. readonly useVertexColor?: boolean | undefined;
  95554. /**
  95555. * If vertex alpha should be applied to the mesh
  95556. */
  95557. readonly useVertexAlpha?: boolean | undefined;
  95558. /**
  95559. * Color of the line (Default: White)
  95560. */
  95561. color: Color3;
  95562. /**
  95563. * Alpha of the line (Default: 1)
  95564. */
  95565. alpha: number;
  95566. /**
  95567. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95568. * This margin is expressed in world space coordinates, so its value may vary.
  95569. * Default value is 0.1
  95570. */
  95571. intersectionThreshold: number;
  95572. private _colorShader;
  95573. private color4;
  95574. /**
  95575. * Creates a new LinesMesh
  95576. * @param name defines the name
  95577. * @param scene defines the hosting scene
  95578. * @param parent defines the parent mesh if any
  95579. * @param source defines the optional source LinesMesh used to clone data from
  95580. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95581. * When false, achieved by calling a clone(), also passing False.
  95582. * This will make creation of children, recursive.
  95583. * @param useVertexColor defines if this LinesMesh supports vertex color
  95584. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95585. */
  95586. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95587. /**
  95588. * If vertex color should be applied to the mesh
  95589. */
  95590. useVertexColor?: boolean | undefined,
  95591. /**
  95592. * If vertex alpha should be applied to the mesh
  95593. */
  95594. useVertexAlpha?: boolean | undefined);
  95595. private _addClipPlaneDefine;
  95596. private _removeClipPlaneDefine;
  95597. isReady(): boolean;
  95598. /**
  95599. * Returns the string "LineMesh"
  95600. */
  95601. getClassName(): string;
  95602. /**
  95603. * @hidden
  95604. */
  95605. get material(): Material;
  95606. /**
  95607. * @hidden
  95608. */
  95609. set material(value: Material);
  95610. /**
  95611. * @hidden
  95612. */
  95613. get checkCollisions(): boolean;
  95614. /** @hidden */
  95615. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95616. /** @hidden */
  95617. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95618. /**
  95619. * Disposes of the line mesh
  95620. * @param doNotRecurse If children should be disposed
  95621. */
  95622. dispose(doNotRecurse?: boolean): void;
  95623. /**
  95624. * Returns a new LineMesh object cloned from the current one.
  95625. */
  95626. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95627. /**
  95628. * Creates a new InstancedLinesMesh object from the mesh model.
  95629. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95630. * @param name defines the name of the new instance
  95631. * @returns a new InstancedLinesMesh
  95632. */
  95633. createInstance(name: string): InstancedLinesMesh;
  95634. }
  95635. /**
  95636. * Creates an instance based on a source LinesMesh
  95637. */
  95638. export class InstancedLinesMesh extends InstancedMesh {
  95639. /**
  95640. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95641. * This margin is expressed in world space coordinates, so its value may vary.
  95642. * Initilized with the intersectionThreshold value of the source LinesMesh
  95643. */
  95644. intersectionThreshold: number;
  95645. constructor(name: string, source: LinesMesh);
  95646. /**
  95647. * Returns the string "InstancedLinesMesh".
  95648. */
  95649. getClassName(): string;
  95650. }
  95651. }
  95652. declare module BABYLON {
  95653. /** @hidden */
  95654. export var linePixelShader: {
  95655. name: string;
  95656. shader: string;
  95657. };
  95658. }
  95659. declare module BABYLON {
  95660. /** @hidden */
  95661. export var lineVertexShader: {
  95662. name: string;
  95663. shader: string;
  95664. };
  95665. }
  95666. declare module BABYLON {
  95667. interface Scene {
  95668. /** @hidden */
  95669. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95670. }
  95671. interface AbstractMesh {
  95672. /**
  95673. * Gets the edgesRenderer associated with the mesh
  95674. */
  95675. edgesRenderer: Nullable<EdgesRenderer>;
  95676. }
  95677. interface LinesMesh {
  95678. /**
  95679. * Enables the edge rendering mode on the mesh.
  95680. * This mode makes the mesh edges visible
  95681. * @param epsilon defines the maximal distance between two angles to detect a face
  95682. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95683. * @returns the currentAbstractMesh
  95684. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95685. */
  95686. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95687. }
  95688. interface InstancedLinesMesh {
  95689. /**
  95690. * Enables the edge rendering mode on the mesh.
  95691. * This mode makes the mesh edges visible
  95692. * @param epsilon defines the maximal distance between two angles to detect a face
  95693. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95694. * @returns the current InstancedLinesMesh
  95695. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95696. */
  95697. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95698. }
  95699. /**
  95700. * Defines the minimum contract an Edges renderer should follow.
  95701. */
  95702. export interface IEdgesRenderer extends IDisposable {
  95703. /**
  95704. * Gets or sets a boolean indicating if the edgesRenderer is active
  95705. */
  95706. isEnabled: boolean;
  95707. /**
  95708. * Renders the edges of the attached mesh,
  95709. */
  95710. render(): void;
  95711. /**
  95712. * Checks wether or not the edges renderer is ready to render.
  95713. * @return true if ready, otherwise false.
  95714. */
  95715. isReady(): boolean;
  95716. /**
  95717. * List of instances to render in case the source mesh has instances
  95718. */
  95719. customInstances: SmartArray<Matrix>;
  95720. }
  95721. /**
  95722. * Defines the additional options of the edges renderer
  95723. */
  95724. export interface IEdgesRendererOptions {
  95725. /**
  95726. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95727. * If not defined, the default value is true
  95728. */
  95729. useAlternateEdgeFinder?: boolean;
  95730. /**
  95731. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95732. * If not defined, the default value is true.
  95733. * 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)
  95734. * This option is used only if useAlternateEdgeFinder = true
  95735. */
  95736. useFastVertexMerger?: boolean;
  95737. /**
  95738. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95739. * The default value is 1e-6
  95740. * This option is used only if useAlternateEdgeFinder = true
  95741. */
  95742. epsilonVertexMerge?: number;
  95743. /**
  95744. * 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
  95745. * 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.
  95746. * This option is used only if useAlternateEdgeFinder = true
  95747. */
  95748. applyTessellation?: boolean;
  95749. /**
  95750. * 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
  95751. * The default value is 1e-6
  95752. * This option is used only if useAlternateEdgeFinder = true
  95753. */
  95754. epsilonVertexAligned?: number;
  95755. }
  95756. /**
  95757. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  95758. */
  95759. export class EdgesRenderer implements IEdgesRenderer {
  95760. /**
  95761. * Define the size of the edges with an orthographic camera
  95762. */
  95763. edgesWidthScalerForOrthographic: number;
  95764. /**
  95765. * Define the size of the edges with a perspective camera
  95766. */
  95767. edgesWidthScalerForPerspective: number;
  95768. protected _source: AbstractMesh;
  95769. protected _linesPositions: number[];
  95770. protected _linesNormals: number[];
  95771. protected _linesIndices: number[];
  95772. protected _epsilon: number;
  95773. protected _indicesCount: number;
  95774. protected _lineShader: ShaderMaterial;
  95775. protected _ib: DataBuffer;
  95776. protected _buffers: {
  95777. [key: string]: Nullable<VertexBuffer>;
  95778. };
  95779. protected _buffersForInstances: {
  95780. [key: string]: Nullable<VertexBuffer>;
  95781. };
  95782. protected _checkVerticesInsteadOfIndices: boolean;
  95783. protected _options: Nullable<IEdgesRendererOptions>;
  95784. private _meshRebuildObserver;
  95785. private _meshDisposeObserver;
  95786. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95787. isEnabled: boolean;
  95788. /**
  95789. * List of instances to render in case the source mesh has instances
  95790. */
  95791. customInstances: SmartArray<Matrix>;
  95792. private static GetShader;
  95793. /**
  95794. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95795. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95796. * @param source Mesh used to create edges
  95797. * @param epsilon sum of angles in adjacency to check for edge
  95798. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  95799. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95800. * @param options The options to apply when generating the edges
  95801. */
  95802. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  95803. protected _prepareRessources(): void;
  95804. /** @hidden */
  95805. _rebuild(): void;
  95806. /**
  95807. * Releases the required resources for the edges renderer
  95808. */
  95809. dispose(): void;
  95810. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95811. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95812. /**
  95813. * Checks if the pair of p0 and p1 is en edge
  95814. * @param faceIndex
  95815. * @param edge
  95816. * @param faceNormals
  95817. * @param p0
  95818. * @param p1
  95819. * @private
  95820. */
  95821. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95822. /**
  95823. * push line into the position, normal and index buffer
  95824. * @protected
  95825. */
  95826. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95827. /**
  95828. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  95829. */
  95830. private _tessellateTriangle;
  95831. private _generateEdgesLinesAlternate;
  95832. /**
  95833. * Generates lines edges from adjacencjes
  95834. * @private
  95835. */
  95836. _generateEdgesLines(): void;
  95837. /**
  95838. * Checks wether or not the edges renderer is ready to render.
  95839. * @return true if ready, otherwise false.
  95840. */
  95841. isReady(): boolean;
  95842. /**
  95843. * Renders the edges of the attached mesh,
  95844. */
  95845. render(): void;
  95846. }
  95847. /**
  95848. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95849. */
  95850. export class LineEdgesRenderer extends EdgesRenderer {
  95851. /**
  95852. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95853. * @param source LineMesh used to generate edges
  95854. * @param epsilon not important (specified angle for edge detection)
  95855. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95856. */
  95857. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95858. /**
  95859. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95860. */
  95861. _generateEdgesLines(): void;
  95862. }
  95863. }
  95864. declare module BABYLON {
  95865. /**
  95866. * This represents the object necessary to create a rendering group.
  95867. * This is exclusively used and created by the rendering manager.
  95868. * To modify the behavior, you use the available helpers in your scene or meshes.
  95869. * @hidden
  95870. */
  95871. export class RenderingGroup {
  95872. index: number;
  95873. private static _zeroVector;
  95874. private _scene;
  95875. private _opaqueSubMeshes;
  95876. private _transparentSubMeshes;
  95877. private _alphaTestSubMeshes;
  95878. private _depthOnlySubMeshes;
  95879. private _particleSystems;
  95880. private _spriteManagers;
  95881. private _opaqueSortCompareFn;
  95882. private _alphaTestSortCompareFn;
  95883. private _transparentSortCompareFn;
  95884. private _renderOpaque;
  95885. private _renderAlphaTest;
  95886. private _renderTransparent;
  95887. /** @hidden */
  95888. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95889. onBeforeTransparentRendering: () => void;
  95890. /**
  95891. * Set the opaque sort comparison function.
  95892. * If null the sub meshes will be render in the order they were created
  95893. */
  95894. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95895. /**
  95896. * Set the alpha test sort comparison function.
  95897. * If null the sub meshes will be render in the order they were created
  95898. */
  95899. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95900. /**
  95901. * Set the transparent sort comparison function.
  95902. * If null the sub meshes will be render in the order they were created
  95903. */
  95904. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95905. /**
  95906. * Creates a new rendering group.
  95907. * @param index The rendering group index
  95908. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95909. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95910. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95911. */
  95912. 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>);
  95913. /**
  95914. * Render all the sub meshes contained in the group.
  95915. * @param customRenderFunction Used to override the default render behaviour of the group.
  95916. * @returns true if rendered some submeshes.
  95917. */
  95918. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95919. /**
  95920. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95921. * @param subMeshes The submeshes to render
  95922. */
  95923. private renderOpaqueSorted;
  95924. /**
  95925. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95926. * @param subMeshes The submeshes to render
  95927. */
  95928. private renderAlphaTestSorted;
  95929. /**
  95930. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95931. * @param subMeshes The submeshes to render
  95932. */
  95933. private renderTransparentSorted;
  95934. /**
  95935. * Renders the submeshes in a specified order.
  95936. * @param subMeshes The submeshes to sort before render
  95937. * @param sortCompareFn The comparison function use to sort
  95938. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95939. * @param transparent Specifies to activate blending if true
  95940. */
  95941. private static renderSorted;
  95942. /**
  95943. * Renders the submeshes in the order they were dispatched (no sort applied).
  95944. * @param subMeshes The submeshes to render
  95945. */
  95946. private static renderUnsorted;
  95947. /**
  95948. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95949. * are rendered back to front if in the same alpha index.
  95950. *
  95951. * @param a The first submesh
  95952. * @param b The second submesh
  95953. * @returns The result of the comparison
  95954. */
  95955. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95956. /**
  95957. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95958. * are rendered back to front.
  95959. *
  95960. * @param a The first submesh
  95961. * @param b The second submesh
  95962. * @returns The result of the comparison
  95963. */
  95964. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95965. /**
  95966. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95967. * are rendered front to back (prevent overdraw).
  95968. *
  95969. * @param a The first submesh
  95970. * @param b The second submesh
  95971. * @returns The result of the comparison
  95972. */
  95973. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95974. /**
  95975. * Resets the different lists of submeshes to prepare a new frame.
  95976. */
  95977. prepare(): void;
  95978. dispose(): void;
  95979. /**
  95980. * Inserts the submesh in its correct queue depending on its material.
  95981. * @param subMesh The submesh to dispatch
  95982. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95983. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95984. */
  95985. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95986. dispatchSprites(spriteManager: ISpriteManager): void;
  95987. dispatchParticles(particleSystem: IParticleSystem): void;
  95988. private _renderParticles;
  95989. private _renderSprites;
  95990. }
  95991. }
  95992. declare module BABYLON {
  95993. /**
  95994. * Interface describing the different options available in the rendering manager
  95995. * regarding Auto Clear between groups.
  95996. */
  95997. export interface IRenderingManagerAutoClearSetup {
  95998. /**
  95999. * Defines whether or not autoclear is enable.
  96000. */
  96001. autoClear: boolean;
  96002. /**
  96003. * Defines whether or not to autoclear the depth buffer.
  96004. */
  96005. depth: boolean;
  96006. /**
  96007. * Defines whether or not to autoclear the stencil buffer.
  96008. */
  96009. stencil: boolean;
  96010. }
  96011. /**
  96012. * This class is used by the onRenderingGroupObservable
  96013. */
  96014. export class RenderingGroupInfo {
  96015. /**
  96016. * The Scene that being rendered
  96017. */
  96018. scene: Scene;
  96019. /**
  96020. * The camera currently used for the rendering pass
  96021. */
  96022. camera: Nullable<Camera>;
  96023. /**
  96024. * The ID of the renderingGroup being processed
  96025. */
  96026. renderingGroupId: number;
  96027. }
  96028. /**
  96029. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96030. * It is enable to manage the different groups as well as the different necessary sort functions.
  96031. * This should not be used directly aside of the few static configurations
  96032. */
  96033. export class RenderingManager {
  96034. /**
  96035. * The max id used for rendering groups (not included)
  96036. */
  96037. static MAX_RENDERINGGROUPS: number;
  96038. /**
  96039. * The min id used for rendering groups (included)
  96040. */
  96041. static MIN_RENDERINGGROUPS: number;
  96042. /**
  96043. * Used to globally prevent autoclearing scenes.
  96044. */
  96045. static AUTOCLEAR: boolean;
  96046. /**
  96047. * @hidden
  96048. */
  96049. _useSceneAutoClearSetup: boolean;
  96050. private _scene;
  96051. private _renderingGroups;
  96052. private _depthStencilBufferAlreadyCleaned;
  96053. private _autoClearDepthStencil;
  96054. private _customOpaqueSortCompareFn;
  96055. private _customAlphaTestSortCompareFn;
  96056. private _customTransparentSortCompareFn;
  96057. private _renderingGroupInfo;
  96058. /**
  96059. * Instantiates a new rendering group for a particular scene
  96060. * @param scene Defines the scene the groups belongs to
  96061. */
  96062. constructor(scene: Scene);
  96063. private _clearDepthStencilBuffer;
  96064. /**
  96065. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  96066. * @hidden
  96067. */
  96068. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  96069. /**
  96070. * Resets the different information of the group to prepare a new frame
  96071. * @hidden
  96072. */
  96073. reset(): void;
  96074. /**
  96075. * Dispose and release the group and its associated resources.
  96076. * @hidden
  96077. */
  96078. dispose(): void;
  96079. /**
  96080. * Clear the info related to rendering groups preventing retention points during dispose.
  96081. */
  96082. freeRenderingGroups(): void;
  96083. private _prepareRenderingGroup;
  96084. /**
  96085. * Add a sprite manager to the rendering manager in order to render it this frame.
  96086. * @param spriteManager Define the sprite manager to render
  96087. */
  96088. dispatchSprites(spriteManager: ISpriteManager): void;
  96089. /**
  96090. * Add a particle system to the rendering manager in order to render it this frame.
  96091. * @param particleSystem Define the particle system to render
  96092. */
  96093. dispatchParticles(particleSystem: IParticleSystem): void;
  96094. /**
  96095. * Add a submesh to the manager in order to render it this frame
  96096. * @param subMesh The submesh to dispatch
  96097. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96098. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96099. */
  96100. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96101. /**
  96102. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96103. * This allowed control for front to back rendering or reversly depending of the special needs.
  96104. *
  96105. * @param renderingGroupId The rendering group id corresponding to its index
  96106. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96107. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96108. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96109. */
  96110. 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;
  96111. /**
  96112. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96113. *
  96114. * @param renderingGroupId The rendering group id corresponding to its index
  96115. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96116. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96117. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96118. */
  96119. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96120. /**
  96121. * Gets the current auto clear configuration for one rendering group of the rendering
  96122. * manager.
  96123. * @param index the rendering group index to get the information for
  96124. * @returns The auto clear setup for the requested rendering group
  96125. */
  96126. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96127. }
  96128. }
  96129. declare module BABYLON {
  96130. /**
  96131. * Defines the options associated with the creation of a custom shader for a shadow generator.
  96132. */
  96133. export interface ICustomShaderOptions {
  96134. /**
  96135. * Gets or sets the custom shader name to use
  96136. */
  96137. shaderName: string;
  96138. /**
  96139. * The list of attribute names used in the shader
  96140. */
  96141. attributes?: string[];
  96142. /**
  96143. * The list of unifrom names used in the shader
  96144. */
  96145. uniforms?: string[];
  96146. /**
  96147. * The list of sampler names used in the shader
  96148. */
  96149. samplers?: string[];
  96150. /**
  96151. * The list of defines used in the shader
  96152. */
  96153. defines?: string[];
  96154. }
  96155. /**
  96156. * Interface to implement to create a shadow generator compatible with BJS.
  96157. */
  96158. export interface IShadowGenerator {
  96159. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96160. id: string;
  96161. /**
  96162. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96163. * @returns The render target texture if present otherwise, null
  96164. */
  96165. getShadowMap(): Nullable<RenderTargetTexture>;
  96166. /**
  96167. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96168. * @param subMesh The submesh we want to render in the shadow map
  96169. * @param useInstances Defines wether will draw in the map using instances
  96170. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96171. * @returns true if ready otherwise, false
  96172. */
  96173. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96174. /**
  96175. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96176. * @param defines Defines of the material we want to update
  96177. * @param lightIndex Index of the light in the enabled light list of the material
  96178. */
  96179. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  96180. /**
  96181. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96182. * defined in the generator but impacting the effect).
  96183. * It implies the unifroms available on the materials are the standard BJS ones.
  96184. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96185. * @param effect The effect we are binfing the information for
  96186. */
  96187. bindShadowLight(lightIndex: string, effect: Effect): void;
  96188. /**
  96189. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96190. * (eq to shadow prjection matrix * light transform matrix)
  96191. * @returns The transform matrix used to create the shadow map
  96192. */
  96193. getTransformMatrix(): Matrix;
  96194. /**
  96195. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96196. * Cube and 2D textures for instance.
  96197. */
  96198. recreateShadowMap(): void;
  96199. /**
  96200. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96201. * @param onCompiled Callback triggered at the and of the effects compilation
  96202. * @param options Sets of optional options forcing the compilation with different modes
  96203. */
  96204. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96205. useInstances: boolean;
  96206. }>): void;
  96207. /**
  96208. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96209. * @param options Sets of optional options forcing the compilation with different modes
  96210. * @returns A promise that resolves when the compilation completes
  96211. */
  96212. forceCompilationAsync(options?: Partial<{
  96213. useInstances: boolean;
  96214. }>): Promise<void>;
  96215. /**
  96216. * Serializes the shadow generator setup to a json object.
  96217. * @returns The serialized JSON object
  96218. */
  96219. serialize(): any;
  96220. /**
  96221. * Disposes the Shadow map and related Textures and effects.
  96222. */
  96223. dispose(): void;
  96224. }
  96225. /**
  96226. * Default implementation IShadowGenerator.
  96227. * This is the main object responsible of generating shadows in the framework.
  96228. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  96229. */
  96230. export class ShadowGenerator implements IShadowGenerator {
  96231. /**
  96232. * Name of the shadow generator class
  96233. */
  96234. static CLASSNAME: string;
  96235. /**
  96236. * Shadow generator mode None: no filtering applied.
  96237. */
  96238. static readonly FILTER_NONE: number;
  96239. /**
  96240. * Shadow generator mode ESM: Exponential Shadow Mapping.
  96241. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96242. */
  96243. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  96244. /**
  96245. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  96246. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  96247. */
  96248. static readonly FILTER_POISSONSAMPLING: number;
  96249. /**
  96250. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  96251. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96252. */
  96253. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  96254. /**
  96255. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  96256. * edge artifacts on steep falloff.
  96257. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96258. */
  96259. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  96260. /**
  96261. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  96262. * edge artifacts on steep falloff.
  96263. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96264. */
  96265. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  96266. /**
  96267. * Shadow generator mode PCF: Percentage Closer Filtering
  96268. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96269. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  96270. */
  96271. static readonly FILTER_PCF: number;
  96272. /**
  96273. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  96274. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96275. * Contact Hardening
  96276. */
  96277. static readonly FILTER_PCSS: number;
  96278. /**
  96279. * Reserved for PCF and PCSS
  96280. * Highest Quality.
  96281. *
  96282. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  96283. *
  96284. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  96285. */
  96286. static readonly QUALITY_HIGH: number;
  96287. /**
  96288. * Reserved for PCF and PCSS
  96289. * Good tradeoff for quality/perf cross devices
  96290. *
  96291. * Execute PCF on a 3*3 kernel.
  96292. *
  96293. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  96294. */
  96295. static readonly QUALITY_MEDIUM: number;
  96296. /**
  96297. * Reserved for PCF and PCSS
  96298. * The lowest quality but the fastest.
  96299. *
  96300. * Execute PCF on a 1*1 kernel.
  96301. *
  96302. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  96303. */
  96304. static readonly QUALITY_LOW: number;
  96305. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96306. id: string;
  96307. /** Gets or sets the custom shader name to use */
  96308. customShaderOptions: ICustomShaderOptions;
  96309. /**
  96310. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  96311. */
  96312. onBeforeShadowMapRenderObservable: Observable<Effect>;
  96313. /**
  96314. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  96315. */
  96316. onAfterShadowMapRenderObservable: Observable<Effect>;
  96317. /**
  96318. * Observable triggered before a mesh is rendered in the shadow map.
  96319. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  96320. */
  96321. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  96322. /**
  96323. * Observable triggered after a mesh is rendered in the shadow map.
  96324. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  96325. */
  96326. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  96327. protected _bias: number;
  96328. /**
  96329. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  96330. */
  96331. get bias(): number;
  96332. /**
  96333. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  96334. */
  96335. set bias(bias: number);
  96336. protected _normalBias: number;
  96337. /**
  96338. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96339. */
  96340. get normalBias(): number;
  96341. /**
  96342. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96343. */
  96344. set normalBias(normalBias: number);
  96345. protected _blurBoxOffset: number;
  96346. /**
  96347. * Gets the blur box offset: offset applied during the blur pass.
  96348. * Only useful if useKernelBlur = false
  96349. */
  96350. get blurBoxOffset(): number;
  96351. /**
  96352. * Sets the blur box offset: offset applied during the blur pass.
  96353. * Only useful if useKernelBlur = false
  96354. */
  96355. set blurBoxOffset(value: number);
  96356. protected _blurScale: number;
  96357. /**
  96358. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  96359. * 2 means half of the size.
  96360. */
  96361. get blurScale(): number;
  96362. /**
  96363. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96364. * 2 means half of the size.
  96365. */
  96366. set blurScale(value: number);
  96367. protected _blurKernel: number;
  96368. /**
  96369. * Gets the blur kernel: kernel size of the blur pass.
  96370. * Only useful if useKernelBlur = true
  96371. */
  96372. get blurKernel(): number;
  96373. /**
  96374. * Sets the blur kernel: kernel size of the blur pass.
  96375. * Only useful if useKernelBlur = true
  96376. */
  96377. set blurKernel(value: number);
  96378. protected _useKernelBlur: boolean;
  96379. /**
  96380. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96381. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96382. */
  96383. get useKernelBlur(): boolean;
  96384. /**
  96385. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96386. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96387. */
  96388. set useKernelBlur(value: boolean);
  96389. protected _depthScale: number;
  96390. /**
  96391. * Gets the depth scale used in ESM mode.
  96392. */
  96393. get depthScale(): number;
  96394. /**
  96395. * Sets the depth scale used in ESM mode.
  96396. * This can override the scale stored on the light.
  96397. */
  96398. set depthScale(value: number);
  96399. protected _validateFilter(filter: number): number;
  96400. protected _filter: number;
  96401. /**
  96402. * Gets 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. get filter(): number;
  96406. /**
  96407. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96408. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96409. */
  96410. set filter(value: number);
  96411. /**
  96412. * Gets if the current filter is set to Poisson Sampling.
  96413. */
  96414. get usePoissonSampling(): boolean;
  96415. /**
  96416. * Sets the current filter to Poisson Sampling.
  96417. */
  96418. set usePoissonSampling(value: boolean);
  96419. /**
  96420. * Gets if the current filter is set to ESM.
  96421. */
  96422. get useExponentialShadowMap(): boolean;
  96423. /**
  96424. * Sets the current filter is to ESM.
  96425. */
  96426. set useExponentialShadowMap(value: boolean);
  96427. /**
  96428. * Gets if the current filter is set to filtered ESM.
  96429. */
  96430. get useBlurExponentialShadowMap(): boolean;
  96431. /**
  96432. * Gets if the current filter is set to filtered ESM.
  96433. */
  96434. set useBlurExponentialShadowMap(value: boolean);
  96435. /**
  96436. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96437. * exponential to prevent steep falloff artifacts).
  96438. */
  96439. get useCloseExponentialShadowMap(): boolean;
  96440. /**
  96441. * Sets the current filter to "close ESM" (using the inverse of the
  96442. * exponential to prevent steep falloff artifacts).
  96443. */
  96444. set useCloseExponentialShadowMap(value: boolean);
  96445. /**
  96446. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96447. * exponential to prevent steep falloff artifacts).
  96448. */
  96449. get useBlurCloseExponentialShadowMap(): boolean;
  96450. /**
  96451. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96452. * exponential to prevent steep falloff artifacts).
  96453. */
  96454. set useBlurCloseExponentialShadowMap(value: boolean);
  96455. /**
  96456. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  96457. */
  96458. get usePercentageCloserFiltering(): boolean;
  96459. /**
  96460. * Sets the current filter to "PCF" (percentage closer filtering).
  96461. */
  96462. set usePercentageCloserFiltering(value: boolean);
  96463. protected _filteringQuality: number;
  96464. /**
  96465. * Gets the PCF or PCSS Quality.
  96466. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96467. */
  96468. get filteringQuality(): number;
  96469. /**
  96470. * Sets the PCF or PCSS Quality.
  96471. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96472. */
  96473. set filteringQuality(filteringQuality: number);
  96474. /**
  96475. * Gets if the current filter is set to "PCSS" (contact hardening).
  96476. */
  96477. get useContactHardeningShadow(): boolean;
  96478. /**
  96479. * Sets the current filter to "PCSS" (contact hardening).
  96480. */
  96481. set useContactHardeningShadow(value: boolean);
  96482. protected _contactHardeningLightSizeUVRatio: number;
  96483. /**
  96484. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96485. * Using a ratio helps keeping shape stability independently of the map size.
  96486. *
  96487. * It does not account for the light projection as it was having too much
  96488. * instability during the light setup or during light position changes.
  96489. *
  96490. * Only valid if useContactHardeningShadow is true.
  96491. */
  96492. get contactHardeningLightSizeUVRatio(): number;
  96493. /**
  96494. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96495. * Using a ratio helps keeping shape stability independently of the map size.
  96496. *
  96497. * It does not account for the light projection as it was having too much
  96498. * instability during the light setup or during light position changes.
  96499. *
  96500. * Only valid if useContactHardeningShadow is true.
  96501. */
  96502. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  96503. protected _darkness: number;
  96504. /** Gets or sets the actual darkness of a shadow */
  96505. get darkness(): number;
  96506. set darkness(value: number);
  96507. /**
  96508. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  96509. * 0 means strongest and 1 would means no shadow.
  96510. * @returns the darkness.
  96511. */
  96512. getDarkness(): number;
  96513. /**
  96514. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  96515. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  96516. * @returns the shadow generator allowing fluent coding.
  96517. */
  96518. setDarkness(darkness: number): ShadowGenerator;
  96519. protected _transparencyShadow: boolean;
  96520. /** Gets or sets the ability to have transparent shadow */
  96521. get transparencyShadow(): boolean;
  96522. set transparencyShadow(value: boolean);
  96523. /**
  96524. * Sets the ability to have transparent shadow (boolean).
  96525. * @param transparent True if transparent else False
  96526. * @returns the shadow generator allowing fluent coding
  96527. */
  96528. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  96529. /**
  96530. * Enables or disables shadows with varying strength based on the transparency
  96531. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  96532. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  96533. * mesh.visibility * alphaTexture.a
  96534. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  96535. */
  96536. enableSoftTransparentShadow: boolean;
  96537. protected _shadowMap: Nullable<RenderTargetTexture>;
  96538. protected _shadowMap2: Nullable<RenderTargetTexture>;
  96539. /**
  96540. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96541. * @returns The render target texture if present otherwise, null
  96542. */
  96543. getShadowMap(): Nullable<RenderTargetTexture>;
  96544. /**
  96545. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  96546. * @returns The render target texture if the shadow map is present otherwise, null
  96547. */
  96548. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  96549. /**
  96550. * Gets the class name of that object
  96551. * @returns "ShadowGenerator"
  96552. */
  96553. getClassName(): string;
  96554. /**
  96555. * Helper function to add a mesh and its descendants to the list of shadow casters.
  96556. * @param mesh Mesh to add
  96557. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  96558. * @returns the Shadow Generator itself
  96559. */
  96560. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96561. /**
  96562. * Helper function to remove a mesh and its descendants from the list of shadow casters
  96563. * @param mesh Mesh to remove
  96564. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  96565. * @returns the Shadow Generator itself
  96566. */
  96567. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96568. /**
  96569. * Controls the extent to which the shadows fade out at the edge of the frustum
  96570. */
  96571. frustumEdgeFalloff: number;
  96572. protected _light: IShadowLight;
  96573. /**
  96574. * Returns the associated light object.
  96575. * @returns the light generating the shadow
  96576. */
  96577. getLight(): IShadowLight;
  96578. /**
  96579. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  96580. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  96581. * It might on the other hand introduce peter panning.
  96582. */
  96583. forceBackFacesOnly: boolean;
  96584. protected _scene: Scene;
  96585. protected _lightDirection: Vector3;
  96586. protected _effect: Effect;
  96587. protected _viewMatrix: Matrix;
  96588. protected _projectionMatrix: Matrix;
  96589. protected _transformMatrix: Matrix;
  96590. protected _cachedPosition: Vector3;
  96591. protected _cachedDirection: Vector3;
  96592. protected _cachedDefines: string;
  96593. protected _currentRenderID: number;
  96594. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96595. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96596. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96597. protected _blurPostProcesses: PostProcess[];
  96598. protected _mapSize: number;
  96599. protected _currentFaceIndex: number;
  96600. protected _currentFaceIndexCache: number;
  96601. protected _textureType: number;
  96602. protected _defaultTextureMatrix: Matrix;
  96603. protected _storedUniqueId: Nullable<number>;
  96604. /** @hidden */
  96605. static _SceneComponentInitialization: (scene: Scene) => void;
  96606. /**
  96607. * Creates a ShadowGenerator object.
  96608. * A ShadowGenerator is the required tool to use the shadows.
  96609. * Each light casting shadows needs to use its own ShadowGenerator.
  96610. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96611. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96612. * @param light The light object generating the shadows.
  96613. * @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.
  96614. */
  96615. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96616. protected _initializeGenerator(): void;
  96617. protected _createTargetRenderTexture(): void;
  96618. protected _initializeShadowMap(): void;
  96619. protected _initializeBlurRTTAndPostProcesses(): void;
  96620. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96621. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96622. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96623. protected _applyFilterValues(): void;
  96624. /**
  96625. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96626. * @param onCompiled Callback triggered at the and of the effects compilation
  96627. * @param options Sets of optional options forcing the compilation with different modes
  96628. */
  96629. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96630. useInstances: boolean;
  96631. }>): void;
  96632. /**
  96633. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96634. * @param options Sets of optional options forcing the compilation with different modes
  96635. * @returns A promise that resolves when the compilation completes
  96636. */
  96637. forceCompilationAsync(options?: Partial<{
  96638. useInstances: boolean;
  96639. }>): Promise<void>;
  96640. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96641. private _prepareShadowDefines;
  96642. /**
  96643. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96644. * @param subMesh The submesh we want to render in the shadow map
  96645. * @param useInstances Defines wether will draw in the map using instances
  96646. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96647. * @returns true if ready otherwise, false
  96648. */
  96649. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96650. /**
  96651. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96652. * @param defines Defines of the material we want to update
  96653. * @param lightIndex Index of the light in the enabled light list of the material
  96654. */
  96655. prepareDefines(defines: any, lightIndex: number): void;
  96656. /**
  96657. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96658. * defined in the generator but impacting the effect).
  96659. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96660. * @param effect The effect we are binfing the information for
  96661. */
  96662. bindShadowLight(lightIndex: string, effect: Effect): void;
  96663. /**
  96664. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96665. * (eq to shadow prjection matrix * light transform matrix)
  96666. * @returns The transform matrix used to create the shadow map
  96667. */
  96668. getTransformMatrix(): Matrix;
  96669. /**
  96670. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96671. * Cube and 2D textures for instance.
  96672. */
  96673. recreateShadowMap(): void;
  96674. protected _disposeBlurPostProcesses(): void;
  96675. protected _disposeRTTandPostProcesses(): void;
  96676. /**
  96677. * Disposes the ShadowGenerator.
  96678. * Returns nothing.
  96679. */
  96680. dispose(): void;
  96681. /**
  96682. * Serializes the shadow generator setup to a json object.
  96683. * @returns The serialized JSON object
  96684. */
  96685. serialize(): any;
  96686. /**
  96687. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96688. * @param parsedShadowGenerator The JSON object to parse
  96689. * @param scene The scene to create the shadow map for
  96690. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96691. * @returns The parsed shadow generator
  96692. */
  96693. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96694. }
  96695. }
  96696. declare module BABYLON {
  96697. /**
  96698. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96699. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96700. * 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.
  96701. */
  96702. export abstract class Light extends Node {
  96703. /**
  96704. * Falloff Default: light is falling off following the material specification:
  96705. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96706. */
  96707. static readonly FALLOFF_DEFAULT: number;
  96708. /**
  96709. * Falloff Physical: light is falling off following the inverse squared distance law.
  96710. */
  96711. static readonly FALLOFF_PHYSICAL: number;
  96712. /**
  96713. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96714. * to enhance interoperability with other engines.
  96715. */
  96716. static readonly FALLOFF_GLTF: number;
  96717. /**
  96718. * Falloff Standard: light is falling off like in the standard material
  96719. * to enhance interoperability with other materials.
  96720. */
  96721. static readonly FALLOFF_STANDARD: number;
  96722. /**
  96723. * If every light affecting the material is in this lightmapMode,
  96724. * material.lightmapTexture adds or multiplies
  96725. * (depends on material.useLightmapAsShadowmap)
  96726. * after every other light calculations.
  96727. */
  96728. static readonly LIGHTMAP_DEFAULT: number;
  96729. /**
  96730. * material.lightmapTexture as only diffuse lighting from this light
  96731. * adds only specular lighting from this light
  96732. * adds dynamic shadows
  96733. */
  96734. static readonly LIGHTMAP_SPECULAR: number;
  96735. /**
  96736. * material.lightmapTexture as only lighting
  96737. * no light calculation from this light
  96738. * only adds dynamic shadows from this light
  96739. */
  96740. static readonly LIGHTMAP_SHADOWSONLY: number;
  96741. /**
  96742. * Each light type uses the default quantity according to its type:
  96743. * point/spot lights use luminous intensity
  96744. * directional lights use illuminance
  96745. */
  96746. static readonly INTENSITYMODE_AUTOMATIC: number;
  96747. /**
  96748. * lumen (lm)
  96749. */
  96750. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  96751. /**
  96752. * candela (lm/sr)
  96753. */
  96754. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  96755. /**
  96756. * lux (lm/m^2)
  96757. */
  96758. static readonly INTENSITYMODE_ILLUMINANCE: number;
  96759. /**
  96760. * nit (cd/m^2)
  96761. */
  96762. static readonly INTENSITYMODE_LUMINANCE: number;
  96763. /**
  96764. * Light type const id of the point light.
  96765. */
  96766. static readonly LIGHTTYPEID_POINTLIGHT: number;
  96767. /**
  96768. * Light type const id of the directional light.
  96769. */
  96770. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96771. /**
  96772. * Light type const id of the spot light.
  96773. */
  96774. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96775. /**
  96776. * Light type const id of the hemispheric light.
  96777. */
  96778. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96779. /**
  96780. * Diffuse gives the basic color to an object.
  96781. */
  96782. diffuse: Color3;
  96783. /**
  96784. * Specular produces a highlight color on an object.
  96785. * Note: This is note affecting PBR materials.
  96786. */
  96787. specular: Color3;
  96788. /**
  96789. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96790. * falling off base on range or angle.
  96791. * This can be set to any values in Light.FALLOFF_x.
  96792. *
  96793. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96794. * other types of materials.
  96795. */
  96796. falloffType: number;
  96797. /**
  96798. * Strength of the light.
  96799. * Note: By default it is define in the framework own unit.
  96800. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96801. */
  96802. intensity: number;
  96803. private _range;
  96804. protected _inverseSquaredRange: 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. get range(): number;
  96810. /**
  96811. * Defines how far from the source the light is impacting in scene units.
  96812. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96813. */
  96814. set range(value: number);
  96815. /**
  96816. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96817. * of light.
  96818. */
  96819. private _photometricScale;
  96820. private _intensityMode;
  96821. /**
  96822. * Gets 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. get intensityMode(): number;
  96826. /**
  96827. * Sets the photometric scale used to interpret the intensity.
  96828. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96829. */
  96830. set intensityMode(value: number);
  96831. private _radius;
  96832. /**
  96833. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96834. */
  96835. get radius(): number;
  96836. /**
  96837. * sets the light radius used by PBR Materials to simulate soft area lights.
  96838. */
  96839. set radius(value: number);
  96840. private _renderPriority;
  96841. /**
  96842. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96843. * exceeding the number allowed of the materials.
  96844. */
  96845. renderPriority: number;
  96846. private _shadowEnabled;
  96847. /**
  96848. * Gets 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. get shadowEnabled(): boolean;
  96852. /**
  96853. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96854. * the current shadow generator.
  96855. */
  96856. set shadowEnabled(value: boolean);
  96857. private _includedOnlyMeshes;
  96858. /**
  96859. * Gets the only meshes impacted by this light.
  96860. */
  96861. get includedOnlyMeshes(): AbstractMesh[];
  96862. /**
  96863. * Sets the only meshes impacted by this light.
  96864. */
  96865. set includedOnlyMeshes(value: AbstractMesh[]);
  96866. private _excludedMeshes;
  96867. /**
  96868. * Gets the meshes not impacted by this light.
  96869. */
  96870. get excludedMeshes(): AbstractMesh[];
  96871. /**
  96872. * Sets the meshes not impacted by this light.
  96873. */
  96874. set excludedMeshes(value: AbstractMesh[]);
  96875. private _excludeWithLayerMask;
  96876. /**
  96877. * Gets the layer id use to find what meshes are not impacted by the light.
  96878. * Inactive if 0
  96879. */
  96880. get excludeWithLayerMask(): number;
  96881. /**
  96882. * Sets the layer id use to find what meshes are not impacted by the light.
  96883. * Inactive if 0
  96884. */
  96885. set excludeWithLayerMask(value: number);
  96886. private _includeOnlyWithLayerMask;
  96887. /**
  96888. * Gets the layer id use to find what meshes are impacted by the light.
  96889. * Inactive if 0
  96890. */
  96891. get includeOnlyWithLayerMask(): number;
  96892. /**
  96893. * Sets the layer id use to find what meshes are impacted by the light.
  96894. * Inactive if 0
  96895. */
  96896. set includeOnlyWithLayerMask(value: number);
  96897. private _lightmapMode;
  96898. /**
  96899. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96900. */
  96901. get lightmapMode(): number;
  96902. /**
  96903. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96904. */
  96905. set lightmapMode(value: number);
  96906. /**
  96907. * Shadow generator associted to the light.
  96908. * @hidden Internal use only.
  96909. */
  96910. _shadowGenerator: Nullable<IShadowGenerator>;
  96911. /**
  96912. * @hidden Internal use only.
  96913. */
  96914. _excludedMeshesIds: string[];
  96915. /**
  96916. * @hidden Internal use only.
  96917. */
  96918. _includedOnlyMeshesIds: string[];
  96919. /**
  96920. * The current light unifom buffer.
  96921. * @hidden Internal use only.
  96922. */
  96923. _uniformBuffer: UniformBuffer;
  96924. /** @hidden */
  96925. _renderId: number;
  96926. /**
  96927. * Creates a Light object in the scene.
  96928. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96929. * @param name The firendly name of the light
  96930. * @param scene The scene the light belongs too
  96931. */
  96932. constructor(name: string, scene: Scene);
  96933. protected abstract _buildUniformLayout(): void;
  96934. /**
  96935. * Sets the passed Effect "effect" with the Light information.
  96936. * @param effect The effect to update
  96937. * @param lightIndex The index of the light in the effect to update
  96938. * @returns The light
  96939. */
  96940. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96941. /**
  96942. * Sets the passed Effect "effect" with the Light textures.
  96943. * @param effect The effect to update
  96944. * @param lightIndex The index of the light in the effect to update
  96945. * @returns The light
  96946. */
  96947. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96948. /**
  96949. * Binds the lights information from the scene to the effect for the given mesh.
  96950. * @param lightIndex Light index
  96951. * @param scene The scene where the light belongs to
  96952. * @param effect The effect we are binding the data to
  96953. * @param useSpecular Defines if specular is supported
  96954. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96955. */
  96956. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96957. /**
  96958. * Sets the passed Effect "effect" with the Light information.
  96959. * @param effect The effect to update
  96960. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96961. * @returns The light
  96962. */
  96963. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96964. /**
  96965. * Returns the string "Light".
  96966. * @returns the class name
  96967. */
  96968. getClassName(): string;
  96969. /** @hidden */
  96970. readonly _isLight: boolean;
  96971. /**
  96972. * Converts the light information to a readable string for debug purpose.
  96973. * @param fullDetails Supports for multiple levels of logging within scene loading
  96974. * @returns the human readable light info
  96975. */
  96976. toString(fullDetails?: boolean): string;
  96977. /** @hidden */
  96978. protected _syncParentEnabledState(): void;
  96979. /**
  96980. * Set the enabled state of this node.
  96981. * @param value - the new enabled state
  96982. */
  96983. setEnabled(value: boolean): void;
  96984. /**
  96985. * Returns the Light associated shadow generator if any.
  96986. * @return the associated shadow generator.
  96987. */
  96988. getShadowGenerator(): Nullable<IShadowGenerator>;
  96989. /**
  96990. * Returns a Vector3, the absolute light position in the World.
  96991. * @returns the world space position of the light
  96992. */
  96993. getAbsolutePosition(): Vector3;
  96994. /**
  96995. * Specifies if the light will affect the passed mesh.
  96996. * @param mesh The mesh to test against the light
  96997. * @return true the mesh is affected otherwise, false.
  96998. */
  96999. canAffectMesh(mesh: AbstractMesh): boolean;
  97000. /**
  97001. * Sort function to order lights for rendering.
  97002. * @param a First Light object to compare to second.
  97003. * @param b Second Light object to compare first.
  97004. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  97005. */
  97006. static CompareLightsPriority(a: Light, b: Light): number;
  97007. /**
  97008. * Releases resources associated with this node.
  97009. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97010. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97011. */
  97012. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97013. /**
  97014. * Returns the light type ID (integer).
  97015. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97016. */
  97017. getTypeID(): number;
  97018. /**
  97019. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  97020. * @returns the scaled intensity in intensity mode unit
  97021. */
  97022. getScaledIntensity(): number;
  97023. /**
  97024. * Returns a new Light object, named "name", from the current one.
  97025. * @param name The name of the cloned light
  97026. * @param newParent The parent of this light, if it has one
  97027. * @returns the new created light
  97028. */
  97029. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97030. /**
  97031. * Serializes the current light into a Serialization object.
  97032. * @returns the serialized object.
  97033. */
  97034. serialize(): any;
  97035. /**
  97036. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97037. * This new light is named "name" and added to the passed scene.
  97038. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97039. * @param name The friendly name of the light
  97040. * @param scene The scene the new light will belong to
  97041. * @returns the constructor function
  97042. */
  97043. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97044. /**
  97045. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97046. * @param parsedLight The JSON representation of the light
  97047. * @param scene The scene to create the parsed light in
  97048. * @returns the created light after parsing
  97049. */
  97050. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97051. private _hookArrayForExcluded;
  97052. private _hookArrayForIncludedOnly;
  97053. private _resyncMeshes;
  97054. /**
  97055. * Forces the meshes to update their light related information in their rendering used effects
  97056. * @hidden Internal Use Only
  97057. */
  97058. _markMeshesAsLightDirty(): void;
  97059. /**
  97060. * Recomputes the cached photometric scale if needed.
  97061. */
  97062. private _computePhotometricScale;
  97063. /**
  97064. * Returns the Photometric Scale according to the light type and intensity mode.
  97065. */
  97066. private _getPhotometricScale;
  97067. /**
  97068. * Reorder the light in the scene according to their defined priority.
  97069. * @hidden Internal Use Only
  97070. */
  97071. _reorderLightsInScene(): void;
  97072. /**
  97073. * Prepares the list of defines specific to the light type.
  97074. * @param defines the list of defines
  97075. * @param lightIndex defines the index of the light for the effect
  97076. */
  97077. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97078. }
  97079. }
  97080. declare module BABYLON {
  97081. /**
  97082. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  97083. * This is the base of the follow, arc rotate cameras and Free camera
  97084. * @see https://doc.babylonjs.com/features/cameras
  97085. */
  97086. export class TargetCamera extends Camera {
  97087. private static _RigCamTransformMatrix;
  97088. private static _TargetTransformMatrix;
  97089. private static _TargetFocalPoint;
  97090. private _tmpUpVector;
  97091. private _tmpTargetVector;
  97092. /**
  97093. * Define the current direction the camera is moving to
  97094. */
  97095. cameraDirection: Vector3;
  97096. /**
  97097. * Define the current rotation the camera is rotating to
  97098. */
  97099. cameraRotation: Vector2;
  97100. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  97101. ignoreParentScaling: boolean;
  97102. /**
  97103. * When set, the up vector of the camera will be updated by the rotation of the camera
  97104. */
  97105. updateUpVectorFromRotation: boolean;
  97106. private _tmpQuaternion;
  97107. /**
  97108. * Define the current rotation of the camera
  97109. */
  97110. rotation: Vector3;
  97111. /**
  97112. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  97113. */
  97114. rotationQuaternion: Quaternion;
  97115. /**
  97116. * Define the current speed of the camera
  97117. */
  97118. speed: number;
  97119. /**
  97120. * Add constraint to the camera to prevent it to move freely in all directions and
  97121. * around all axis.
  97122. */
  97123. noRotationConstraint: boolean;
  97124. /**
  97125. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  97126. * panning
  97127. */
  97128. invertRotation: boolean;
  97129. /**
  97130. * Speed multiplier for inverse camera panning
  97131. */
  97132. inverseRotationSpeed: number;
  97133. /**
  97134. * Define the current target of the camera as an object or a position.
  97135. */
  97136. lockedTarget: any;
  97137. /** @hidden */
  97138. _currentTarget: Vector3;
  97139. /** @hidden */
  97140. _initialFocalDistance: number;
  97141. /** @hidden */
  97142. _viewMatrix: Matrix;
  97143. /** @hidden */
  97144. _camMatrix: Matrix;
  97145. /** @hidden */
  97146. _cameraTransformMatrix: Matrix;
  97147. /** @hidden */
  97148. _cameraRotationMatrix: Matrix;
  97149. /** @hidden */
  97150. _referencePoint: Vector3;
  97151. /** @hidden */
  97152. _transformedReferencePoint: Vector3;
  97153. /** @hidden */
  97154. _reset: () => void;
  97155. private _defaultUp;
  97156. /**
  97157. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  97158. * This is the base of the follow, arc rotate cameras and Free camera
  97159. * @see https://doc.babylonjs.com/features/cameras
  97160. * @param name Defines the name of the camera in the scene
  97161. * @param position Defines the start position of the camera in the scene
  97162. * @param scene Defines the scene the camera belongs to
  97163. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97164. */
  97165. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97166. /**
  97167. * Gets the position in front of the camera at a given distance.
  97168. * @param distance The distance from the camera we want the position to be
  97169. * @returns the position
  97170. */
  97171. getFrontPosition(distance: number): Vector3;
  97172. /** @hidden */
  97173. _getLockedTargetPosition(): Nullable<Vector3>;
  97174. private _storedPosition;
  97175. private _storedRotation;
  97176. private _storedRotationQuaternion;
  97177. /**
  97178. * Store current camera state of the camera (fov, position, rotation, etc..)
  97179. * @returns the camera
  97180. */
  97181. storeState(): Camera;
  97182. /**
  97183. * Restored camera state. You must call storeState() first
  97184. * @returns whether it was successful or not
  97185. * @hidden
  97186. */
  97187. _restoreStateValues(): boolean;
  97188. /** @hidden */
  97189. _initCache(): void;
  97190. /** @hidden */
  97191. _updateCache(ignoreParentClass?: boolean): void;
  97192. /** @hidden */
  97193. _isSynchronizedViewMatrix(): boolean;
  97194. /** @hidden */
  97195. _computeLocalCameraSpeed(): number;
  97196. /**
  97197. * Defines the target the camera should look at.
  97198. * @param target Defines the new target as a Vector or a mesh
  97199. */
  97200. setTarget(target: Vector3): void;
  97201. /**
  97202. * Return the current target position of the camera. This value is expressed in local space.
  97203. * @returns the target position
  97204. */
  97205. getTarget(): Vector3;
  97206. /** @hidden */
  97207. _decideIfNeedsToMove(): boolean;
  97208. /** @hidden */
  97209. _updatePosition(): void;
  97210. /** @hidden */
  97211. _checkInputs(): void;
  97212. protected _updateCameraRotationMatrix(): void;
  97213. /**
  97214. * 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)
  97215. * @returns the current camera
  97216. */
  97217. private _rotateUpVectorWithCameraRotationMatrix;
  97218. private _cachedRotationZ;
  97219. private _cachedQuaternionRotationZ;
  97220. /** @hidden */
  97221. _getViewMatrix(): Matrix;
  97222. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  97223. /**
  97224. * @hidden
  97225. */
  97226. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97227. /**
  97228. * @hidden
  97229. */
  97230. _updateRigCameras(): void;
  97231. private _getRigCamPositionAndTarget;
  97232. /**
  97233. * Gets the current object class name.
  97234. * @return the class name
  97235. */
  97236. getClassName(): string;
  97237. }
  97238. }
  97239. declare module BABYLON {
  97240. /**
  97241. * Gather the list of keyboard event types as constants.
  97242. */
  97243. export class KeyboardEventTypes {
  97244. /**
  97245. * The keydown event is fired when a key becomes active (pressed).
  97246. */
  97247. static readonly KEYDOWN: number;
  97248. /**
  97249. * The keyup event is fired when a key has been released.
  97250. */
  97251. static readonly KEYUP: number;
  97252. }
  97253. /**
  97254. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97255. */
  97256. export class KeyboardInfo {
  97257. /**
  97258. * Defines the type of event (KeyboardEventTypes)
  97259. */
  97260. type: number;
  97261. /**
  97262. * Defines the related dom event
  97263. */
  97264. event: KeyboardEvent;
  97265. /**
  97266. * Instantiates a new keyboard info.
  97267. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97268. * @param type Defines the type of event (KeyboardEventTypes)
  97269. * @param event Defines the related dom event
  97270. */
  97271. constructor(
  97272. /**
  97273. * Defines the type of event (KeyboardEventTypes)
  97274. */
  97275. type: number,
  97276. /**
  97277. * Defines the related dom event
  97278. */
  97279. event: KeyboardEvent);
  97280. }
  97281. /**
  97282. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97283. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  97284. */
  97285. export class KeyboardInfoPre extends KeyboardInfo {
  97286. /**
  97287. * Defines the type of event (KeyboardEventTypes)
  97288. */
  97289. type: number;
  97290. /**
  97291. * Defines the related dom event
  97292. */
  97293. event: KeyboardEvent;
  97294. /**
  97295. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  97296. */
  97297. skipOnPointerObservable: boolean;
  97298. /**
  97299. * Instantiates a new keyboard pre info.
  97300. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97301. * @param type Defines the type of event (KeyboardEventTypes)
  97302. * @param event Defines the related dom event
  97303. */
  97304. constructor(
  97305. /**
  97306. * Defines the type of event (KeyboardEventTypes)
  97307. */
  97308. type: number,
  97309. /**
  97310. * Defines the related dom event
  97311. */
  97312. event: KeyboardEvent);
  97313. }
  97314. }
  97315. declare module BABYLON {
  97316. /**
  97317. * Manage the keyboard inputs to control the movement of a free camera.
  97318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97319. */
  97320. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  97321. /**
  97322. * Defines the camera the input is attached to.
  97323. */
  97324. camera: FreeCamera;
  97325. /**
  97326. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97327. */
  97328. keysUp: number[];
  97329. /**
  97330. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97331. */
  97332. keysUpward: number[];
  97333. /**
  97334. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97335. */
  97336. keysDown: number[];
  97337. /**
  97338. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97339. */
  97340. keysDownward: number[];
  97341. /**
  97342. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97343. */
  97344. keysLeft: number[];
  97345. /**
  97346. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97347. */
  97348. keysRight: number[];
  97349. private _keys;
  97350. private _onCanvasBlurObserver;
  97351. private _onKeyboardObserver;
  97352. private _engine;
  97353. private _scene;
  97354. /**
  97355. * Attach the input controls to a specific dom element to get the input from.
  97356. * @param element Defines the element the controls should be listened from
  97357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97358. */
  97359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97360. /**
  97361. * Detach the current controls from the specified dom element.
  97362. * @param element Defines the element to stop listening the inputs from
  97363. */
  97364. detachControl(element: Nullable<HTMLElement>): void;
  97365. /**
  97366. * Update the current camera state depending on the inputs that have been used this frame.
  97367. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97368. */
  97369. checkInputs(): void;
  97370. /**
  97371. * Gets the class name of the current intput.
  97372. * @returns the class name
  97373. */
  97374. getClassName(): string;
  97375. /** @hidden */
  97376. _onLostFocus(): void;
  97377. /**
  97378. * Get the friendly name associated with the input class.
  97379. * @returns the input friendly name
  97380. */
  97381. getSimpleName(): string;
  97382. }
  97383. }
  97384. declare module BABYLON {
  97385. /**
  97386. * Gather the list of pointer event types as constants.
  97387. */
  97388. export class PointerEventTypes {
  97389. /**
  97390. * 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.
  97391. */
  97392. static readonly POINTERDOWN: number;
  97393. /**
  97394. * The pointerup event is fired when a pointer is no longer active.
  97395. */
  97396. static readonly POINTERUP: number;
  97397. /**
  97398. * The pointermove event is fired when a pointer changes coordinates.
  97399. */
  97400. static readonly POINTERMOVE: number;
  97401. /**
  97402. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97403. */
  97404. static readonly POINTERWHEEL: number;
  97405. /**
  97406. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97407. */
  97408. static readonly POINTERPICK: number;
  97409. /**
  97410. * The pointertap event is fired when a the object has been touched and released without drag.
  97411. */
  97412. static readonly POINTERTAP: number;
  97413. /**
  97414. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97415. */
  97416. static readonly POINTERDOUBLETAP: number;
  97417. }
  97418. /**
  97419. * Base class of pointer info types.
  97420. */
  97421. export class PointerInfoBase {
  97422. /**
  97423. * Defines the type of event (PointerEventTypes)
  97424. */
  97425. type: number;
  97426. /**
  97427. * Defines the related dom event
  97428. */
  97429. event: PointerEvent | MouseWheelEvent;
  97430. /**
  97431. * Instantiates the base class of pointers info.
  97432. * @param type Defines the type of event (PointerEventTypes)
  97433. * @param event Defines the related dom event
  97434. */
  97435. constructor(
  97436. /**
  97437. * Defines the type of event (PointerEventTypes)
  97438. */
  97439. type: number,
  97440. /**
  97441. * Defines the related dom event
  97442. */
  97443. event: PointerEvent | MouseWheelEvent);
  97444. }
  97445. /**
  97446. * This class is used to store pointer related info for the onPrePointerObservable event.
  97447. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97448. */
  97449. export class PointerInfoPre extends PointerInfoBase {
  97450. /**
  97451. * Ray from a pointer if availible (eg. 6dof controller)
  97452. */
  97453. ray: Nullable<Ray>;
  97454. /**
  97455. * Defines the local position of the pointer on the canvas.
  97456. */
  97457. localPosition: Vector2;
  97458. /**
  97459. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  97460. */
  97461. skipOnPointerObservable: boolean;
  97462. /**
  97463. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  97464. * @param type Defines the type of event (PointerEventTypes)
  97465. * @param event Defines the related dom event
  97466. * @param localX Defines the local x coordinates of the pointer when the event occured
  97467. * @param localY Defines the local y coordinates of the pointer when the event occured
  97468. */
  97469. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  97470. }
  97471. /**
  97472. * This type contains all the data related to a pointer event in Babylon.js.
  97473. * 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.
  97474. */
  97475. export class PointerInfo extends PointerInfoBase {
  97476. /**
  97477. * Defines the picking info associated to the info (if any)\
  97478. */
  97479. pickInfo: Nullable<PickingInfo>;
  97480. /**
  97481. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  97482. * @param type Defines the type of event (PointerEventTypes)
  97483. * @param event Defines the related dom event
  97484. * @param pickInfo Defines the picking info associated to the info (if any)\
  97485. */
  97486. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  97487. /**
  97488. * Defines the picking info associated to the info (if any)\
  97489. */
  97490. pickInfo: Nullable<PickingInfo>);
  97491. }
  97492. /**
  97493. * Data relating to a touch event on the screen.
  97494. */
  97495. export interface PointerTouch {
  97496. /**
  97497. * X coordinate of touch.
  97498. */
  97499. x: number;
  97500. /**
  97501. * Y coordinate of touch.
  97502. */
  97503. y: number;
  97504. /**
  97505. * Id of touch. Unique for each finger.
  97506. */
  97507. pointerId: number;
  97508. /**
  97509. * Event type passed from DOM.
  97510. */
  97511. type: any;
  97512. }
  97513. }
  97514. declare module BABYLON {
  97515. /**
  97516. * Manage the mouse inputs to control the movement of a free camera.
  97517. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97518. */
  97519. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  97520. /**
  97521. * Define if touch is enabled in the mouse input
  97522. */
  97523. touchEnabled: boolean;
  97524. /**
  97525. * Defines the camera the input is attached to.
  97526. */
  97527. camera: FreeCamera;
  97528. /**
  97529. * Defines the buttons associated with the input to handle camera move.
  97530. */
  97531. buttons: number[];
  97532. /**
  97533. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  97534. */
  97535. angularSensibility: number;
  97536. private _pointerInput;
  97537. private _onMouseMove;
  97538. private _observer;
  97539. private previousPosition;
  97540. /**
  97541. * Observable for when a pointer move event occurs containing the move offset
  97542. */
  97543. onPointerMovedObservable: Observable<{
  97544. offsetX: number;
  97545. offsetY: number;
  97546. }>;
  97547. /**
  97548. * @hidden
  97549. * If the camera should be rotated automatically based on pointer movement
  97550. */
  97551. _allowCameraRotation: boolean;
  97552. /**
  97553. * Manage the mouse inputs to control the movement of a free camera.
  97554. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97555. * @param touchEnabled Defines if touch is enabled or not
  97556. */
  97557. constructor(
  97558. /**
  97559. * Define if touch is enabled in the mouse input
  97560. */
  97561. touchEnabled?: boolean);
  97562. /**
  97563. * Attach the input controls to a specific dom element to get the input from.
  97564. * @param element Defines the element the controls should be listened from
  97565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97566. */
  97567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97568. /**
  97569. * Called on JS contextmenu event.
  97570. * Override this method to provide functionality.
  97571. */
  97572. protected onContextMenu(evt: PointerEvent): void;
  97573. /**
  97574. * Detach the current controls from the specified dom element.
  97575. * @param element Defines the element to stop listening the inputs from
  97576. */
  97577. detachControl(element: Nullable<HTMLElement>): void;
  97578. /**
  97579. * Gets the class name of the current intput.
  97580. * @returns the class name
  97581. */
  97582. getClassName(): string;
  97583. /**
  97584. * Get the friendly name associated with the input class.
  97585. * @returns the input friendly name
  97586. */
  97587. getSimpleName(): string;
  97588. }
  97589. }
  97590. declare module BABYLON {
  97591. /**
  97592. * Manage the touch inputs to control the movement of a free camera.
  97593. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97594. */
  97595. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97596. /**
  97597. * Defines the camera the input is attached to.
  97598. */
  97599. camera: FreeCamera;
  97600. /**
  97601. * Defines the touch sensibility for rotation.
  97602. * The higher the faster.
  97603. */
  97604. touchAngularSensibility: number;
  97605. /**
  97606. * Defines the touch sensibility for move.
  97607. * The higher the faster.
  97608. */
  97609. touchMoveSensibility: number;
  97610. private _offsetX;
  97611. private _offsetY;
  97612. private _pointerPressed;
  97613. private _pointerInput;
  97614. private _observer;
  97615. private _onLostFocus;
  97616. /**
  97617. * Attach the input controls to a specific dom element to get the input from.
  97618. * @param element Defines the element the controls should be listened from
  97619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97620. */
  97621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97622. /**
  97623. * Detach the current controls from the specified dom element.
  97624. * @param element Defines the element to stop listening the inputs from
  97625. */
  97626. detachControl(element: Nullable<HTMLElement>): void;
  97627. /**
  97628. * Update the current camera state depending on the inputs that have been used this frame.
  97629. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97630. */
  97631. checkInputs(): void;
  97632. /**
  97633. * Gets the class name of the current intput.
  97634. * @returns the class name
  97635. */
  97636. getClassName(): string;
  97637. /**
  97638. * Get the friendly name associated with the input class.
  97639. * @returns the input friendly name
  97640. */
  97641. getSimpleName(): string;
  97642. }
  97643. }
  97644. declare module BABYLON {
  97645. /**
  97646. * Default Inputs manager for the FreeCamera.
  97647. * It groups all the default supported inputs for ease of use.
  97648. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97649. */
  97650. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97651. /**
  97652. * @hidden
  97653. */
  97654. _mouseInput: Nullable<FreeCameraMouseInput>;
  97655. /**
  97656. * Instantiates a new FreeCameraInputsManager.
  97657. * @param camera Defines the camera the inputs belong to
  97658. */
  97659. constructor(camera: FreeCamera);
  97660. /**
  97661. * Add keyboard input support to the input manager.
  97662. * @returns the current input manager
  97663. */
  97664. addKeyboard(): FreeCameraInputsManager;
  97665. /**
  97666. * Add mouse input support to the input manager.
  97667. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97668. * @returns the current input manager
  97669. */
  97670. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97671. /**
  97672. * Removes the mouse input support from the manager
  97673. * @returns the current input manager
  97674. */
  97675. removeMouse(): FreeCameraInputsManager;
  97676. /**
  97677. * Add touch input support to the input manager.
  97678. * @returns the current input manager
  97679. */
  97680. addTouch(): FreeCameraInputsManager;
  97681. /**
  97682. * Remove all attached input methods from a camera
  97683. */
  97684. clear(): void;
  97685. }
  97686. }
  97687. declare module BABYLON {
  97688. /**
  97689. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97690. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97691. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97692. */
  97693. export class FreeCamera extends TargetCamera {
  97694. /**
  97695. * Define the collision ellipsoid of the camera.
  97696. * This is helpful to simulate a camera body like the player body around the camera
  97697. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97698. */
  97699. ellipsoid: Vector3;
  97700. /**
  97701. * Define an offset for the position of the ellipsoid around the camera.
  97702. * This can be helpful to determine the center of the body near the gravity center of the body
  97703. * instead of its head.
  97704. */
  97705. ellipsoidOffset: Vector3;
  97706. /**
  97707. * Enable or disable collisions of the camera with the rest of the scene objects.
  97708. */
  97709. checkCollisions: boolean;
  97710. /**
  97711. * Enable or disable gravity on the camera.
  97712. */
  97713. applyGravity: boolean;
  97714. /**
  97715. * Define the input manager associated to the camera.
  97716. */
  97717. inputs: FreeCameraInputsManager;
  97718. /**
  97719. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97720. * Higher values reduce sensitivity.
  97721. */
  97722. get angularSensibility(): number;
  97723. /**
  97724. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97725. * Higher values reduce sensitivity.
  97726. */
  97727. set angularSensibility(value: number);
  97728. /**
  97729. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97730. */
  97731. get keysUp(): number[];
  97732. set keysUp(value: number[]);
  97733. /**
  97734. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97735. */
  97736. get keysUpward(): number[];
  97737. set keysUpward(value: number[]);
  97738. /**
  97739. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97740. */
  97741. get keysDown(): number[];
  97742. set keysDown(value: number[]);
  97743. /**
  97744. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97745. */
  97746. get keysDownward(): number[];
  97747. set keysDownward(value: number[]);
  97748. /**
  97749. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97750. */
  97751. get keysLeft(): number[];
  97752. set keysLeft(value: number[]);
  97753. /**
  97754. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97755. */
  97756. get keysRight(): number[];
  97757. set keysRight(value: number[]);
  97758. /**
  97759. * Event raised when the camera collide with a mesh in the scene.
  97760. */
  97761. onCollide: (collidedMesh: AbstractMesh) => void;
  97762. private _collider;
  97763. private _needMoveForGravity;
  97764. private _oldPosition;
  97765. private _diffPosition;
  97766. private _newPosition;
  97767. /** @hidden */
  97768. _localDirection: Vector3;
  97769. /** @hidden */
  97770. _transformedDirection: Vector3;
  97771. /**
  97772. * Instantiates a Free Camera.
  97773. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97774. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97775. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97776. * @param name Define the name of the camera in the scene
  97777. * @param position Define the start position of the camera in the scene
  97778. * @param scene Define the scene the camera belongs to
  97779. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97780. */
  97781. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97782. /**
  97783. * Attached controls to the current camera.
  97784. * @param element Defines the element the controls should be listened from
  97785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97786. */
  97787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97788. /**
  97789. * Detach the current controls from the camera.
  97790. * The camera will stop reacting to inputs.
  97791. * @param element Defines the element to stop listening the inputs from
  97792. */
  97793. detachControl(element: HTMLElement): void;
  97794. private _collisionMask;
  97795. /**
  97796. * Define a collision mask to limit the list of object the camera can collide with
  97797. */
  97798. get collisionMask(): number;
  97799. set collisionMask(mask: number);
  97800. /** @hidden */
  97801. _collideWithWorld(displacement: Vector3): void;
  97802. private _onCollisionPositionChange;
  97803. /** @hidden */
  97804. _checkInputs(): void;
  97805. /** @hidden */
  97806. _decideIfNeedsToMove(): boolean;
  97807. /** @hidden */
  97808. _updatePosition(): void;
  97809. /**
  97810. * Destroy the camera and release the current resources hold by it.
  97811. */
  97812. dispose(): void;
  97813. /**
  97814. * Gets the current object class name.
  97815. * @return the class name
  97816. */
  97817. getClassName(): string;
  97818. }
  97819. }
  97820. declare module BABYLON {
  97821. /**
  97822. * Represents a gamepad control stick position
  97823. */
  97824. export class StickValues {
  97825. /**
  97826. * The x component of the control stick
  97827. */
  97828. x: number;
  97829. /**
  97830. * The y component of the control stick
  97831. */
  97832. y: number;
  97833. /**
  97834. * Initializes the gamepad x and y control stick values
  97835. * @param x The x component of the gamepad control stick value
  97836. * @param y The y component of the gamepad control stick value
  97837. */
  97838. constructor(
  97839. /**
  97840. * The x component of the control stick
  97841. */
  97842. x: number,
  97843. /**
  97844. * The y component of the control stick
  97845. */
  97846. y: number);
  97847. }
  97848. /**
  97849. * An interface which manages callbacks for gamepad button changes
  97850. */
  97851. export interface GamepadButtonChanges {
  97852. /**
  97853. * Called when a gamepad has been changed
  97854. */
  97855. changed: boolean;
  97856. /**
  97857. * Called when a gamepad press event has been triggered
  97858. */
  97859. pressChanged: boolean;
  97860. /**
  97861. * Called when a touch event has been triggered
  97862. */
  97863. touchChanged: boolean;
  97864. /**
  97865. * Called when a value has changed
  97866. */
  97867. valueChanged: boolean;
  97868. }
  97869. /**
  97870. * Represents a gamepad
  97871. */
  97872. export class Gamepad {
  97873. /**
  97874. * The id of the gamepad
  97875. */
  97876. id: string;
  97877. /**
  97878. * The index of the gamepad
  97879. */
  97880. index: number;
  97881. /**
  97882. * The browser gamepad
  97883. */
  97884. browserGamepad: any;
  97885. /**
  97886. * Specifies what type of gamepad this represents
  97887. */
  97888. type: number;
  97889. private _leftStick;
  97890. private _rightStick;
  97891. /** @hidden */
  97892. _isConnected: boolean;
  97893. private _leftStickAxisX;
  97894. private _leftStickAxisY;
  97895. private _rightStickAxisX;
  97896. private _rightStickAxisY;
  97897. /**
  97898. * Triggered when the left control stick has been changed
  97899. */
  97900. private _onleftstickchanged;
  97901. /**
  97902. * Triggered when the right control stick has been changed
  97903. */
  97904. private _onrightstickchanged;
  97905. /**
  97906. * Represents a gamepad controller
  97907. */
  97908. static GAMEPAD: number;
  97909. /**
  97910. * Represents a generic controller
  97911. */
  97912. static GENERIC: number;
  97913. /**
  97914. * Represents an XBox controller
  97915. */
  97916. static XBOX: number;
  97917. /**
  97918. * Represents a pose-enabled controller
  97919. */
  97920. static POSE_ENABLED: number;
  97921. /**
  97922. * Represents an Dual Shock controller
  97923. */
  97924. static DUALSHOCK: number;
  97925. /**
  97926. * Specifies whether the left control stick should be Y-inverted
  97927. */
  97928. protected _invertLeftStickY: boolean;
  97929. /**
  97930. * Specifies if the gamepad has been connected
  97931. */
  97932. get isConnected(): boolean;
  97933. /**
  97934. * Initializes the gamepad
  97935. * @param id The id of the gamepad
  97936. * @param index The index of the gamepad
  97937. * @param browserGamepad The browser gamepad
  97938. * @param leftStickX The x component of the left joystick
  97939. * @param leftStickY The y component of the left joystick
  97940. * @param rightStickX The x component of the right joystick
  97941. * @param rightStickY The y component of the right joystick
  97942. */
  97943. constructor(
  97944. /**
  97945. * The id of the gamepad
  97946. */
  97947. id: string,
  97948. /**
  97949. * The index of the gamepad
  97950. */
  97951. index: number,
  97952. /**
  97953. * The browser gamepad
  97954. */
  97955. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97956. /**
  97957. * Callback triggered when the left joystick has changed
  97958. * @param callback
  97959. */
  97960. onleftstickchanged(callback: (values: StickValues) => void): void;
  97961. /**
  97962. * Callback triggered when the right joystick has changed
  97963. * @param callback
  97964. */
  97965. onrightstickchanged(callback: (values: StickValues) => void): void;
  97966. /**
  97967. * Gets the left joystick
  97968. */
  97969. get leftStick(): StickValues;
  97970. /**
  97971. * Sets the left joystick values
  97972. */
  97973. set leftStick(newValues: StickValues);
  97974. /**
  97975. * Gets the right joystick
  97976. */
  97977. get rightStick(): StickValues;
  97978. /**
  97979. * Sets the right joystick value
  97980. */
  97981. set rightStick(newValues: StickValues);
  97982. /**
  97983. * Updates the gamepad joystick positions
  97984. */
  97985. update(): void;
  97986. /**
  97987. * Disposes the gamepad
  97988. */
  97989. dispose(): void;
  97990. }
  97991. /**
  97992. * Represents a generic gamepad
  97993. */
  97994. export class GenericPad extends Gamepad {
  97995. private _buttons;
  97996. private _onbuttondown;
  97997. private _onbuttonup;
  97998. /**
  97999. * Observable triggered when a button has been pressed
  98000. */
  98001. onButtonDownObservable: Observable<number>;
  98002. /**
  98003. * Observable triggered when a button has been released
  98004. */
  98005. onButtonUpObservable: Observable<number>;
  98006. /**
  98007. * Callback triggered when a button has been pressed
  98008. * @param callback Called when a button has been pressed
  98009. */
  98010. onbuttondown(callback: (buttonPressed: number) => void): void;
  98011. /**
  98012. * Callback triggered when a button has been released
  98013. * @param callback Called when a button has been released
  98014. */
  98015. onbuttonup(callback: (buttonReleased: number) => void): void;
  98016. /**
  98017. * Initializes the generic gamepad
  98018. * @param id The id of the generic gamepad
  98019. * @param index The index of the generic gamepad
  98020. * @param browserGamepad The browser gamepad
  98021. */
  98022. constructor(id: string, index: number, browserGamepad: any);
  98023. private _setButtonValue;
  98024. /**
  98025. * Updates the generic gamepad
  98026. */
  98027. update(): void;
  98028. /**
  98029. * Disposes the generic gamepad
  98030. */
  98031. dispose(): void;
  98032. }
  98033. }
  98034. declare module BABYLON {
  98035. /**
  98036. * Defines the types of pose enabled controllers that are supported
  98037. */
  98038. export enum PoseEnabledControllerType {
  98039. /**
  98040. * HTC Vive
  98041. */
  98042. VIVE = 0,
  98043. /**
  98044. * Oculus Rift
  98045. */
  98046. OCULUS = 1,
  98047. /**
  98048. * Windows mixed reality
  98049. */
  98050. WINDOWS = 2,
  98051. /**
  98052. * Samsung gear VR
  98053. */
  98054. GEAR_VR = 3,
  98055. /**
  98056. * Google Daydream
  98057. */
  98058. DAYDREAM = 4,
  98059. /**
  98060. * Generic
  98061. */
  98062. GENERIC = 5
  98063. }
  98064. /**
  98065. * Defines the MutableGamepadButton interface for the state of a gamepad button
  98066. */
  98067. export interface MutableGamepadButton {
  98068. /**
  98069. * Value of the button/trigger
  98070. */
  98071. value: number;
  98072. /**
  98073. * If the button/trigger is currently touched
  98074. */
  98075. touched: boolean;
  98076. /**
  98077. * If the button/trigger is currently pressed
  98078. */
  98079. pressed: boolean;
  98080. }
  98081. /**
  98082. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  98083. * @hidden
  98084. */
  98085. export interface ExtendedGamepadButton extends GamepadButton {
  98086. /**
  98087. * If the button/trigger is currently pressed
  98088. */
  98089. readonly pressed: boolean;
  98090. /**
  98091. * If the button/trigger is currently touched
  98092. */
  98093. readonly touched: boolean;
  98094. /**
  98095. * Value of the button/trigger
  98096. */
  98097. readonly value: number;
  98098. }
  98099. /** @hidden */
  98100. export interface _GamePadFactory {
  98101. /**
  98102. * Returns whether or not the current gamepad can be created for this type of controller.
  98103. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98104. * @returns true if it can be created, otherwise false
  98105. */
  98106. canCreate(gamepadInfo: any): boolean;
  98107. /**
  98108. * Creates a new instance of the Gamepad.
  98109. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98110. * @returns the new gamepad instance
  98111. */
  98112. create(gamepadInfo: any): Gamepad;
  98113. }
  98114. /**
  98115. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98116. */
  98117. export class PoseEnabledControllerHelper {
  98118. /** @hidden */
  98119. static _ControllerFactories: _GamePadFactory[];
  98120. /** @hidden */
  98121. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  98122. /**
  98123. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98124. * @param vrGamepad the gamepad to initialized
  98125. * @returns a vr controller of the type the gamepad identified as
  98126. */
  98127. static InitiateController(vrGamepad: any): Gamepad;
  98128. }
  98129. /**
  98130. * Defines the PoseEnabledController object that contains state of a vr capable controller
  98131. */
  98132. export class PoseEnabledController extends Gamepad implements PoseControlled {
  98133. /**
  98134. * If the controller is used in a webXR session
  98135. */
  98136. isXR: boolean;
  98137. private _deviceRoomPosition;
  98138. private _deviceRoomRotationQuaternion;
  98139. /**
  98140. * The device position in babylon space
  98141. */
  98142. devicePosition: Vector3;
  98143. /**
  98144. * The device rotation in babylon space
  98145. */
  98146. deviceRotationQuaternion: Quaternion;
  98147. /**
  98148. * The scale factor of the device in babylon space
  98149. */
  98150. deviceScaleFactor: number;
  98151. /**
  98152. * (Likely devicePosition should be used instead) The device position in its room space
  98153. */
  98154. position: Vector3;
  98155. /**
  98156. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  98157. */
  98158. rotationQuaternion: Quaternion;
  98159. /**
  98160. * The type of controller (Eg. Windows mixed reality)
  98161. */
  98162. controllerType: PoseEnabledControllerType;
  98163. protected _calculatedPosition: Vector3;
  98164. private _calculatedRotation;
  98165. /**
  98166. * The raw pose from the device
  98167. */
  98168. rawPose: DevicePose;
  98169. private _trackPosition;
  98170. private _maxRotationDistFromHeadset;
  98171. private _draggedRoomRotation;
  98172. /**
  98173. * @hidden
  98174. */
  98175. _disableTrackPosition(fixedPosition: Vector3): void;
  98176. /**
  98177. * Internal, the mesh attached to the controller
  98178. * @hidden
  98179. */
  98180. _mesh: Nullable<AbstractMesh>;
  98181. private _poseControlledCamera;
  98182. private _leftHandSystemQuaternion;
  98183. /**
  98184. * Internal, matrix used to convert room space to babylon space
  98185. * @hidden
  98186. */
  98187. _deviceToWorld: Matrix;
  98188. /**
  98189. * Node to be used when casting a ray from the controller
  98190. * @hidden
  98191. */
  98192. _pointingPoseNode: Nullable<TransformNode>;
  98193. /**
  98194. * Name of the child mesh that can be used to cast a ray from the controller
  98195. */
  98196. static readonly POINTING_POSE: string;
  98197. /**
  98198. * Creates a new PoseEnabledController from a gamepad
  98199. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  98200. */
  98201. constructor(browserGamepad: any);
  98202. private _workingMatrix;
  98203. /**
  98204. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  98205. */
  98206. update(): void;
  98207. /**
  98208. * Updates only the pose device and mesh without doing any button event checking
  98209. */
  98210. protected _updatePoseAndMesh(): void;
  98211. /**
  98212. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  98213. * @param poseData raw pose fromthe device
  98214. */
  98215. updateFromDevice(poseData: DevicePose): void;
  98216. /**
  98217. * @hidden
  98218. */
  98219. _meshAttachedObservable: Observable<AbstractMesh>;
  98220. /**
  98221. * Attaches a mesh to the controller
  98222. * @param mesh the mesh to be attached
  98223. */
  98224. attachToMesh(mesh: AbstractMesh): void;
  98225. /**
  98226. * Attaches the controllers mesh to a camera
  98227. * @param camera the camera the mesh should be attached to
  98228. */
  98229. attachToPoseControlledCamera(camera: TargetCamera): void;
  98230. /**
  98231. * Disposes of the controller
  98232. */
  98233. dispose(): void;
  98234. /**
  98235. * The mesh that is attached to the controller
  98236. */
  98237. get mesh(): Nullable<AbstractMesh>;
  98238. /**
  98239. * Gets the ray of the controller in the direction the controller is pointing
  98240. * @param length the length the resulting ray should be
  98241. * @returns a ray in the direction the controller is pointing
  98242. */
  98243. getForwardRay(length?: number): Ray;
  98244. }
  98245. }
  98246. declare module BABYLON {
  98247. /**
  98248. * Defines the WebVRController object that represents controllers tracked in 3D space
  98249. */
  98250. export abstract class WebVRController extends PoseEnabledController {
  98251. /**
  98252. * Internal, the default controller model for the controller
  98253. */
  98254. protected _defaultModel: Nullable<AbstractMesh>;
  98255. /**
  98256. * Fired when the trigger state has changed
  98257. */
  98258. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98259. /**
  98260. * Fired when the main button state has changed
  98261. */
  98262. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98263. /**
  98264. * Fired when the secondary button state has changed
  98265. */
  98266. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98267. /**
  98268. * Fired when the pad state has changed
  98269. */
  98270. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  98271. /**
  98272. * Fired when controllers stick values have changed
  98273. */
  98274. onPadValuesChangedObservable: Observable<StickValues>;
  98275. /**
  98276. * Array of button availible on the controller
  98277. */
  98278. protected _buttons: Array<MutableGamepadButton>;
  98279. private _onButtonStateChange;
  98280. /**
  98281. * Fired when a controller button's state has changed
  98282. * @param callback the callback containing the button that was modified
  98283. */
  98284. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  98285. /**
  98286. * X and Y axis corresponding to the controllers joystick
  98287. */
  98288. pad: StickValues;
  98289. /**
  98290. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  98291. */
  98292. hand: string;
  98293. /**
  98294. * The default controller model for the controller
  98295. */
  98296. get defaultModel(): Nullable<AbstractMesh>;
  98297. /**
  98298. * Creates a new WebVRController from a gamepad
  98299. * @param vrGamepad the gamepad that the WebVRController should be created from
  98300. */
  98301. constructor(vrGamepad: any);
  98302. /**
  98303. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  98304. */
  98305. update(): void;
  98306. /**
  98307. * Function to be called when a button is modified
  98308. */
  98309. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98310. /**
  98311. * Loads a mesh and attaches it to the controller
  98312. * @param scene the scene the mesh should be added to
  98313. * @param meshLoaded callback for when the mesh has been loaded
  98314. */
  98315. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98316. private _setButtonValue;
  98317. private _changes;
  98318. private _checkChanges;
  98319. /**
  98320. * Disposes of th webVRCOntroller
  98321. */
  98322. dispose(): void;
  98323. }
  98324. }
  98325. declare module BABYLON {
  98326. /**
  98327. * The HemisphericLight simulates the ambient environment light,
  98328. * so the passed direction is the light reflection direction, not the incoming direction.
  98329. */
  98330. export class HemisphericLight extends Light {
  98331. /**
  98332. * The groundColor is the light in the opposite direction to the one specified during creation.
  98333. * 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.
  98334. */
  98335. groundColor: Color3;
  98336. /**
  98337. * The light reflection direction, not the incoming direction.
  98338. */
  98339. direction: Vector3;
  98340. /**
  98341. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  98342. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  98343. * The HemisphericLight can't cast shadows.
  98344. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98345. * @param name The friendly name of the light
  98346. * @param direction The direction of the light reflection
  98347. * @param scene The scene the light belongs to
  98348. */
  98349. constructor(name: string, direction: Vector3, scene: Scene);
  98350. protected _buildUniformLayout(): void;
  98351. /**
  98352. * Returns the string "HemisphericLight".
  98353. * @return The class name
  98354. */
  98355. getClassName(): string;
  98356. /**
  98357. * Sets the HemisphericLight direction towards the passed target (Vector3).
  98358. * Returns the updated direction.
  98359. * @param target The target the direction should point to
  98360. * @return The computed direction
  98361. */
  98362. setDirectionToTarget(target: Vector3): Vector3;
  98363. /**
  98364. * Returns the shadow generator associated to the light.
  98365. * @returns Always null for hemispheric lights because it does not support shadows.
  98366. */
  98367. getShadowGenerator(): Nullable<IShadowGenerator>;
  98368. /**
  98369. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98370. * @param effect The effect to update
  98371. * @param lightIndex The index of the light in the effect to update
  98372. * @returns The hemispheric light
  98373. */
  98374. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98375. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98376. /**
  98377. * Computes the world matrix of the node
  98378. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98379. * @param useWasUpdatedFlag defines a reserved property
  98380. * @returns the world matrix
  98381. */
  98382. computeWorldMatrix(): Matrix;
  98383. /**
  98384. * Returns the integer 3.
  98385. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98386. */
  98387. getTypeID(): number;
  98388. /**
  98389. * Prepares the list of defines specific to the light type.
  98390. * @param defines the list of defines
  98391. * @param lightIndex defines the index of the light for the effect
  98392. */
  98393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98394. }
  98395. }
  98396. declare module BABYLON {
  98397. /** @hidden */
  98398. export var vrMultiviewToSingleviewPixelShader: {
  98399. name: string;
  98400. shader: string;
  98401. };
  98402. }
  98403. declare module BABYLON {
  98404. /**
  98405. * Renders to multiple views with a single draw call
  98406. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98407. */
  98408. export class MultiviewRenderTarget extends RenderTargetTexture {
  98409. /**
  98410. * Creates a multiview render target
  98411. * @param scene scene used with the render target
  98412. * @param size the size of the render target (used for each view)
  98413. */
  98414. constructor(scene: Scene, size?: number | {
  98415. width: number;
  98416. height: number;
  98417. } | {
  98418. ratio: number;
  98419. });
  98420. /**
  98421. * @hidden
  98422. * @param faceIndex the face index, if its a cube texture
  98423. */
  98424. _bindFrameBuffer(faceIndex?: number): void;
  98425. /**
  98426. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98427. * @returns the view count
  98428. */
  98429. getViewCount(): number;
  98430. }
  98431. }
  98432. declare module BABYLON {
  98433. interface Engine {
  98434. /**
  98435. * Creates a new multiview render target
  98436. * @param width defines the width of the texture
  98437. * @param height defines the height of the texture
  98438. * @returns the created multiview texture
  98439. */
  98440. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  98441. /**
  98442. * Binds a multiview framebuffer to be drawn to
  98443. * @param multiviewTexture texture to bind
  98444. */
  98445. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  98446. }
  98447. interface Camera {
  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. _useMultiviewToSingleView: boolean;
  98453. /**
  98454. * @hidden
  98455. * 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)
  98456. */
  98457. _multiviewTexture: Nullable<RenderTargetTexture>;
  98458. /**
  98459. * @hidden
  98460. * ensures the multiview texture of the camera exists and has the specified width/height
  98461. * @param width height to set on the multiview texture
  98462. * @param height width to set on the multiview texture
  98463. */
  98464. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  98465. }
  98466. interface Scene {
  98467. /** @hidden */
  98468. _transformMatrixR: Matrix;
  98469. /** @hidden */
  98470. _multiviewSceneUbo: Nullable<UniformBuffer>;
  98471. /** @hidden */
  98472. _createMultiviewUbo(): void;
  98473. /** @hidden */
  98474. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  98475. /** @hidden */
  98476. _renderMultiviewToSingleView(camera: Camera): void;
  98477. }
  98478. }
  98479. declare module BABYLON {
  98480. /**
  98481. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  98482. * This will not be used for webXR as it supports displaying texture arrays directly
  98483. */
  98484. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  98485. /**
  98486. * Initializes a VRMultiviewToSingleview
  98487. * @param name name of the post process
  98488. * @param camera camera to be applied to
  98489. * @param scaleFactor scaling factor to the size of the output texture
  98490. */
  98491. constructor(name: string, camera: Camera, scaleFactor: number);
  98492. }
  98493. }
  98494. declare module BABYLON {
  98495. /**
  98496. * Interface used to define additional presentation attributes
  98497. */
  98498. export interface IVRPresentationAttributes {
  98499. /**
  98500. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  98501. */
  98502. highRefreshRate: boolean;
  98503. /**
  98504. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  98505. */
  98506. foveationLevel: number;
  98507. }
  98508. interface Engine {
  98509. /** @hidden */
  98510. _vrDisplay: any;
  98511. /** @hidden */
  98512. _vrSupported: boolean;
  98513. /** @hidden */
  98514. _oldSize: Size;
  98515. /** @hidden */
  98516. _oldHardwareScaleFactor: number;
  98517. /** @hidden */
  98518. _vrExclusivePointerMode: boolean;
  98519. /** @hidden */
  98520. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  98521. /** @hidden */
  98522. _onVRDisplayPointerRestricted: () => void;
  98523. /** @hidden */
  98524. _onVRDisplayPointerUnrestricted: () => void;
  98525. /** @hidden */
  98526. _onVrDisplayConnect: Nullable<(display: any) => void>;
  98527. /** @hidden */
  98528. _onVrDisplayDisconnect: Nullable<() => void>;
  98529. /** @hidden */
  98530. _onVrDisplayPresentChange: Nullable<() => void>;
  98531. /**
  98532. * Observable signaled when VR display mode changes
  98533. */
  98534. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  98535. /**
  98536. * Observable signaled when VR request present is complete
  98537. */
  98538. onVRRequestPresentComplete: Observable<boolean>;
  98539. /**
  98540. * Observable signaled when VR request present starts
  98541. */
  98542. onVRRequestPresentStart: Observable<Engine>;
  98543. /**
  98544. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  98545. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  98546. */
  98547. isInVRExclusivePointerMode: boolean;
  98548. /**
  98549. * Gets a boolean indicating if a webVR device was detected
  98550. * @returns true if a webVR device was detected
  98551. */
  98552. isVRDevicePresent(): boolean;
  98553. /**
  98554. * Gets the current webVR device
  98555. * @returns the current webVR device (or null)
  98556. */
  98557. getVRDevice(): any;
  98558. /**
  98559. * Initializes a webVR display and starts listening to display change events
  98560. * The onVRDisplayChangedObservable will be notified upon these changes
  98561. * @returns A promise containing a VRDisplay and if vr is supported
  98562. */
  98563. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  98564. /** @hidden */
  98565. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  98566. /**
  98567. * Gets or sets the presentation attributes used to configure VR rendering
  98568. */
  98569. vrPresentationAttributes?: IVRPresentationAttributes;
  98570. /**
  98571. * Call this function to switch to webVR mode
  98572. * Will do nothing if webVR is not supported or if there is no webVR device
  98573. * @param options the webvr options provided to the camera. mainly used for multiview
  98574. * @see https://doc.babylonjs.com/how_to/webvr_camera
  98575. */
  98576. enableVR(options: WebVROptions): void;
  98577. /** @hidden */
  98578. _onVRFullScreenTriggered(): void;
  98579. }
  98580. }
  98581. declare module BABYLON {
  98582. /**
  98583. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  98584. * IMPORTANT!! The data is right-hand data.
  98585. * @export
  98586. * @interface DevicePose
  98587. */
  98588. export interface DevicePose {
  98589. /**
  98590. * The position of the device, values in array are [x,y,z].
  98591. */
  98592. readonly position: Nullable<Float32Array>;
  98593. /**
  98594. * The linearVelocity of the device, values in array are [x,y,z].
  98595. */
  98596. readonly linearVelocity: Nullable<Float32Array>;
  98597. /**
  98598. * The linearAcceleration of the device, values in array are [x,y,z].
  98599. */
  98600. readonly linearAcceleration: Nullable<Float32Array>;
  98601. /**
  98602. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98603. */
  98604. readonly orientation: Nullable<Float32Array>;
  98605. /**
  98606. * The angularVelocity of the device, values in array are [x,y,z].
  98607. */
  98608. readonly angularVelocity: Nullable<Float32Array>;
  98609. /**
  98610. * The angularAcceleration of the device, values in array are [x,y,z].
  98611. */
  98612. readonly angularAcceleration: Nullable<Float32Array>;
  98613. }
  98614. /**
  98615. * Interface representing a pose controlled object in Babylon.
  98616. * A pose controlled object has both regular pose values as well as pose values
  98617. * from an external device such as a VR head mounted display
  98618. */
  98619. export interface PoseControlled {
  98620. /**
  98621. * The position of the object in babylon space.
  98622. */
  98623. position: Vector3;
  98624. /**
  98625. * The rotation quaternion of the object in babylon space.
  98626. */
  98627. rotationQuaternion: Quaternion;
  98628. /**
  98629. * The position of the device in babylon space.
  98630. */
  98631. devicePosition?: Vector3;
  98632. /**
  98633. * The rotation quaternion of the device in babylon space.
  98634. */
  98635. deviceRotationQuaternion: Quaternion;
  98636. /**
  98637. * The raw pose coming from the device.
  98638. */
  98639. rawPose: Nullable<DevicePose>;
  98640. /**
  98641. * The scale of the device to be used when translating from device space to babylon space.
  98642. */
  98643. deviceScaleFactor: number;
  98644. /**
  98645. * Updates the poseControlled values based on the input device pose.
  98646. * @param poseData the pose data to update the object with
  98647. */
  98648. updateFromDevice(poseData: DevicePose): void;
  98649. }
  98650. /**
  98651. * Set of options to customize the webVRCamera
  98652. */
  98653. export interface WebVROptions {
  98654. /**
  98655. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98656. */
  98657. trackPosition?: boolean;
  98658. /**
  98659. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98660. */
  98661. positionScale?: number;
  98662. /**
  98663. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98664. */
  98665. displayName?: string;
  98666. /**
  98667. * Should the native controller meshes be initialized. (default: true)
  98668. */
  98669. controllerMeshes?: boolean;
  98670. /**
  98671. * Creating a default HemiLight only on controllers. (default: true)
  98672. */
  98673. defaultLightingOnControllers?: boolean;
  98674. /**
  98675. * If you don't want to use the default VR button of the helper. (default: false)
  98676. */
  98677. useCustomVRButton?: boolean;
  98678. /**
  98679. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98680. */
  98681. customVRButton?: HTMLButtonElement;
  98682. /**
  98683. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98684. */
  98685. rayLength?: number;
  98686. /**
  98687. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98688. */
  98689. defaultHeight?: number;
  98690. /**
  98691. * If multiview should be used if availible (default: false)
  98692. */
  98693. useMultiview?: boolean;
  98694. }
  98695. /**
  98696. * This represents a WebVR camera.
  98697. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98698. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98699. */
  98700. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98701. private webVROptions;
  98702. /**
  98703. * @hidden
  98704. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98705. */
  98706. _vrDevice: any;
  98707. /**
  98708. * The rawPose of the vrDevice.
  98709. */
  98710. rawPose: Nullable<DevicePose>;
  98711. private _onVREnabled;
  98712. private _specsVersion;
  98713. private _attached;
  98714. private _frameData;
  98715. protected _descendants: Array<Node>;
  98716. private _deviceRoomPosition;
  98717. /** @hidden */
  98718. _deviceRoomRotationQuaternion: Quaternion;
  98719. private _standingMatrix;
  98720. /**
  98721. * Represents device position in babylon space.
  98722. */
  98723. devicePosition: Vector3;
  98724. /**
  98725. * Represents device rotation in babylon space.
  98726. */
  98727. deviceRotationQuaternion: Quaternion;
  98728. /**
  98729. * The scale of the device to be used when translating from device space to babylon space.
  98730. */
  98731. deviceScaleFactor: number;
  98732. private _deviceToWorld;
  98733. private _worldToDevice;
  98734. /**
  98735. * References to the webVR controllers for the vrDevice.
  98736. */
  98737. controllers: Array<WebVRController>;
  98738. /**
  98739. * Emits an event when a controller is attached.
  98740. */
  98741. onControllersAttachedObservable: Observable<WebVRController[]>;
  98742. /**
  98743. * Emits an event when a controller's mesh has been loaded;
  98744. */
  98745. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98746. /**
  98747. * Emits an event when the HMD's pose has been updated.
  98748. */
  98749. onPoseUpdatedFromDeviceObservable: Observable<any>;
  98750. private _poseSet;
  98751. /**
  98752. * If the rig cameras be used as parent instead of this camera.
  98753. */
  98754. rigParenting: boolean;
  98755. private _lightOnControllers;
  98756. private _defaultHeight?;
  98757. /**
  98758. * Instantiates a WebVRFreeCamera.
  98759. * @param name The name of the WebVRFreeCamera
  98760. * @param position The starting anchor position for the camera
  98761. * @param scene The scene the camera belongs to
  98762. * @param webVROptions a set of customizable options for the webVRCamera
  98763. */
  98764. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  98765. /**
  98766. * Gets the device distance from the ground in meters.
  98767. * @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.
  98768. */
  98769. deviceDistanceToRoomGround(): number;
  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. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98773. */
  98774. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98775. /**
  98776. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98777. * @returns A promise with a boolean set to if the standing matrix is supported.
  98778. */
  98779. useStandingMatrixAsync(): Promise<boolean>;
  98780. /**
  98781. * Disposes the camera
  98782. */
  98783. dispose(): void;
  98784. /**
  98785. * Gets a vrController by name.
  98786. * @param name The name of the controller to retreive
  98787. * @returns the controller matching the name specified or null if not found
  98788. */
  98789. getControllerByName(name: string): Nullable<WebVRController>;
  98790. private _leftController;
  98791. /**
  98792. * The controller corresponding to the users left hand.
  98793. */
  98794. get leftController(): Nullable<WebVRController>;
  98795. private _rightController;
  98796. /**
  98797. * The controller corresponding to the users right hand.
  98798. */
  98799. get rightController(): Nullable<WebVRController>;
  98800. /**
  98801. * Casts a ray forward from the vrCamera's gaze.
  98802. * @param length Length of the ray (default: 100)
  98803. * @returns the ray corresponding to the gaze
  98804. */
  98805. getForwardRay(length?: number): Ray;
  98806. /**
  98807. * @hidden
  98808. * Updates the camera based on device's frame data
  98809. */
  98810. _checkInputs(): void;
  98811. /**
  98812. * Updates the poseControlled values based on the input device pose.
  98813. * @param poseData Pose coming from the device
  98814. */
  98815. updateFromDevice(poseData: DevicePose): void;
  98816. private _htmlElementAttached;
  98817. private _detachIfAttached;
  98818. /**
  98819. * WebVR's attach control will start broadcasting frames to the device.
  98820. * Note that in certain browsers (chrome for example) this function must be called
  98821. * within a user-interaction callback. Example:
  98822. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98823. *
  98824. * @param element html element to attach the vrDevice to
  98825. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98826. */
  98827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98828. /**
  98829. * Detaches the camera from the html element and disables VR
  98830. *
  98831. * @param element html element to detach from
  98832. */
  98833. detachControl(element: HTMLElement): void;
  98834. /**
  98835. * @returns the name of this class
  98836. */
  98837. getClassName(): string;
  98838. /**
  98839. * Calls resetPose on the vrDisplay
  98840. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98841. */
  98842. resetToCurrentRotation(): void;
  98843. /**
  98844. * @hidden
  98845. * Updates the rig cameras (left and right eye)
  98846. */
  98847. _updateRigCameras(): void;
  98848. private _workingVector;
  98849. private _oneVector;
  98850. private _workingMatrix;
  98851. private updateCacheCalled;
  98852. private _correctPositionIfNotTrackPosition;
  98853. /**
  98854. * @hidden
  98855. * Updates the cached values of the camera
  98856. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98857. */
  98858. _updateCache(ignoreParentClass?: boolean): void;
  98859. /**
  98860. * @hidden
  98861. * Get current device position in babylon world
  98862. */
  98863. _computeDevicePosition(): void;
  98864. /**
  98865. * Updates the current device position and rotation in the babylon world
  98866. */
  98867. update(): void;
  98868. /**
  98869. * @hidden
  98870. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98871. * @returns an identity matrix
  98872. */
  98873. _getViewMatrix(): Matrix;
  98874. private _tmpMatrix;
  98875. /**
  98876. * This function is called by the two RIG cameras.
  98877. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98878. * @hidden
  98879. */
  98880. _getWebVRViewMatrix(): Matrix;
  98881. /** @hidden */
  98882. _getWebVRProjectionMatrix(): Matrix;
  98883. private _onGamepadConnectedObserver;
  98884. private _onGamepadDisconnectedObserver;
  98885. private _updateCacheWhenTrackingDisabledObserver;
  98886. /**
  98887. * Initializes the controllers and their meshes
  98888. */
  98889. initControllers(): void;
  98890. }
  98891. }
  98892. declare module BABYLON {
  98893. /**
  98894. * "Static Class" containing the most commonly used helper while dealing with material for
  98895. * rendering purpose.
  98896. *
  98897. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98898. *
  98899. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98900. */
  98901. export class MaterialHelper {
  98902. /**
  98903. * Bind the current view position to an effect.
  98904. * @param effect The effect to be bound
  98905. * @param scene The scene the eyes position is used from
  98906. * @param variableName name of the shader variable that will hold the eye position
  98907. */
  98908. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98909. /**
  98910. * Helps preparing the defines values about the UVs in used in the effect.
  98911. * UVs are shared as much as we can accross channels in the shaders.
  98912. * @param texture The texture we are preparing the UVs for
  98913. * @param defines The defines to update
  98914. * @param key The channel key "diffuse", "specular"... used in the shader
  98915. */
  98916. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98917. /**
  98918. * Binds a texture matrix value to its corrsponding uniform
  98919. * @param texture The texture to bind the matrix for
  98920. * @param uniformBuffer The uniform buffer receivin the data
  98921. * @param key The channel key "diffuse", "specular"... used in the shader
  98922. */
  98923. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98924. /**
  98925. * Gets the current status of the fog (should it be enabled?)
  98926. * @param mesh defines the mesh to evaluate for fog support
  98927. * @param scene defines the hosting scene
  98928. * @returns true if fog must be enabled
  98929. */
  98930. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98931. /**
  98932. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98933. * @param mesh defines the current mesh
  98934. * @param scene defines the current scene
  98935. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98936. * @param pointsCloud defines if point cloud rendering has to be turned on
  98937. * @param fogEnabled defines if fog has to be turned on
  98938. * @param alphaTest defines if alpha testing has to be turned on
  98939. * @param defines defines the current list of defines
  98940. */
  98941. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98942. /**
  98943. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98944. * @param scene defines the current scene
  98945. * @param engine defines the current engine
  98946. * @param defines specifies the list of active defines
  98947. * @param useInstances defines if instances have to be turned on
  98948. * @param useClipPlane defines if clip plane have to be turned on
  98949. * @param useInstances defines if instances have to be turned on
  98950. * @param useThinInstances defines if thin instances have to be turned on
  98951. */
  98952. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98953. /**
  98954. * Prepares the defines for bones
  98955. * @param mesh The mesh containing the geometry data we will draw
  98956. * @param defines The defines to update
  98957. */
  98958. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98959. /**
  98960. * Prepares the defines for morph targets
  98961. * @param mesh The mesh containing the geometry data we will draw
  98962. * @param defines The defines to update
  98963. */
  98964. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98965. /**
  98966. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98967. * @param mesh The mesh containing the geometry data we will draw
  98968. * @param defines The defines to update
  98969. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98970. * @param useBones Precise whether bones should be used or not (override mesh info)
  98971. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98972. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98973. * @returns false if defines are considered not dirty and have not been checked
  98974. */
  98975. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98976. /**
  98977. * Prepares the defines related to multiview
  98978. * @param scene The scene we are intending to draw
  98979. * @param defines The defines to update
  98980. */
  98981. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98982. /**
  98983. * Prepares the defines related to the prepass
  98984. * @param scene The scene we are intending to draw
  98985. * @param defines The defines to update
  98986. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  98987. */
  98988. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  98989. /**
  98990. * Prepares the defines related to the light information passed in parameter
  98991. * @param scene The scene we are intending to draw
  98992. * @param mesh The mesh the effect is compiling for
  98993. * @param light The light the effect is compiling for
  98994. * @param lightIndex The index of the light
  98995. * @param defines The defines to update
  98996. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98997. * @param state Defines the current state regarding what is needed (normals, etc...)
  98998. */
  98999. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  99000. needNormals: boolean;
  99001. needRebuild: boolean;
  99002. shadowEnabled: boolean;
  99003. specularEnabled: boolean;
  99004. lightmapMode: boolean;
  99005. }): void;
  99006. /**
  99007. * Prepares the defines related to the light information passed in parameter
  99008. * @param scene The scene we are intending to draw
  99009. * @param mesh The mesh the effect is compiling for
  99010. * @param defines The defines to update
  99011. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99012. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  99013. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  99014. * @returns true if normals will be required for the rest of the effect
  99015. */
  99016. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  99017. /**
  99018. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  99019. * @param lightIndex defines the light index
  99020. * @param uniformsList The uniform list
  99021. * @param samplersList The sampler list
  99022. * @param projectedLightTexture defines if projected texture must be used
  99023. * @param uniformBuffersList defines an optional list of uniform buffers
  99024. */
  99025. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99026. /**
  99027. * Prepares the uniforms and samplers list to be used in the effect
  99028. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99029. * @param samplersList The sampler list
  99030. * @param defines The defines helping in the list generation
  99031. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99032. */
  99033. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99034. /**
  99035. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  99036. * @param defines The defines to update while falling back
  99037. * @param fallbacks The authorized effect fallbacks
  99038. * @param maxSimultaneousLights The maximum number of lights allowed
  99039. * @param rank the current rank of the Effect
  99040. * @returns The newly affected rank
  99041. */
  99042. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  99043. private static _TmpMorphInfluencers;
  99044. /**
  99045. * Prepares the list of attributes required for morph targets according to the effect defines.
  99046. * @param attribs The current list of supported attribs
  99047. * @param mesh The mesh to prepare the morph targets attributes for
  99048. * @param influencers The number of influencers
  99049. */
  99050. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  99051. /**
  99052. * Prepares the list of attributes required for morph targets according to the effect defines.
  99053. * @param attribs The current list of supported attribs
  99054. * @param mesh The mesh to prepare the morph targets attributes for
  99055. * @param defines The current Defines of the effect
  99056. */
  99057. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  99058. /**
  99059. * Prepares the list of attributes required for bones according to the effect defines.
  99060. * @param attribs The current list of supported attribs
  99061. * @param mesh The mesh to prepare the bones attributes for
  99062. * @param defines The current Defines of the effect
  99063. * @param fallbacks The current efffect fallback strategy
  99064. */
  99065. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  99066. /**
  99067. * Check and prepare the list of attributes required for instances according to the effect defines.
  99068. * @param attribs The current list of supported attribs
  99069. * @param defines The current MaterialDefines of the effect
  99070. */
  99071. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  99072. /**
  99073. * Add the list of attributes required for instances to the attribs array.
  99074. * @param attribs The current list of supported attribs
  99075. */
  99076. static PushAttributesForInstances(attribs: string[]): void;
  99077. /**
  99078. * Binds the light information to the effect.
  99079. * @param light The light containing the generator
  99080. * @param effect The effect we are binding the data to
  99081. * @param lightIndex The light index in the effect used to render
  99082. */
  99083. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  99084. /**
  99085. * Binds the lights information from the scene to the effect for the given mesh.
  99086. * @param light Light to bind
  99087. * @param lightIndex Light index
  99088. * @param scene The scene where the light belongs to
  99089. * @param effect The effect we are binding the data to
  99090. * @param useSpecular Defines if specular is supported
  99091. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99092. */
  99093. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99094. /**
  99095. * Binds the lights information from the scene to the effect for the given mesh.
  99096. * @param scene The scene the lights belongs to
  99097. * @param mesh The mesh we are binding the information to render
  99098. * @param effect The effect we are binding the data to
  99099. * @param defines The generated defines for the effect
  99100. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  99101. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99102. */
  99103. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  99104. private static _tempFogColor;
  99105. /**
  99106. * Binds the fog information from the scene to the effect for the given mesh.
  99107. * @param scene The scene the lights belongs to
  99108. * @param mesh The mesh we are binding the information to render
  99109. * @param effect The effect we are binding the data to
  99110. * @param linearSpace Defines if the fog effect is applied in linear space
  99111. */
  99112. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  99113. /**
  99114. * Binds the bones information from the mesh to the effect.
  99115. * @param mesh The mesh we are binding the information to render
  99116. * @param effect The effect we are binding the data to
  99117. */
  99118. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  99119. /**
  99120. * Binds the morph targets information from the mesh to the effect.
  99121. * @param abstractMesh The mesh we are binding the information to render
  99122. * @param effect The effect we are binding the data to
  99123. */
  99124. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  99125. /**
  99126. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  99127. * @param defines The generated defines used in the effect
  99128. * @param effect The effect we are binding the data to
  99129. * @param scene The scene we are willing to render with logarithmic scale for
  99130. */
  99131. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  99132. /**
  99133. * Binds the clip plane information from the scene to the effect.
  99134. * @param scene The scene the clip plane information are extracted from
  99135. * @param effect The effect we are binding the data to
  99136. */
  99137. static BindClipPlane(effect: Effect, scene: Scene): void;
  99138. }
  99139. }
  99140. declare module BABYLON {
  99141. /**
  99142. * Block used to expose an input value
  99143. */
  99144. export class InputBlock extends NodeMaterialBlock {
  99145. private _mode;
  99146. private _associatedVariableName;
  99147. private _storedValue;
  99148. private _valueCallback;
  99149. private _type;
  99150. private _animationType;
  99151. /** Gets or set a value used to limit the range of float values */
  99152. min: number;
  99153. /** Gets or set a value used to limit the range of float values */
  99154. max: number;
  99155. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  99156. isBoolean: boolean;
  99157. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  99158. matrixMode: number;
  99159. /** @hidden */
  99160. _systemValue: Nullable<NodeMaterialSystemValues>;
  99161. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  99162. visibleInInspector: boolean;
  99163. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  99164. isConstant: boolean;
  99165. /** Gets or sets the group to use to display this block in the Inspector */
  99166. groupInInspector: string;
  99167. /** Gets an observable raised when the value is changed */
  99168. onValueChangedObservable: Observable<InputBlock>;
  99169. /**
  99170. * Gets or sets the connection point type (default is float)
  99171. */
  99172. get type(): NodeMaterialBlockConnectionPointTypes;
  99173. /**
  99174. * Creates a new InputBlock
  99175. * @param name defines the block name
  99176. * @param target defines the target of that block (Vertex by default)
  99177. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  99178. */
  99179. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  99180. /**
  99181. * Validates if a name is a reserve word.
  99182. * @param newName the new name to be given to the node.
  99183. * @returns false if the name is a reserve word, else true.
  99184. */
  99185. validateBlockName(newName: string): boolean;
  99186. /**
  99187. * Gets the output component
  99188. */
  99189. get output(): NodeMaterialConnectionPoint;
  99190. /**
  99191. * Set the source of this connection point to a vertex attribute
  99192. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  99193. * @returns the current connection point
  99194. */
  99195. setAsAttribute(attributeName?: string): InputBlock;
  99196. /**
  99197. * Set the source of this connection point to a system value
  99198. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  99199. * @returns the current connection point
  99200. */
  99201. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  99202. /**
  99203. * Gets or sets the value of that point.
  99204. * Please note that this value will be ignored if valueCallback is defined
  99205. */
  99206. get value(): any;
  99207. set value(value: any);
  99208. /**
  99209. * Gets or sets a callback used to get the value of that point.
  99210. * Please note that setting this value will force the connection point to ignore the value property
  99211. */
  99212. get valueCallback(): () => any;
  99213. set valueCallback(value: () => any);
  99214. /**
  99215. * Gets or sets the associated variable name in the shader
  99216. */
  99217. get associatedVariableName(): string;
  99218. set associatedVariableName(value: string);
  99219. /** Gets or sets the type of animation applied to the input */
  99220. get animationType(): AnimatedInputBlockTypes;
  99221. set animationType(value: AnimatedInputBlockTypes);
  99222. /**
  99223. * Gets a boolean indicating that this connection point not defined yet
  99224. */
  99225. get isUndefined(): boolean;
  99226. /**
  99227. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  99228. * In this case the connection point name must be the name of the uniform to use.
  99229. * Can only be set on inputs
  99230. */
  99231. get isUniform(): boolean;
  99232. set isUniform(value: boolean);
  99233. /**
  99234. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  99235. * In this case the connection point name must be the name of the attribute to use
  99236. * Can only be set on inputs
  99237. */
  99238. get isAttribute(): boolean;
  99239. set isAttribute(value: boolean);
  99240. /**
  99241. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  99242. * Can only be set on exit points
  99243. */
  99244. get isVarying(): boolean;
  99245. set isVarying(value: boolean);
  99246. /**
  99247. * Gets a boolean indicating that the current connection point is a system value
  99248. */
  99249. get isSystemValue(): boolean;
  99250. /**
  99251. * Gets or sets the current well known value or null if not defined as a system value
  99252. */
  99253. get systemValue(): Nullable<NodeMaterialSystemValues>;
  99254. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  99255. /**
  99256. * Gets the current class name
  99257. * @returns the class name
  99258. */
  99259. getClassName(): string;
  99260. /**
  99261. * Animate the input if animationType !== None
  99262. * @param scene defines the rendering scene
  99263. */
  99264. animate(scene: Scene): void;
  99265. private _emitDefine;
  99266. initialize(state: NodeMaterialBuildState): void;
  99267. /**
  99268. * Set the input block to its default value (based on its type)
  99269. */
  99270. setDefaultValue(): void;
  99271. private _emitConstant;
  99272. /** @hidden */
  99273. get _noContextSwitch(): boolean;
  99274. private _emit;
  99275. /** @hidden */
  99276. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  99277. /** @hidden */
  99278. _transmit(effect: Effect, scene: Scene): void;
  99279. protected _buildBlock(state: NodeMaterialBuildState): void;
  99280. protected _dumpPropertiesCode(): string;
  99281. dispose(): void;
  99282. serialize(): any;
  99283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99284. }
  99285. }
  99286. declare module BABYLON {
  99287. /**
  99288. * Enum used to define the compatibility state between two connection points
  99289. */
  99290. export enum NodeMaterialConnectionPointCompatibilityStates {
  99291. /** Points are compatibles */
  99292. Compatible = 0,
  99293. /** Points are incompatible because of their types */
  99294. TypeIncompatible = 1,
  99295. /** Points are incompatible because of their targets (vertex vs fragment) */
  99296. TargetIncompatible = 2
  99297. }
  99298. /**
  99299. * Defines the direction of a connection point
  99300. */
  99301. export enum NodeMaterialConnectionPointDirection {
  99302. /** Input */
  99303. Input = 0,
  99304. /** Output */
  99305. Output = 1
  99306. }
  99307. /**
  99308. * Defines a connection point for a block
  99309. */
  99310. export class NodeMaterialConnectionPoint {
  99311. /** @hidden */
  99312. _ownerBlock: NodeMaterialBlock;
  99313. /** @hidden */
  99314. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  99315. private _endpoints;
  99316. private _associatedVariableName;
  99317. private _direction;
  99318. /** @hidden */
  99319. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99320. /** @hidden */
  99321. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99322. private _type;
  99323. /** @hidden */
  99324. _enforceAssociatedVariableName: boolean;
  99325. /** Gets the direction of the point */
  99326. get direction(): NodeMaterialConnectionPointDirection;
  99327. /** Indicates that this connection point needs dual validation before being connected to another point */
  99328. needDualDirectionValidation: boolean;
  99329. /**
  99330. * Gets or sets the additional types supported by this connection point
  99331. */
  99332. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99333. /**
  99334. * Gets or sets the additional types excluded by this connection point
  99335. */
  99336. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99337. /**
  99338. * Observable triggered when this point is connected
  99339. */
  99340. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  99341. /**
  99342. * Gets or sets the associated variable name in the shader
  99343. */
  99344. get associatedVariableName(): string;
  99345. set associatedVariableName(value: string);
  99346. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  99347. get innerType(): NodeMaterialBlockConnectionPointTypes;
  99348. /**
  99349. * Gets or sets the connection point type (default is float)
  99350. */
  99351. get type(): NodeMaterialBlockConnectionPointTypes;
  99352. set type(value: NodeMaterialBlockConnectionPointTypes);
  99353. /**
  99354. * Gets or sets the connection point name
  99355. */
  99356. name: string;
  99357. /**
  99358. * Gets or sets the connection point name
  99359. */
  99360. displayName: string;
  99361. /**
  99362. * Gets or sets a boolean indicating that this connection point can be omitted
  99363. */
  99364. isOptional: boolean;
  99365. /**
  99366. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99367. */
  99368. isExposedOnFrame: boolean;
  99369. /**
  99370. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99371. */
  99372. define: string;
  99373. /** @hidden */
  99374. _prioritizeVertex: boolean;
  99375. private _target;
  99376. /** Gets or sets the target of that connection point */
  99377. get target(): NodeMaterialBlockTargets;
  99378. set target(value: NodeMaterialBlockTargets);
  99379. /**
  99380. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99381. */
  99382. get isConnected(): boolean;
  99383. /**
  99384. * Gets a boolean indicating that the current point is connected to an input block
  99385. */
  99386. get isConnectedToInputBlock(): boolean;
  99387. /**
  99388. * Gets a the connected input block (if any)
  99389. */
  99390. get connectInputBlock(): Nullable<InputBlock>;
  99391. /** Get the other side of the connection (if any) */
  99392. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99393. /** Get the block that owns this connection point */
  99394. get ownerBlock(): NodeMaterialBlock;
  99395. /** Get the block connected on the other side of this connection (if any) */
  99396. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99397. /** Get the block connected on the endpoints of this connection (if any) */
  99398. get connectedBlocks(): Array<NodeMaterialBlock>;
  99399. /** Gets the list of connected endpoints */
  99400. get endpoints(): NodeMaterialConnectionPoint[];
  99401. /** Gets a boolean indicating if that output point is connected to at least one input */
  99402. get hasEndpoints(): boolean;
  99403. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99404. get isConnectedInVertexShader(): boolean;
  99405. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99406. get isConnectedInFragmentShader(): boolean;
  99407. /**
  99408. * Creates a block suitable to be used as an input for this input point.
  99409. * If null is returned, a block based on the point type will be created.
  99410. * @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
  99411. */
  99412. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99413. /**
  99414. * Creates a new connection point
  99415. * @param name defines the connection point name
  99416. * @param ownerBlock defines the block hosting this connection point
  99417. * @param direction defines the direction of the connection point
  99418. */
  99419. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99420. /**
  99421. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99422. * @returns the class name
  99423. */
  99424. getClassName(): string;
  99425. /**
  99426. * Gets a boolean indicating if the current point can be connected to another point
  99427. * @param connectionPoint defines the other connection point
  99428. * @returns a boolean
  99429. */
  99430. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99431. /**
  99432. * Gets a number indicating if the current point can be connected to another point
  99433. * @param connectionPoint defines the other connection point
  99434. * @returns a number defining the compatibility state
  99435. */
  99436. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99437. /**
  99438. * Connect this point to another connection point
  99439. * @param connectionPoint defines the other connection point
  99440. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  99441. * @returns the current connection point
  99442. */
  99443. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  99444. /**
  99445. * Disconnect this point from one of his endpoint
  99446. * @param endpoint defines the other connection point
  99447. * @returns the current connection point
  99448. */
  99449. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  99450. /**
  99451. * Serializes this point in a JSON representation
  99452. * @param isInput defines if the connection point is an input (default is true)
  99453. * @returns the serialized point object
  99454. */
  99455. serialize(isInput?: boolean): any;
  99456. /**
  99457. * Release resources
  99458. */
  99459. dispose(): void;
  99460. }
  99461. }
  99462. declare module BABYLON {
  99463. /**
  99464. * Enum used to define the material modes
  99465. */
  99466. export enum NodeMaterialModes {
  99467. /** Regular material */
  99468. Material = 0,
  99469. /** For post process */
  99470. PostProcess = 1,
  99471. /** For particle system */
  99472. Particle = 2
  99473. }
  99474. }
  99475. declare module BABYLON {
  99476. /**
  99477. * Block used to read a texture from a sampler
  99478. */
  99479. export class TextureBlock extends NodeMaterialBlock {
  99480. private _defineName;
  99481. private _linearDefineName;
  99482. private _gammaDefineName;
  99483. private _tempTextureRead;
  99484. private _samplerName;
  99485. private _transformedUVName;
  99486. private _textureTransformName;
  99487. private _textureInfoName;
  99488. private _mainUVName;
  99489. private _mainUVDefineName;
  99490. private _fragmentOnly;
  99491. /**
  99492. * Gets or sets the texture associated with the node
  99493. */
  99494. texture: Nullable<Texture>;
  99495. /**
  99496. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99497. */
  99498. convertToGammaSpace: boolean;
  99499. /**
  99500. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99501. */
  99502. convertToLinearSpace: boolean;
  99503. /**
  99504. * Create a new TextureBlock
  99505. * @param name defines the block name
  99506. */
  99507. constructor(name: string, fragmentOnly?: boolean);
  99508. /**
  99509. * Gets the current class name
  99510. * @returns the class name
  99511. */
  99512. getClassName(): string;
  99513. /**
  99514. * Gets the uv input component
  99515. */
  99516. get uv(): NodeMaterialConnectionPoint;
  99517. /**
  99518. * Gets the rgba output component
  99519. */
  99520. get rgba(): NodeMaterialConnectionPoint;
  99521. /**
  99522. * Gets the rgb output component
  99523. */
  99524. get rgb(): NodeMaterialConnectionPoint;
  99525. /**
  99526. * Gets the r output component
  99527. */
  99528. get r(): NodeMaterialConnectionPoint;
  99529. /**
  99530. * Gets the g output component
  99531. */
  99532. get g(): NodeMaterialConnectionPoint;
  99533. /**
  99534. * Gets the b output component
  99535. */
  99536. get b(): NodeMaterialConnectionPoint;
  99537. /**
  99538. * Gets the a output component
  99539. */
  99540. get a(): NodeMaterialConnectionPoint;
  99541. get target(): NodeMaterialBlockTargets;
  99542. autoConfigure(material: NodeMaterial): void;
  99543. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99544. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99545. isReady(): boolean;
  99546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99547. private get _isMixed();
  99548. private _injectVertexCode;
  99549. private _writeTextureRead;
  99550. private _writeOutput;
  99551. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99552. protected _dumpPropertiesCode(): string;
  99553. serialize(): any;
  99554. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99555. }
  99556. }
  99557. declare module BABYLON {
  99558. /** @hidden */
  99559. export var reflectionFunction: {
  99560. name: string;
  99561. shader: string;
  99562. };
  99563. }
  99564. declare module BABYLON {
  99565. /**
  99566. * Base block used to read a reflection texture from a sampler
  99567. */
  99568. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  99569. /** @hidden */
  99570. _define3DName: string;
  99571. /** @hidden */
  99572. _defineCubicName: string;
  99573. /** @hidden */
  99574. _defineExplicitName: string;
  99575. /** @hidden */
  99576. _defineProjectionName: string;
  99577. /** @hidden */
  99578. _defineLocalCubicName: string;
  99579. /** @hidden */
  99580. _defineSphericalName: string;
  99581. /** @hidden */
  99582. _definePlanarName: string;
  99583. /** @hidden */
  99584. _defineEquirectangularName: string;
  99585. /** @hidden */
  99586. _defineMirroredEquirectangularFixedName: string;
  99587. /** @hidden */
  99588. _defineEquirectangularFixedName: string;
  99589. /** @hidden */
  99590. _defineSkyboxName: string;
  99591. /** @hidden */
  99592. _defineOppositeZ: string;
  99593. /** @hidden */
  99594. _cubeSamplerName: string;
  99595. /** @hidden */
  99596. _2DSamplerName: string;
  99597. protected _positionUVWName: string;
  99598. protected _directionWName: string;
  99599. protected _reflectionVectorName: string;
  99600. /** @hidden */
  99601. _reflectionCoordsName: string;
  99602. /** @hidden */
  99603. _reflectionMatrixName: string;
  99604. protected _reflectionColorName: string;
  99605. /**
  99606. * Gets or sets the texture associated with the node
  99607. */
  99608. texture: Nullable<BaseTexture>;
  99609. /**
  99610. * Create a new ReflectionTextureBaseBlock
  99611. * @param name defines the block name
  99612. */
  99613. constructor(name: string);
  99614. /**
  99615. * Gets the current class name
  99616. * @returns the class name
  99617. */
  99618. getClassName(): string;
  99619. /**
  99620. * Gets the world position input component
  99621. */
  99622. abstract get position(): NodeMaterialConnectionPoint;
  99623. /**
  99624. * Gets the world position input component
  99625. */
  99626. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99627. /**
  99628. * Gets the world normal input component
  99629. */
  99630. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99631. /**
  99632. * Gets the world input component
  99633. */
  99634. abstract get world(): NodeMaterialConnectionPoint;
  99635. /**
  99636. * Gets the camera (or eye) position component
  99637. */
  99638. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99639. /**
  99640. * Gets the view input component
  99641. */
  99642. abstract get view(): NodeMaterialConnectionPoint;
  99643. protected _getTexture(): Nullable<BaseTexture>;
  99644. autoConfigure(material: NodeMaterial): void;
  99645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99646. isReady(): boolean;
  99647. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99648. /**
  99649. * Gets the code to inject in the vertex shader
  99650. * @param state current state of the node material building
  99651. * @returns the shader code
  99652. */
  99653. handleVertexSide(state: NodeMaterialBuildState): string;
  99654. /**
  99655. * Handles the inits for the fragment code path
  99656. * @param state node material build state
  99657. */
  99658. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99659. /**
  99660. * Generates the reflection coords code for the fragment code path
  99661. * @param worldNormalVarName name of the world normal variable
  99662. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99663. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99664. * @returns the shader code
  99665. */
  99666. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99667. /**
  99668. * Generates the reflection color code for the fragment code path
  99669. * @param lodVarName name of the lod variable
  99670. * @param swizzleLookupTexture swizzle to use for the final color variable
  99671. * @returns the shader code
  99672. */
  99673. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99674. /**
  99675. * Generates the code corresponding to the connected output points
  99676. * @param state node material build state
  99677. * @param varName name of the variable to output
  99678. * @returns the shader code
  99679. */
  99680. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99681. protected _buildBlock(state: NodeMaterialBuildState): this;
  99682. protected _dumpPropertiesCode(): string;
  99683. serialize(): any;
  99684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99685. }
  99686. }
  99687. declare module BABYLON {
  99688. /**
  99689. * Defines a connection point to be used for points with a custom object type
  99690. */
  99691. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99692. private _blockType;
  99693. private _blockName;
  99694. private _nameForCheking?;
  99695. /**
  99696. * Creates a new connection point
  99697. * @param name defines the connection point name
  99698. * @param ownerBlock defines the block hosting this connection point
  99699. * @param direction defines the direction of the connection point
  99700. */
  99701. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99702. /**
  99703. * Gets a number indicating if the current point can be connected to another point
  99704. * @param connectionPoint defines the other connection point
  99705. * @returns a number defining the compatibility state
  99706. */
  99707. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99708. /**
  99709. * Creates a block suitable to be used as an input for this input point.
  99710. * If null is returned, a block based on the point type will be created.
  99711. * @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
  99712. */
  99713. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99714. }
  99715. }
  99716. declare module BABYLON {
  99717. /**
  99718. * Enum defining the type of properties that can be edited in the property pages in the NME
  99719. */
  99720. export enum PropertyTypeForEdition {
  99721. /** property is a boolean */
  99722. Boolean = 0,
  99723. /** property is a float */
  99724. Float = 1,
  99725. /** property is a Vector2 */
  99726. Vector2 = 2,
  99727. /** property is a list of values */
  99728. List = 3
  99729. }
  99730. /**
  99731. * Interface that defines an option in a variable of type list
  99732. */
  99733. export interface IEditablePropertyListOption {
  99734. /** label of the option */
  99735. "label": string;
  99736. /** value of the option */
  99737. "value": number;
  99738. }
  99739. /**
  99740. * Interface that defines the options available for an editable property
  99741. */
  99742. export interface IEditablePropertyOption {
  99743. /** min value */
  99744. "min"?: number;
  99745. /** max value */
  99746. "max"?: number;
  99747. /** notifiers: indicates which actions to take when the property is changed */
  99748. "notifiers"?: {
  99749. /** the material should be rebuilt */
  99750. "rebuild"?: boolean;
  99751. /** the preview should be updated */
  99752. "update"?: boolean;
  99753. };
  99754. /** list of the options for a variable of type list */
  99755. "options"?: IEditablePropertyListOption[];
  99756. }
  99757. /**
  99758. * Interface that describes an editable property
  99759. */
  99760. export interface IPropertyDescriptionForEdition {
  99761. /** name of the property */
  99762. "propertyName": string;
  99763. /** display name of the property */
  99764. "displayName": string;
  99765. /** type of the property */
  99766. "type": PropertyTypeForEdition;
  99767. /** group of the property - all properties with the same group value will be displayed in a specific section */
  99768. "groupName": string;
  99769. /** options for the property */
  99770. "options": IEditablePropertyOption;
  99771. }
  99772. /**
  99773. * Decorator that flags a property in a node material block as being editable
  99774. */
  99775. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  99776. }
  99777. declare module BABYLON {
  99778. /**
  99779. * Block used to implement the refraction part of the sub surface module of the PBR material
  99780. */
  99781. export class RefractionBlock extends NodeMaterialBlock {
  99782. /** @hidden */
  99783. _define3DName: string;
  99784. /** @hidden */
  99785. _refractionMatrixName: string;
  99786. /** @hidden */
  99787. _defineLODRefractionAlpha: string;
  99788. /** @hidden */
  99789. _defineLinearSpecularRefraction: string;
  99790. /** @hidden */
  99791. _defineOppositeZ: string;
  99792. /** @hidden */
  99793. _cubeSamplerName: string;
  99794. /** @hidden */
  99795. _2DSamplerName: string;
  99796. /** @hidden */
  99797. _vRefractionMicrosurfaceInfosName: string;
  99798. /** @hidden */
  99799. _vRefractionInfosName: string;
  99800. private _scene;
  99801. /**
  99802. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99803. * Materials half opaque for instance using refraction could benefit from this control.
  99804. */
  99805. linkRefractionWithTransparency: boolean;
  99806. /**
  99807. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99808. */
  99809. invertRefractionY: boolean;
  99810. /**
  99811. * Gets or sets the texture associated with the node
  99812. */
  99813. texture: Nullable<BaseTexture>;
  99814. /**
  99815. * Create a new RefractionBlock
  99816. * @param name defines the block name
  99817. */
  99818. constructor(name: string);
  99819. /**
  99820. * Gets the current class name
  99821. * @returns the class name
  99822. */
  99823. getClassName(): string;
  99824. /**
  99825. * Gets the intensity input component
  99826. */
  99827. get intensity(): NodeMaterialConnectionPoint;
  99828. /**
  99829. * Gets the index of refraction input component
  99830. */
  99831. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99832. /**
  99833. * Gets the tint at distance input component
  99834. */
  99835. get tintAtDistance(): NodeMaterialConnectionPoint;
  99836. /**
  99837. * Gets the view input component
  99838. */
  99839. get view(): NodeMaterialConnectionPoint;
  99840. /**
  99841. * Gets the refraction object output component
  99842. */
  99843. get refraction(): NodeMaterialConnectionPoint;
  99844. /**
  99845. * Returns true if the block has a texture
  99846. */
  99847. get hasTexture(): boolean;
  99848. protected _getTexture(): Nullable<BaseTexture>;
  99849. autoConfigure(material: NodeMaterial): void;
  99850. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99851. isReady(): boolean;
  99852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99853. /**
  99854. * Gets the main code of the block (fragment side)
  99855. * @param state current state of the node material building
  99856. * @returns the shader code
  99857. */
  99858. getCode(state: NodeMaterialBuildState): string;
  99859. protected _buildBlock(state: NodeMaterialBuildState): this;
  99860. protected _dumpPropertiesCode(): string;
  99861. serialize(): any;
  99862. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99863. }
  99864. }
  99865. declare module BABYLON {
  99866. /**
  99867. * Base block used as input for post process
  99868. */
  99869. export class CurrentScreenBlock extends NodeMaterialBlock {
  99870. private _samplerName;
  99871. private _linearDefineName;
  99872. private _gammaDefineName;
  99873. private _mainUVName;
  99874. private _tempTextureRead;
  99875. /**
  99876. * Gets or sets the texture associated with the node
  99877. */
  99878. texture: Nullable<BaseTexture>;
  99879. /**
  99880. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99881. */
  99882. convertToGammaSpace: boolean;
  99883. /**
  99884. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99885. */
  99886. convertToLinearSpace: boolean;
  99887. /**
  99888. * Create a new CurrentScreenBlock
  99889. * @param name defines the block name
  99890. */
  99891. constructor(name: string);
  99892. /**
  99893. * Gets the current class name
  99894. * @returns the class name
  99895. */
  99896. getClassName(): string;
  99897. /**
  99898. * Gets the uv input component
  99899. */
  99900. get uv(): NodeMaterialConnectionPoint;
  99901. /**
  99902. * Gets the rgba output component
  99903. */
  99904. get rgba(): NodeMaterialConnectionPoint;
  99905. /**
  99906. * Gets the rgb output component
  99907. */
  99908. get rgb(): NodeMaterialConnectionPoint;
  99909. /**
  99910. * Gets the r output component
  99911. */
  99912. get r(): NodeMaterialConnectionPoint;
  99913. /**
  99914. * Gets the g output component
  99915. */
  99916. get g(): NodeMaterialConnectionPoint;
  99917. /**
  99918. * Gets the b output component
  99919. */
  99920. get b(): NodeMaterialConnectionPoint;
  99921. /**
  99922. * Gets the a output component
  99923. */
  99924. get a(): NodeMaterialConnectionPoint;
  99925. /**
  99926. * Initialize the block and prepare the context for build
  99927. * @param state defines the state that will be used for the build
  99928. */
  99929. initialize(state: NodeMaterialBuildState): void;
  99930. get target(): NodeMaterialBlockTargets;
  99931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99932. isReady(): boolean;
  99933. private _injectVertexCode;
  99934. private _writeTextureRead;
  99935. private _writeOutput;
  99936. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99937. serialize(): any;
  99938. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99939. }
  99940. }
  99941. declare module BABYLON {
  99942. /**
  99943. * Base block used for the particle texture
  99944. */
  99945. export class ParticleTextureBlock extends NodeMaterialBlock {
  99946. private _samplerName;
  99947. private _linearDefineName;
  99948. private _gammaDefineName;
  99949. private _tempTextureRead;
  99950. /**
  99951. * Gets or sets the texture associated with the node
  99952. */
  99953. texture: Nullable<BaseTexture>;
  99954. /**
  99955. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99956. */
  99957. convertToGammaSpace: boolean;
  99958. /**
  99959. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99960. */
  99961. convertToLinearSpace: boolean;
  99962. /**
  99963. * Create a new ParticleTextureBlock
  99964. * @param name defines the block name
  99965. */
  99966. constructor(name: string);
  99967. /**
  99968. * Gets the current class name
  99969. * @returns the class name
  99970. */
  99971. getClassName(): string;
  99972. /**
  99973. * Gets the uv input component
  99974. */
  99975. get uv(): NodeMaterialConnectionPoint;
  99976. /**
  99977. * Gets the rgba output component
  99978. */
  99979. get rgba(): NodeMaterialConnectionPoint;
  99980. /**
  99981. * Gets the rgb output component
  99982. */
  99983. get rgb(): NodeMaterialConnectionPoint;
  99984. /**
  99985. * Gets the r output component
  99986. */
  99987. get r(): NodeMaterialConnectionPoint;
  99988. /**
  99989. * Gets the g output component
  99990. */
  99991. get g(): NodeMaterialConnectionPoint;
  99992. /**
  99993. * Gets the b output component
  99994. */
  99995. get b(): NodeMaterialConnectionPoint;
  99996. /**
  99997. * Gets the a output component
  99998. */
  99999. get a(): NodeMaterialConnectionPoint;
  100000. /**
  100001. * Initialize the block and prepare the context for build
  100002. * @param state defines the state that will be used for the build
  100003. */
  100004. initialize(state: NodeMaterialBuildState): void;
  100005. autoConfigure(material: NodeMaterial): void;
  100006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100007. isReady(): boolean;
  100008. private _writeOutput;
  100009. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100010. serialize(): any;
  100011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100012. }
  100013. }
  100014. declare module BABYLON {
  100015. /**
  100016. * Class used to store shared data between 2 NodeMaterialBuildState
  100017. */
  100018. export class NodeMaterialBuildStateSharedData {
  100019. /**
  100020. * Gets the list of emitted varyings
  100021. */
  100022. temps: string[];
  100023. /**
  100024. * Gets the list of emitted varyings
  100025. */
  100026. varyings: string[];
  100027. /**
  100028. * Gets the varying declaration string
  100029. */
  100030. varyingDeclaration: string;
  100031. /**
  100032. * Input blocks
  100033. */
  100034. inputBlocks: InputBlock[];
  100035. /**
  100036. * Input blocks
  100037. */
  100038. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100039. /**
  100040. * Bindable blocks (Blocks that need to set data to the effect)
  100041. */
  100042. bindableBlocks: NodeMaterialBlock[];
  100043. /**
  100044. * List of blocks that can provide a compilation fallback
  100045. */
  100046. blocksWithFallbacks: NodeMaterialBlock[];
  100047. /**
  100048. * List of blocks that can provide a define update
  100049. */
  100050. blocksWithDefines: NodeMaterialBlock[];
  100051. /**
  100052. * List of blocks that can provide a repeatable content
  100053. */
  100054. repeatableContentBlocks: NodeMaterialBlock[];
  100055. /**
  100056. * List of blocks that can provide a dynamic list of uniforms
  100057. */
  100058. dynamicUniformBlocks: NodeMaterialBlock[];
  100059. /**
  100060. * List of blocks that can block the isReady function for the material
  100061. */
  100062. blockingBlocks: NodeMaterialBlock[];
  100063. /**
  100064. * Gets the list of animated inputs
  100065. */
  100066. animatedInputs: InputBlock[];
  100067. /**
  100068. * Build Id used to avoid multiple recompilations
  100069. */
  100070. buildId: number;
  100071. /** List of emitted variables */
  100072. variableNames: {
  100073. [key: string]: number;
  100074. };
  100075. /** List of emitted defines */
  100076. defineNames: {
  100077. [key: string]: number;
  100078. };
  100079. /** Should emit comments? */
  100080. emitComments: boolean;
  100081. /** Emit build activity */
  100082. verbose: boolean;
  100083. /** Gets or sets the hosting scene */
  100084. scene: Scene;
  100085. /**
  100086. * Gets the compilation hints emitted at compilation time
  100087. */
  100088. hints: {
  100089. needWorldViewMatrix: boolean;
  100090. needWorldViewProjectionMatrix: boolean;
  100091. needAlphaBlending: boolean;
  100092. needAlphaTesting: boolean;
  100093. };
  100094. /**
  100095. * List of compilation checks
  100096. */
  100097. checks: {
  100098. emitVertex: boolean;
  100099. emitFragment: boolean;
  100100. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  100101. };
  100102. /**
  100103. * Is vertex program allowed to be empty?
  100104. */
  100105. allowEmptyVertexProgram: boolean;
  100106. /** Creates a new shared data */
  100107. constructor();
  100108. /**
  100109. * Emits console errors and exceptions if there is a failing check
  100110. */
  100111. emitErrors(): void;
  100112. }
  100113. }
  100114. declare module BABYLON {
  100115. /**
  100116. * Class used to store node based material build state
  100117. */
  100118. export class NodeMaterialBuildState {
  100119. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  100120. supportUniformBuffers: boolean;
  100121. /**
  100122. * Gets the list of emitted attributes
  100123. */
  100124. attributes: string[];
  100125. /**
  100126. * Gets the list of emitted uniforms
  100127. */
  100128. uniforms: string[];
  100129. /**
  100130. * Gets the list of emitted constants
  100131. */
  100132. constants: string[];
  100133. /**
  100134. * Gets the list of emitted samplers
  100135. */
  100136. samplers: string[];
  100137. /**
  100138. * Gets the list of emitted functions
  100139. */
  100140. functions: {
  100141. [key: string]: string;
  100142. };
  100143. /**
  100144. * Gets the list of emitted extensions
  100145. */
  100146. extensions: {
  100147. [key: string]: string;
  100148. };
  100149. /**
  100150. * Gets the target of the compilation state
  100151. */
  100152. target: NodeMaterialBlockTargets;
  100153. /**
  100154. * Gets the list of emitted counters
  100155. */
  100156. counters: {
  100157. [key: string]: number;
  100158. };
  100159. /**
  100160. * Shared data between multiple NodeMaterialBuildState instances
  100161. */
  100162. sharedData: NodeMaterialBuildStateSharedData;
  100163. /** @hidden */
  100164. _vertexState: NodeMaterialBuildState;
  100165. /** @hidden */
  100166. _attributeDeclaration: string;
  100167. /** @hidden */
  100168. _uniformDeclaration: string;
  100169. /** @hidden */
  100170. _constantDeclaration: string;
  100171. /** @hidden */
  100172. _samplerDeclaration: string;
  100173. /** @hidden */
  100174. _varyingTransfer: string;
  100175. /** @hidden */
  100176. _injectAtEnd: string;
  100177. private _repeatableContentAnchorIndex;
  100178. /** @hidden */
  100179. _builtCompilationString: string;
  100180. /**
  100181. * Gets the emitted compilation strings
  100182. */
  100183. compilationString: string;
  100184. /**
  100185. * Finalize the compilation strings
  100186. * @param state defines the current compilation state
  100187. */
  100188. finalize(state: NodeMaterialBuildState): void;
  100189. /** @hidden */
  100190. get _repeatableContentAnchor(): string;
  100191. /** @hidden */
  100192. _getFreeVariableName(prefix: string): string;
  100193. /** @hidden */
  100194. _getFreeDefineName(prefix: string): string;
  100195. /** @hidden */
  100196. _excludeVariableName(name: string): void;
  100197. /** @hidden */
  100198. _emit2DSampler(name: string): void;
  100199. /** @hidden */
  100200. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  100201. /** @hidden */
  100202. _emitExtension(name: string, extension: string, define?: string): void;
  100203. /** @hidden */
  100204. _emitFunction(name: string, code: string, comments: string): void;
  100205. /** @hidden */
  100206. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  100207. replaceStrings?: {
  100208. search: RegExp;
  100209. replace: string;
  100210. }[];
  100211. repeatKey?: string;
  100212. }): string;
  100213. /** @hidden */
  100214. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  100215. repeatKey?: string;
  100216. removeAttributes?: boolean;
  100217. removeUniforms?: boolean;
  100218. removeVaryings?: boolean;
  100219. removeIfDef?: boolean;
  100220. replaceStrings?: {
  100221. search: RegExp;
  100222. replace: string;
  100223. }[];
  100224. }, storeKey?: string): void;
  100225. /** @hidden */
  100226. _registerTempVariable(name: string): boolean;
  100227. /** @hidden */
  100228. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  100229. /** @hidden */
  100230. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  100231. /** @hidden */
  100232. _emitFloat(value: number): string;
  100233. }
  100234. }
  100235. declare module BABYLON {
  100236. /**
  100237. * Helper class used to generate session unique ID
  100238. */
  100239. export class UniqueIdGenerator {
  100240. private static _UniqueIdCounter;
  100241. /**
  100242. * Gets an unique (relatively to the current scene) Id
  100243. */
  100244. static get UniqueId(): number;
  100245. }
  100246. }
  100247. declare module BABYLON {
  100248. /**
  100249. * Defines a block that can be used inside a node based material
  100250. */
  100251. export class NodeMaterialBlock {
  100252. private _buildId;
  100253. private _buildTarget;
  100254. private _target;
  100255. private _isFinalMerger;
  100256. private _isInput;
  100257. private _name;
  100258. protected _isUnique: boolean;
  100259. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  100260. inputsAreExclusive: boolean;
  100261. /** @hidden */
  100262. _codeVariableName: string;
  100263. /** @hidden */
  100264. _inputs: NodeMaterialConnectionPoint[];
  100265. /** @hidden */
  100266. _outputs: NodeMaterialConnectionPoint[];
  100267. /** @hidden */
  100268. _preparationId: number;
  100269. /**
  100270. * Gets the name of the block
  100271. */
  100272. get name(): string;
  100273. /**
  100274. * Sets the name of the block. Will check if the name is valid.
  100275. */
  100276. set name(newName: string);
  100277. /**
  100278. * Gets or sets the unique id of the node
  100279. */
  100280. uniqueId: number;
  100281. /**
  100282. * Gets or sets the comments associated with this block
  100283. */
  100284. comments: string;
  100285. /**
  100286. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  100287. */
  100288. get isUnique(): boolean;
  100289. /**
  100290. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  100291. */
  100292. get isFinalMerger(): boolean;
  100293. /**
  100294. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  100295. */
  100296. get isInput(): boolean;
  100297. /**
  100298. * Gets or sets the build Id
  100299. */
  100300. get buildId(): number;
  100301. set buildId(value: number);
  100302. /**
  100303. * Gets or sets the target of the block
  100304. */
  100305. get target(): NodeMaterialBlockTargets;
  100306. set target(value: NodeMaterialBlockTargets);
  100307. /**
  100308. * Gets the list of input points
  100309. */
  100310. get inputs(): NodeMaterialConnectionPoint[];
  100311. /** Gets the list of output points */
  100312. get outputs(): NodeMaterialConnectionPoint[];
  100313. /**
  100314. * Find an input by its name
  100315. * @param name defines the name of the input to look for
  100316. * @returns the input or null if not found
  100317. */
  100318. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100319. /**
  100320. * Find an output by its name
  100321. * @param name defines the name of the outputto look for
  100322. * @returns the output or null if not found
  100323. */
  100324. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100325. /**
  100326. * Creates a new NodeMaterialBlock
  100327. * @param name defines the block name
  100328. * @param target defines the target of that block (Vertex by default)
  100329. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  100330. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  100331. */
  100332. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  100333. /**
  100334. * Initialize the block and prepare the context for build
  100335. * @param state defines the state that will be used for the build
  100336. */
  100337. initialize(state: NodeMaterialBuildState): void;
  100338. /**
  100339. * Bind data to effect. Will only be called for blocks with isBindable === true
  100340. * @param effect defines the effect to bind data to
  100341. * @param nodeMaterial defines the hosting NodeMaterial
  100342. * @param mesh defines the mesh that will be rendered
  100343. * @param subMesh defines the submesh that will be rendered
  100344. */
  100345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100346. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  100347. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  100348. protected _writeFloat(value: number): string;
  100349. /**
  100350. * Gets the current class name e.g. "NodeMaterialBlock"
  100351. * @returns the class name
  100352. */
  100353. getClassName(): string;
  100354. /**
  100355. * Register a new input. Must be called inside a block constructor
  100356. * @param name defines the connection point name
  100357. * @param type defines the connection point type
  100358. * @param isOptional defines a boolean indicating that this input can be omitted
  100359. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100360. * @param point an already created connection point. If not provided, create a new one
  100361. * @returns the current block
  100362. */
  100363. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100364. /**
  100365. * Register a new output. Must be called inside a block constructor
  100366. * @param name defines the connection point name
  100367. * @param type defines the connection point type
  100368. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100369. * @param point an already created connection point. If not provided, create a new one
  100370. * @returns the current block
  100371. */
  100372. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100373. /**
  100374. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100375. * @param forOutput defines an optional connection point to check compatibility with
  100376. * @returns the first available input or null
  100377. */
  100378. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100379. /**
  100380. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100381. * @param forBlock defines an optional block to check compatibility with
  100382. * @returns the first available input or null
  100383. */
  100384. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100385. /**
  100386. * Gets the sibling of the given output
  100387. * @param current defines the current output
  100388. * @returns the next output in the list or null
  100389. */
  100390. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100391. /**
  100392. * Connect current block with another block
  100393. * @param other defines the block to connect with
  100394. * @param options define the various options to help pick the right connections
  100395. * @returns the current block
  100396. */
  100397. connectTo(other: NodeMaterialBlock, options?: {
  100398. input?: string;
  100399. output?: string;
  100400. outputSwizzle?: string;
  100401. }): this | undefined;
  100402. protected _buildBlock(state: NodeMaterialBuildState): void;
  100403. /**
  100404. * Add uniforms, samplers and uniform buffers at compilation time
  100405. * @param state defines the state to update
  100406. * @param nodeMaterial defines the node material requesting the update
  100407. * @param defines defines the material defines to update
  100408. * @param uniformBuffers defines the list of uniform buffer names
  100409. */
  100410. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100411. /**
  100412. * Add potential fallbacks if shader compilation fails
  100413. * @param mesh defines the mesh to be rendered
  100414. * @param fallbacks defines the current prioritized list of fallbacks
  100415. */
  100416. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100417. /**
  100418. * Initialize defines for shader compilation
  100419. * @param mesh defines the mesh to be rendered
  100420. * @param nodeMaterial defines the node material requesting the update
  100421. * @param defines defines the material defines to update
  100422. * @param useInstances specifies that instances should be used
  100423. */
  100424. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100425. /**
  100426. * Update defines for shader compilation
  100427. * @param mesh defines the mesh to be rendered
  100428. * @param nodeMaterial defines the node material requesting the update
  100429. * @param defines defines the material defines to update
  100430. * @param useInstances specifies that instances should be used
  100431. * @param subMesh defines which submesh to render
  100432. */
  100433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100434. /**
  100435. * Lets the block try to connect some inputs automatically
  100436. * @param material defines the hosting NodeMaterial
  100437. */
  100438. autoConfigure(material: NodeMaterial): void;
  100439. /**
  100440. * Function called when a block is declared as repeatable content generator
  100441. * @param vertexShaderState defines the current compilation state for the vertex shader
  100442. * @param fragmentShaderState defines the current compilation state for the fragment shader
  100443. * @param mesh defines the mesh to be rendered
  100444. * @param defines defines the material defines to update
  100445. */
  100446. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  100447. /**
  100448. * Checks if the block is ready
  100449. * @param mesh defines the mesh to be rendered
  100450. * @param nodeMaterial defines the node material requesting the update
  100451. * @param defines defines the material defines to update
  100452. * @param useInstances specifies that instances should be used
  100453. * @returns true if the block is ready
  100454. */
  100455. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  100456. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  100457. private _processBuild;
  100458. /**
  100459. * Validates the new name for the block node.
  100460. * @param newName the new name to be given to the node.
  100461. * @returns false if the name is a reserve word, else true.
  100462. */
  100463. validateBlockName(newName: string): boolean;
  100464. /**
  100465. * Compile the current node and generate the shader code
  100466. * @param state defines the current compilation state (uniforms, samplers, current string)
  100467. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  100468. * @returns true if already built
  100469. */
  100470. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  100471. protected _inputRename(name: string): string;
  100472. protected _outputRename(name: string): string;
  100473. protected _dumpPropertiesCode(): string;
  100474. /** @hidden */
  100475. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  100476. /** @hidden */
  100477. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  100478. /**
  100479. * Clone the current block to a new identical block
  100480. * @param scene defines the hosting scene
  100481. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100482. * @returns a copy of the current block
  100483. */
  100484. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  100485. /**
  100486. * Serializes this block in a JSON representation
  100487. * @returns the serialized block object
  100488. */
  100489. serialize(): any;
  100490. /** @hidden */
  100491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100492. private _deserializePortDisplayNamesAndExposedOnFrame;
  100493. /**
  100494. * Release resources
  100495. */
  100496. dispose(): void;
  100497. }
  100498. }
  100499. declare module BABYLON {
  100500. /**
  100501. * Base class of materials working in push mode in babylon JS
  100502. * @hidden
  100503. */
  100504. export class PushMaterial extends Material {
  100505. protected _activeEffect: Effect;
  100506. protected _normalMatrix: Matrix;
  100507. constructor(name: string, scene: Scene);
  100508. getEffect(): Effect;
  100509. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100510. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100511. /**
  100512. * Binds the given world matrix to the active effect
  100513. *
  100514. * @param world the matrix to bind
  100515. */
  100516. bindOnlyWorldMatrix(world: Matrix): void;
  100517. /**
  100518. * Binds the given normal matrix to the active effect
  100519. *
  100520. * @param normalMatrix the matrix to bind
  100521. */
  100522. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100523. bind(world: Matrix, mesh?: Mesh): void;
  100524. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100525. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100526. }
  100527. }
  100528. declare module BABYLON {
  100529. /**
  100530. * Root class for all node material optimizers
  100531. */
  100532. export class NodeMaterialOptimizer {
  100533. /**
  100534. * Function used to optimize a NodeMaterial graph
  100535. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  100536. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  100537. */
  100538. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  100539. }
  100540. }
  100541. declare module BABYLON {
  100542. /**
  100543. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  100544. */
  100545. export class TransformBlock extends NodeMaterialBlock {
  100546. /**
  100547. * Defines the value to use to complement W value to transform it to a Vector4
  100548. */
  100549. complementW: number;
  100550. /**
  100551. * Defines the value to use to complement z value to transform it to a Vector4
  100552. */
  100553. complementZ: number;
  100554. /**
  100555. * Creates a new TransformBlock
  100556. * @param name defines the block name
  100557. */
  100558. constructor(name: string);
  100559. /**
  100560. * Gets the current class name
  100561. * @returns the class name
  100562. */
  100563. getClassName(): string;
  100564. /**
  100565. * Gets the vector input
  100566. */
  100567. get vector(): NodeMaterialConnectionPoint;
  100568. /**
  100569. * Gets the output component
  100570. */
  100571. get output(): NodeMaterialConnectionPoint;
  100572. /**
  100573. * Gets the xyz output component
  100574. */
  100575. get xyz(): NodeMaterialConnectionPoint;
  100576. /**
  100577. * Gets the matrix transform input
  100578. */
  100579. get transform(): NodeMaterialConnectionPoint;
  100580. protected _buildBlock(state: NodeMaterialBuildState): this;
  100581. /**
  100582. * Update defines for shader compilation
  100583. * @param mesh defines the mesh to be rendered
  100584. * @param nodeMaterial defines the node material requesting the update
  100585. * @param defines defines the material defines to update
  100586. * @param useInstances specifies that instances should be used
  100587. * @param subMesh defines which submesh to render
  100588. */
  100589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100590. serialize(): any;
  100591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100592. protected _dumpPropertiesCode(): string;
  100593. }
  100594. }
  100595. declare module BABYLON {
  100596. /**
  100597. * Block used to output the vertex position
  100598. */
  100599. export class VertexOutputBlock extends NodeMaterialBlock {
  100600. /**
  100601. * Creates a new VertexOutputBlock
  100602. * @param name defines the block name
  100603. */
  100604. constructor(name: string);
  100605. /**
  100606. * Gets the current class name
  100607. * @returns the class name
  100608. */
  100609. getClassName(): string;
  100610. /**
  100611. * Gets the vector input component
  100612. */
  100613. get vector(): NodeMaterialConnectionPoint;
  100614. protected _buildBlock(state: NodeMaterialBuildState): this;
  100615. }
  100616. }
  100617. declare module BABYLON {
  100618. /**
  100619. * Block used to output the final color
  100620. */
  100621. export class FragmentOutputBlock extends NodeMaterialBlock {
  100622. /**
  100623. * Create a new FragmentOutputBlock
  100624. * @param name defines the block name
  100625. */
  100626. constructor(name: string);
  100627. /**
  100628. * Gets the current class name
  100629. * @returns the class name
  100630. */
  100631. getClassName(): string;
  100632. /**
  100633. * Gets the rgba input component
  100634. */
  100635. get rgba(): NodeMaterialConnectionPoint;
  100636. /**
  100637. * Gets the rgb input component
  100638. */
  100639. get rgb(): NodeMaterialConnectionPoint;
  100640. /**
  100641. * Gets the a input component
  100642. */
  100643. get a(): NodeMaterialConnectionPoint;
  100644. protected _buildBlock(state: NodeMaterialBuildState): this;
  100645. }
  100646. }
  100647. declare module BABYLON {
  100648. /**
  100649. * Block used for the particle ramp gradient section
  100650. */
  100651. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100652. /**
  100653. * Create a new ParticleRampGradientBlock
  100654. * @param name defines the block name
  100655. */
  100656. constructor(name: string);
  100657. /**
  100658. * Gets the current class name
  100659. * @returns the class name
  100660. */
  100661. getClassName(): string;
  100662. /**
  100663. * Gets the color input component
  100664. */
  100665. get color(): NodeMaterialConnectionPoint;
  100666. /**
  100667. * Gets the rampColor output component
  100668. */
  100669. get rampColor(): NodeMaterialConnectionPoint;
  100670. /**
  100671. * Initialize the block and prepare the context for build
  100672. * @param state defines the state that will be used for the build
  100673. */
  100674. initialize(state: NodeMaterialBuildState): void;
  100675. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100676. }
  100677. }
  100678. declare module BABYLON {
  100679. /**
  100680. * Block used for the particle blend multiply section
  100681. */
  100682. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100683. /**
  100684. * Create a new ParticleBlendMultiplyBlock
  100685. * @param name defines the block name
  100686. */
  100687. constructor(name: string);
  100688. /**
  100689. * Gets the current class name
  100690. * @returns the class name
  100691. */
  100692. getClassName(): string;
  100693. /**
  100694. * Gets the color input component
  100695. */
  100696. get color(): NodeMaterialConnectionPoint;
  100697. /**
  100698. * Gets the alphaTexture input component
  100699. */
  100700. get alphaTexture(): NodeMaterialConnectionPoint;
  100701. /**
  100702. * Gets the alphaColor input component
  100703. */
  100704. get alphaColor(): NodeMaterialConnectionPoint;
  100705. /**
  100706. * Gets the blendColor output component
  100707. */
  100708. get blendColor(): NodeMaterialConnectionPoint;
  100709. /**
  100710. * Initialize the block and prepare the context for build
  100711. * @param state defines the state that will be used for the build
  100712. */
  100713. initialize(state: NodeMaterialBuildState): void;
  100714. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100715. }
  100716. }
  100717. declare module BABYLON {
  100718. /**
  100719. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100720. */
  100721. export class VectorMergerBlock extends NodeMaterialBlock {
  100722. /**
  100723. * Create a new VectorMergerBlock
  100724. * @param name defines the block name
  100725. */
  100726. constructor(name: string);
  100727. /**
  100728. * Gets the current class name
  100729. * @returns the class name
  100730. */
  100731. getClassName(): string;
  100732. /**
  100733. * Gets the xyz component (input)
  100734. */
  100735. get xyzIn(): NodeMaterialConnectionPoint;
  100736. /**
  100737. * Gets the xy component (input)
  100738. */
  100739. get xyIn(): NodeMaterialConnectionPoint;
  100740. /**
  100741. * Gets the x component (input)
  100742. */
  100743. get x(): NodeMaterialConnectionPoint;
  100744. /**
  100745. * Gets the y component (input)
  100746. */
  100747. get y(): NodeMaterialConnectionPoint;
  100748. /**
  100749. * Gets the z component (input)
  100750. */
  100751. get z(): NodeMaterialConnectionPoint;
  100752. /**
  100753. * Gets the w component (input)
  100754. */
  100755. get w(): NodeMaterialConnectionPoint;
  100756. /**
  100757. * Gets the xyzw component (output)
  100758. */
  100759. get xyzw(): NodeMaterialConnectionPoint;
  100760. /**
  100761. * Gets the xyz component (output)
  100762. */
  100763. get xyzOut(): NodeMaterialConnectionPoint;
  100764. /**
  100765. * Gets the xy component (output)
  100766. */
  100767. get xyOut(): NodeMaterialConnectionPoint;
  100768. /**
  100769. * Gets the xy component (output)
  100770. * @deprecated Please use xyOut instead.
  100771. */
  100772. get xy(): NodeMaterialConnectionPoint;
  100773. /**
  100774. * Gets the xyz component (output)
  100775. * @deprecated Please use xyzOut instead.
  100776. */
  100777. get xyz(): NodeMaterialConnectionPoint;
  100778. protected _buildBlock(state: NodeMaterialBuildState): this;
  100779. }
  100780. }
  100781. declare module BABYLON {
  100782. /**
  100783. * Block used to remap a float from a range to a new one
  100784. */
  100785. export class RemapBlock extends NodeMaterialBlock {
  100786. /**
  100787. * Gets or sets the source range
  100788. */
  100789. sourceRange: Vector2;
  100790. /**
  100791. * Gets or sets the target range
  100792. */
  100793. targetRange: Vector2;
  100794. /**
  100795. * Creates a new RemapBlock
  100796. * @param name defines the block name
  100797. */
  100798. constructor(name: string);
  100799. /**
  100800. * Gets the current class name
  100801. * @returns the class name
  100802. */
  100803. getClassName(): string;
  100804. /**
  100805. * Gets the input component
  100806. */
  100807. get input(): NodeMaterialConnectionPoint;
  100808. /**
  100809. * Gets the source min input component
  100810. */
  100811. get sourceMin(): NodeMaterialConnectionPoint;
  100812. /**
  100813. * Gets the source max input component
  100814. */
  100815. get sourceMax(): NodeMaterialConnectionPoint;
  100816. /**
  100817. * Gets the target min input component
  100818. */
  100819. get targetMin(): NodeMaterialConnectionPoint;
  100820. /**
  100821. * Gets the target max input component
  100822. */
  100823. get targetMax(): NodeMaterialConnectionPoint;
  100824. /**
  100825. * Gets the output component
  100826. */
  100827. get output(): NodeMaterialConnectionPoint;
  100828. protected _buildBlock(state: NodeMaterialBuildState): this;
  100829. protected _dumpPropertiesCode(): string;
  100830. serialize(): any;
  100831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100832. }
  100833. }
  100834. declare module BABYLON {
  100835. /**
  100836. * Block used to multiply 2 values
  100837. */
  100838. export class MultiplyBlock extends NodeMaterialBlock {
  100839. /**
  100840. * Creates a new MultiplyBlock
  100841. * @param name defines the block name
  100842. */
  100843. constructor(name: string);
  100844. /**
  100845. * Gets the current class name
  100846. * @returns the class name
  100847. */
  100848. getClassName(): string;
  100849. /**
  100850. * Gets the left operand input component
  100851. */
  100852. get left(): NodeMaterialConnectionPoint;
  100853. /**
  100854. * Gets the right operand input component
  100855. */
  100856. get right(): NodeMaterialConnectionPoint;
  100857. /**
  100858. * Gets the output component
  100859. */
  100860. get output(): NodeMaterialConnectionPoint;
  100861. protected _buildBlock(state: NodeMaterialBuildState): this;
  100862. }
  100863. }
  100864. declare module BABYLON {
  100865. /**
  100866. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100867. */
  100868. export class ColorSplitterBlock extends NodeMaterialBlock {
  100869. /**
  100870. * Create a new ColorSplitterBlock
  100871. * @param name defines the block name
  100872. */
  100873. constructor(name: string);
  100874. /**
  100875. * Gets the current class name
  100876. * @returns the class name
  100877. */
  100878. getClassName(): string;
  100879. /**
  100880. * Gets the rgba component (input)
  100881. */
  100882. get rgba(): NodeMaterialConnectionPoint;
  100883. /**
  100884. * Gets the rgb component (input)
  100885. */
  100886. get rgbIn(): NodeMaterialConnectionPoint;
  100887. /**
  100888. * Gets the rgb component (output)
  100889. */
  100890. get rgbOut(): NodeMaterialConnectionPoint;
  100891. /**
  100892. * Gets the r component (output)
  100893. */
  100894. get r(): NodeMaterialConnectionPoint;
  100895. /**
  100896. * Gets the g component (output)
  100897. */
  100898. get g(): NodeMaterialConnectionPoint;
  100899. /**
  100900. * Gets the b component (output)
  100901. */
  100902. get b(): NodeMaterialConnectionPoint;
  100903. /**
  100904. * Gets the a component (output)
  100905. */
  100906. get a(): NodeMaterialConnectionPoint;
  100907. protected _inputRename(name: string): string;
  100908. protected _outputRename(name: string): string;
  100909. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100910. }
  100911. }
  100912. declare module BABYLON {
  100913. /**
  100914. * Interface used to configure the node material editor
  100915. */
  100916. export interface INodeMaterialEditorOptions {
  100917. /** Define the URl to load node editor script */
  100918. editorURL?: string;
  100919. }
  100920. /** @hidden */
  100921. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100922. NORMAL: boolean;
  100923. TANGENT: boolean;
  100924. UV1: boolean;
  100925. /** BONES */
  100926. NUM_BONE_INFLUENCERS: number;
  100927. BonesPerMesh: number;
  100928. BONETEXTURE: boolean;
  100929. /** MORPH TARGETS */
  100930. MORPHTARGETS: boolean;
  100931. MORPHTARGETS_NORMAL: boolean;
  100932. MORPHTARGETS_TANGENT: boolean;
  100933. MORPHTARGETS_UV: boolean;
  100934. NUM_MORPH_INFLUENCERS: number;
  100935. /** IMAGE PROCESSING */
  100936. IMAGEPROCESSING: boolean;
  100937. VIGNETTE: boolean;
  100938. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100939. VIGNETTEBLENDMODEOPAQUE: boolean;
  100940. TONEMAPPING: boolean;
  100941. TONEMAPPING_ACES: boolean;
  100942. CONTRAST: boolean;
  100943. EXPOSURE: boolean;
  100944. COLORCURVES: boolean;
  100945. COLORGRADING: boolean;
  100946. COLORGRADING3D: boolean;
  100947. SAMPLER3DGREENDEPTH: boolean;
  100948. SAMPLER3DBGRMAP: boolean;
  100949. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100950. /** MISC. */
  100951. BUMPDIRECTUV: number;
  100952. constructor();
  100953. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100954. }
  100955. /**
  100956. * Class used to configure NodeMaterial
  100957. */
  100958. export interface INodeMaterialOptions {
  100959. /**
  100960. * Defines if blocks should emit comments
  100961. */
  100962. emitComments: boolean;
  100963. }
  100964. /**
  100965. * Class used to create a node based material built by assembling shader blocks
  100966. */
  100967. export class NodeMaterial extends PushMaterial {
  100968. private static _BuildIdGenerator;
  100969. private _options;
  100970. private _vertexCompilationState;
  100971. private _fragmentCompilationState;
  100972. private _sharedData;
  100973. private _buildId;
  100974. private _buildWasSuccessful;
  100975. private _cachedWorldViewMatrix;
  100976. private _cachedWorldViewProjectionMatrix;
  100977. private _optimizers;
  100978. private _animationFrame;
  100979. /** Define the Url to load node editor script */
  100980. static EditorURL: string;
  100981. /** Define the Url to load snippets */
  100982. static SnippetUrl: string;
  100983. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100984. static IgnoreTexturesAtLoadTime: boolean;
  100985. private BJSNODEMATERIALEDITOR;
  100986. /** Get the inspector from bundle or global */
  100987. private _getGlobalNodeMaterialEditor;
  100988. /**
  100989. * Snippet ID if the material was created from the snippet server
  100990. */
  100991. snippetId: string;
  100992. /**
  100993. * Gets or sets data used by visual editor
  100994. * @see https://nme.babylonjs.com
  100995. */
  100996. editorData: any;
  100997. /**
  100998. * 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)
  100999. */
  101000. ignoreAlpha: boolean;
  101001. /**
  101002. * Defines the maximum number of lights that can be used in the material
  101003. */
  101004. maxSimultaneousLights: number;
  101005. /**
  101006. * Observable raised when the material is built
  101007. */
  101008. onBuildObservable: Observable<NodeMaterial>;
  101009. /**
  101010. * Gets or sets the root nodes of the material vertex shader
  101011. */
  101012. _vertexOutputNodes: NodeMaterialBlock[];
  101013. /**
  101014. * Gets or sets the root nodes of the material fragment (pixel) shader
  101015. */
  101016. _fragmentOutputNodes: NodeMaterialBlock[];
  101017. /** Gets or sets options to control the node material overall behavior */
  101018. get options(): INodeMaterialOptions;
  101019. set options(options: INodeMaterialOptions);
  101020. /**
  101021. * Default configuration related to image processing available in the standard Material.
  101022. */
  101023. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101024. /**
  101025. * Gets the image processing configuration used either in this material.
  101026. */
  101027. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101028. /**
  101029. * Sets the Default image processing configuration used either in the this material.
  101030. *
  101031. * If sets to null, the scene one is in use.
  101032. */
  101033. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101034. /**
  101035. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  101036. */
  101037. attachedBlocks: NodeMaterialBlock[];
  101038. /**
  101039. * Specifies the mode of the node material
  101040. * @hidden
  101041. */
  101042. _mode: NodeMaterialModes;
  101043. /**
  101044. * Gets the mode property
  101045. */
  101046. get mode(): NodeMaterialModes;
  101047. /**
  101048. * Create a new node based material
  101049. * @param name defines the material name
  101050. * @param scene defines the hosting scene
  101051. * @param options defines creation option
  101052. */
  101053. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  101054. /**
  101055. * Gets the current class name of the material e.g. "NodeMaterial"
  101056. * @returns the class name
  101057. */
  101058. getClassName(): string;
  101059. /**
  101060. * Keep track of the image processing observer to allow dispose and replace.
  101061. */
  101062. private _imageProcessingObserver;
  101063. /**
  101064. * Attaches a new image processing configuration to the Standard Material.
  101065. * @param configuration
  101066. */
  101067. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101068. /**
  101069. * Get a block by its name
  101070. * @param name defines the name of the block to retrieve
  101071. * @returns the required block or null if not found
  101072. */
  101073. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  101074. /**
  101075. * Get a block by its name
  101076. * @param predicate defines the predicate used to find the good candidate
  101077. * @returns the required block or null if not found
  101078. */
  101079. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  101080. /**
  101081. * Get an input block by its name
  101082. * @param predicate defines the predicate used to find the good candidate
  101083. * @returns the required input block or null if not found
  101084. */
  101085. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  101086. /**
  101087. * Gets the list of input blocks attached to this material
  101088. * @returns an array of InputBlocks
  101089. */
  101090. getInputBlocks(): InputBlock[];
  101091. /**
  101092. * Adds a new optimizer to the list of optimizers
  101093. * @param optimizer defines the optimizers to add
  101094. * @returns the current material
  101095. */
  101096. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101097. /**
  101098. * Remove an optimizer from the list of optimizers
  101099. * @param optimizer defines the optimizers to remove
  101100. * @returns the current material
  101101. */
  101102. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101103. /**
  101104. * Add a new block to the list of output nodes
  101105. * @param node defines the node to add
  101106. * @returns the current material
  101107. */
  101108. addOutputNode(node: NodeMaterialBlock): this;
  101109. /**
  101110. * Remove a block from the list of root nodes
  101111. * @param node defines the node to remove
  101112. * @returns the current material
  101113. */
  101114. removeOutputNode(node: NodeMaterialBlock): this;
  101115. private _addVertexOutputNode;
  101116. private _removeVertexOutputNode;
  101117. private _addFragmentOutputNode;
  101118. private _removeFragmentOutputNode;
  101119. /**
  101120. * Specifies if the material will require alpha blending
  101121. * @returns a boolean specifying if alpha blending is needed
  101122. */
  101123. needAlphaBlending(): boolean;
  101124. /**
  101125. * Specifies if this material should be rendered in alpha test mode
  101126. * @returns a boolean specifying if an alpha test is needed.
  101127. */
  101128. needAlphaTesting(): boolean;
  101129. private _initializeBlock;
  101130. private _resetDualBlocks;
  101131. /**
  101132. * Remove a block from the current node material
  101133. * @param block defines the block to remove
  101134. */
  101135. removeBlock(block: NodeMaterialBlock): void;
  101136. /**
  101137. * Build the material and generates the inner effect
  101138. * @param verbose defines if the build should log activity
  101139. */
  101140. build(verbose?: boolean): void;
  101141. /**
  101142. * Runs an otpimization phase to try to improve the shader code
  101143. */
  101144. optimize(): void;
  101145. private _prepareDefinesForAttributes;
  101146. /**
  101147. * Create a post process from the material
  101148. * @param camera The camera to apply the render pass to.
  101149. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101151. * @param engine The engine which the post process will be applied. (default: current engine)
  101152. * @param reusable If the post process can be reused on the same frame. (default: false)
  101153. * @param textureType Type of textures used when performing the post process. (default: 0)
  101154. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101155. * @returns the post process created
  101156. */
  101157. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  101158. /**
  101159. * Create the post process effect from the material
  101160. * @param postProcess The post process to create the effect for
  101161. */
  101162. createEffectForPostProcess(postProcess: PostProcess): void;
  101163. private _createEffectOrPostProcess;
  101164. private _createEffectForParticles;
  101165. /**
  101166. * Create the effect to be used as the custom effect for a particle system
  101167. * @param particleSystem Particle system to create the effect for
  101168. * @param onCompiled defines a function to call when the effect creation is successful
  101169. * @param onError defines a function to call when the effect creation has failed
  101170. */
  101171. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101172. private _processDefines;
  101173. /**
  101174. * Get if the submesh is ready to be used and all its information available.
  101175. * Child classes can use it to update shaders
  101176. * @param mesh defines the mesh to check
  101177. * @param subMesh defines which submesh to check
  101178. * @param useInstances specifies that instances should be used
  101179. * @returns a boolean indicating that the submesh is ready or not
  101180. */
  101181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101182. /**
  101183. * Get a string representing the shaders built by the current node graph
  101184. */
  101185. get compiledShaders(): string;
  101186. /**
  101187. * Binds the world matrix to the material
  101188. * @param world defines the world transformation matrix
  101189. */
  101190. bindOnlyWorldMatrix(world: Matrix): void;
  101191. /**
  101192. * Binds the submesh to this material by preparing the effect and shader to draw
  101193. * @param world defines the world transformation matrix
  101194. * @param mesh defines the mesh containing the submesh
  101195. * @param subMesh defines the submesh to bind the material to
  101196. */
  101197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101198. /**
  101199. * Gets the active textures from the material
  101200. * @returns an array of textures
  101201. */
  101202. getActiveTextures(): BaseTexture[];
  101203. /**
  101204. * Gets the list of texture blocks
  101205. * @returns an array of texture blocks
  101206. */
  101207. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101208. /**
  101209. * Specifies if the material uses a texture
  101210. * @param texture defines the texture to check against the material
  101211. * @returns a boolean specifying if the material uses the texture
  101212. */
  101213. hasTexture(texture: BaseTexture): boolean;
  101214. /**
  101215. * Disposes the material
  101216. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101217. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101218. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101219. */
  101220. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101221. /** Creates the node editor window. */
  101222. private _createNodeEditor;
  101223. /**
  101224. * Launch the node material editor
  101225. * @param config Define the configuration of the editor
  101226. * @return a promise fulfilled when the node editor is visible
  101227. */
  101228. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  101229. /**
  101230. * Clear the current material
  101231. */
  101232. clear(): void;
  101233. /**
  101234. * Clear the current material and set it to a default state
  101235. */
  101236. setToDefault(): void;
  101237. /**
  101238. * Clear the current material and set it to a default state for post process
  101239. */
  101240. setToDefaultPostProcess(): void;
  101241. /**
  101242. * Clear the current material and set it to a default state for particle
  101243. */
  101244. setToDefaultParticle(): void;
  101245. /**
  101246. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  101247. * @param url defines the url to load from
  101248. * @returns a promise that will fullfil when the material is fully loaded
  101249. */
  101250. loadAsync(url: string): Promise<void>;
  101251. private _gatherBlocks;
  101252. /**
  101253. * Generate a string containing the code declaration required to create an equivalent of this material
  101254. * @returns a string
  101255. */
  101256. generateCode(): string;
  101257. /**
  101258. * Serializes this material in a JSON representation
  101259. * @returns the serialized material object
  101260. */
  101261. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  101262. private _restoreConnections;
  101263. /**
  101264. * Clear the current graph and load a new one from a serialization object
  101265. * @param source defines the JSON representation of the material
  101266. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101267. * @param merge defines whether or not the source must be merged or replace the current content
  101268. */
  101269. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  101270. /**
  101271. * Makes a duplicate of the current material.
  101272. * @param name - name to use for the new material.
  101273. */
  101274. clone(name: string): NodeMaterial;
  101275. /**
  101276. * Creates a node material from parsed material data
  101277. * @param source defines the JSON representation of the material
  101278. * @param scene defines the hosting scene
  101279. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101280. * @returns a new node material
  101281. */
  101282. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  101283. /**
  101284. * Creates a node material from a snippet saved in a remote file
  101285. * @param name defines the name of the material to create
  101286. * @param url defines the url to load from
  101287. * @param scene defines the hosting scene
  101288. * @returns a promise that will resolve to the new node material
  101289. */
  101290. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  101291. /**
  101292. * Creates a node material from a snippet saved by the node material editor
  101293. * @param snippetId defines the snippet to load
  101294. * @param scene defines the hosting scene
  101295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101296. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  101297. * @returns a promise that will resolve to the new node material
  101298. */
  101299. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  101300. /**
  101301. * Creates a new node material set to default basic configuration
  101302. * @param name defines the name of the material
  101303. * @param scene defines the hosting scene
  101304. * @returns a new NodeMaterial
  101305. */
  101306. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  101307. }
  101308. }
  101309. declare module BABYLON {
  101310. /**
  101311. * Size options for a post process
  101312. */
  101313. export type PostProcessOptions = {
  101314. width: number;
  101315. height: number;
  101316. };
  101317. /**
  101318. * PostProcess can be used to apply a shader to a texture after it has been rendered
  101319. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101320. */
  101321. export class PostProcess {
  101322. /** Name of the PostProcess. */
  101323. name: string;
  101324. /**
  101325. * Gets or sets the unique id of the post process
  101326. */
  101327. uniqueId: number;
  101328. /**
  101329. * Width of the texture to apply the post process on
  101330. */
  101331. width: number;
  101332. /**
  101333. * Height of the texture to apply the post process on
  101334. */
  101335. height: number;
  101336. /**
  101337. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  101338. */
  101339. nodeMaterialSource: Nullable<NodeMaterial>;
  101340. /**
  101341. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  101342. * @hidden
  101343. */
  101344. _outputTexture: Nullable<InternalTexture>;
  101345. /**
  101346. * Sampling mode used by the shader
  101347. * See https://doc.babylonjs.com/classes/3.1/texture
  101348. */
  101349. renderTargetSamplingMode: number;
  101350. /**
  101351. * Clear color to use when screen clearing
  101352. */
  101353. clearColor: Color4;
  101354. /**
  101355. * If the buffer needs to be cleared before applying the post process. (default: true)
  101356. * Should be set to false if shader will overwrite all previous pixels.
  101357. */
  101358. autoClear: boolean;
  101359. /**
  101360. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  101361. */
  101362. alphaMode: number;
  101363. /**
  101364. * Sets the setAlphaBlendConstants of the babylon engine
  101365. */
  101366. alphaConstants: Color4;
  101367. /**
  101368. * Animations to be used for the post processing
  101369. */
  101370. animations: Animation[];
  101371. /**
  101372. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101373. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101374. */
  101375. enablePixelPerfectMode: boolean;
  101376. /**
  101377. * Force the postprocess to be applied without taking in account viewport
  101378. */
  101379. forceFullscreenViewport: boolean;
  101380. /**
  101381. * List of inspectable custom properties (used by the Inspector)
  101382. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101383. */
  101384. inspectableCustomProperties: IInspectable[];
  101385. /**
  101386. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101387. *
  101388. * | Value | Type | Description |
  101389. * | ----- | ----------------------------------- | ----------- |
  101390. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101391. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101392. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101393. *
  101394. */
  101395. scaleMode: number;
  101396. /**
  101397. * Force textures to be a power of two (default: false)
  101398. */
  101399. alwaysForcePOT: boolean;
  101400. private _samples;
  101401. /**
  101402. * Number of sample textures (default: 1)
  101403. */
  101404. get samples(): number;
  101405. set samples(n: number);
  101406. /**
  101407. * Modify the scale of the post process to be the same as the viewport (default: false)
  101408. */
  101409. adaptScaleToCurrentViewport: boolean;
  101410. private _camera;
  101411. protected _scene: Scene;
  101412. private _engine;
  101413. private _options;
  101414. private _reusable;
  101415. private _textureType;
  101416. private _textureFormat;
  101417. /**
  101418. * Smart array of input and output textures for the post process.
  101419. * @hidden
  101420. */
  101421. _textures: SmartArray<InternalTexture>;
  101422. /**
  101423. * The index in _textures that corresponds to the output texture.
  101424. * @hidden
  101425. */
  101426. _currentRenderTextureInd: number;
  101427. private _effect;
  101428. private _samplers;
  101429. private _fragmentUrl;
  101430. private _vertexUrl;
  101431. private _parameters;
  101432. private _scaleRatio;
  101433. protected _indexParameters: any;
  101434. private _shareOutputWithPostProcess;
  101435. private _texelSize;
  101436. private _forcedOutputTexture;
  101437. /**
  101438. * Returns the fragment url or shader name used in the post process.
  101439. * @returns the fragment url or name in the shader store.
  101440. */
  101441. getEffectName(): string;
  101442. /**
  101443. * An event triggered when the postprocess is activated.
  101444. */
  101445. onActivateObservable: Observable<Camera>;
  101446. private _onActivateObserver;
  101447. /**
  101448. * A function that is added to the onActivateObservable
  101449. */
  101450. set onActivate(callback: Nullable<(camera: Camera) => void>);
  101451. /**
  101452. * An event triggered when the postprocess changes its size.
  101453. */
  101454. onSizeChangedObservable: Observable<PostProcess>;
  101455. private _onSizeChangedObserver;
  101456. /**
  101457. * A function that is added to the onSizeChangedObservable
  101458. */
  101459. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  101460. /**
  101461. * An event triggered when the postprocess applies its effect.
  101462. */
  101463. onApplyObservable: Observable<Effect>;
  101464. private _onApplyObserver;
  101465. /**
  101466. * A function that is added to the onApplyObservable
  101467. */
  101468. set onApply(callback: (effect: Effect) => void);
  101469. /**
  101470. * An event triggered before rendering the postprocess
  101471. */
  101472. onBeforeRenderObservable: Observable<Effect>;
  101473. private _onBeforeRenderObserver;
  101474. /**
  101475. * A function that is added to the onBeforeRenderObservable
  101476. */
  101477. set onBeforeRender(callback: (effect: Effect) => void);
  101478. /**
  101479. * An event triggered after rendering the postprocess
  101480. */
  101481. onAfterRenderObservable: Observable<Effect>;
  101482. private _onAfterRenderObserver;
  101483. /**
  101484. * A function that is added to the onAfterRenderObservable
  101485. */
  101486. set onAfterRender(callback: (efect: Effect) => void);
  101487. /**
  101488. * 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
  101489. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  101490. */
  101491. get inputTexture(): InternalTexture;
  101492. set inputTexture(value: InternalTexture);
  101493. /**
  101494. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  101495. * the only way to unset it is to use this function to restore its internal state
  101496. */
  101497. restoreDefaultInputTexture(): void;
  101498. /**
  101499. * Gets the camera which post process is applied to.
  101500. * @returns The camera the post process is applied to.
  101501. */
  101502. getCamera(): Camera;
  101503. /**
  101504. * Gets the texel size of the postprocess.
  101505. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  101506. */
  101507. get texelSize(): Vector2;
  101508. /**
  101509. * Creates a new instance PostProcess
  101510. * @param name The name of the PostProcess.
  101511. * @param fragmentUrl The url of the fragment shader to be used.
  101512. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  101513. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  101514. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101515. * @param camera The camera to apply the render pass to.
  101516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101517. * @param engine The engine which the post process will be applied. (default: current engine)
  101518. * @param reusable If the post process can be reused on the same frame. (default: false)
  101519. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  101520. * @param textureType Type of textures used when performing the post process. (default: 0)
  101521. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  101522. * @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
  101523. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  101524. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101525. */
  101526. constructor(
  101527. /** Name of the PostProcess. */
  101528. 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);
  101529. /**
  101530. * Gets a string idenfifying the name of the class
  101531. * @returns "PostProcess" string
  101532. */
  101533. getClassName(): string;
  101534. /**
  101535. * Gets the engine which this post process belongs to.
  101536. * @returns The engine the post process was enabled with.
  101537. */
  101538. getEngine(): Engine;
  101539. /**
  101540. * The effect that is created when initializing the post process.
  101541. * @returns The created effect corresponding the the postprocess.
  101542. */
  101543. getEffect(): Effect;
  101544. /**
  101545. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  101546. * @param postProcess The post process to share the output with.
  101547. * @returns This post process.
  101548. */
  101549. shareOutputWith(postProcess: PostProcess): PostProcess;
  101550. /**
  101551. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  101552. * This should be called if the post process that shares output with this post process is disabled/disposed.
  101553. */
  101554. useOwnOutput(): void;
  101555. /**
  101556. * Updates the effect with the current post process compile time values and recompiles the shader.
  101557. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101558. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101559. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101560. * @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
  101561. * @param onCompiled Called when the shader has been compiled.
  101562. * @param onError Called if there is an error when compiling a shader.
  101563. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  101564. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  101565. */
  101566. 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;
  101567. /**
  101568. * The post process is reusable if it can be used multiple times within one frame.
  101569. * @returns If the post process is reusable
  101570. */
  101571. isReusable(): boolean;
  101572. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  101573. markTextureDirty(): void;
  101574. /**
  101575. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  101576. * 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.
  101577. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  101578. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  101579. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  101580. * @returns The target texture that was bound to be written to.
  101581. */
  101582. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  101583. /**
  101584. * If the post process is supported.
  101585. */
  101586. get isSupported(): boolean;
  101587. /**
  101588. * The aspect ratio of the output texture.
  101589. */
  101590. get aspectRatio(): number;
  101591. /**
  101592. * Get a value indicating if the post-process is ready to be used
  101593. * @returns true if the post-process is ready (shader is compiled)
  101594. */
  101595. isReady(): boolean;
  101596. /**
  101597. * Binds all textures and uniforms to the shader, this will be run on every pass.
  101598. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  101599. */
  101600. apply(): Nullable<Effect>;
  101601. private _disposeTextures;
  101602. /**
  101603. * Disposes the post process.
  101604. * @param camera The camera to dispose the post process on.
  101605. */
  101606. dispose(camera?: Camera): void;
  101607. }
  101608. }
  101609. declare module BABYLON {
  101610. /** @hidden */
  101611. export var kernelBlurVaryingDeclaration: {
  101612. name: string;
  101613. shader: string;
  101614. };
  101615. }
  101616. declare module BABYLON {
  101617. /** @hidden */
  101618. export var kernelBlurFragment: {
  101619. name: string;
  101620. shader: string;
  101621. };
  101622. }
  101623. declare module BABYLON {
  101624. /** @hidden */
  101625. export var kernelBlurFragment2: {
  101626. name: string;
  101627. shader: string;
  101628. };
  101629. }
  101630. declare module BABYLON {
  101631. /** @hidden */
  101632. export var kernelBlurPixelShader: {
  101633. name: string;
  101634. shader: string;
  101635. };
  101636. }
  101637. declare module BABYLON {
  101638. /** @hidden */
  101639. export var kernelBlurVertex: {
  101640. name: string;
  101641. shader: string;
  101642. };
  101643. }
  101644. declare module BABYLON {
  101645. /** @hidden */
  101646. export var kernelBlurVertexShader: {
  101647. name: string;
  101648. shader: string;
  101649. };
  101650. }
  101651. declare module BABYLON {
  101652. /**
  101653. * The Blur Post Process which blurs an image based on a kernel and direction.
  101654. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101655. */
  101656. export class BlurPostProcess extends PostProcess {
  101657. /** The direction in which to blur the image. */
  101658. direction: Vector2;
  101659. private blockCompilation;
  101660. protected _kernel: number;
  101661. protected _idealKernel: number;
  101662. protected _packedFloat: boolean;
  101663. private _staticDefines;
  101664. /**
  101665. * Sets the length in pixels of the blur sample region
  101666. */
  101667. set kernel(v: number);
  101668. /**
  101669. * Gets the length in pixels of the blur sample region
  101670. */
  101671. get kernel(): number;
  101672. /**
  101673. * Sets wether or not the blur needs to unpack/repack floats
  101674. */
  101675. set packedFloat(v: boolean);
  101676. /**
  101677. * Gets wether or not the blur is unpacking/repacking floats
  101678. */
  101679. get packedFloat(): boolean;
  101680. /**
  101681. * Creates a new instance BlurPostProcess
  101682. * @param name The name of the effect.
  101683. * @param direction The direction in which to blur the image.
  101684. * @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.
  101685. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101686. * @param camera The camera to apply the render pass to.
  101687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101688. * @param engine The engine which the post process will be applied. (default: current engine)
  101689. * @param reusable If the post process can be reused on the same frame. (default: false)
  101690. * @param textureType Type of textures used when performing the post process. (default: 0)
  101691. * @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)
  101692. */
  101693. constructor(name: string,
  101694. /** The direction in which to blur the image. */
  101695. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101696. /**
  101697. * Updates the effect with the current post process compile time values and recompiles the shader.
  101698. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101699. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101700. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101701. * @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
  101702. * @param onCompiled Called when the shader has been compiled.
  101703. * @param onError Called if there is an error when compiling a shader.
  101704. */
  101705. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101706. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101707. /**
  101708. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101709. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101710. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101711. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101712. * The gaps between physical kernels are compensated for in the weighting of the samples
  101713. * @param idealKernel Ideal blur kernel.
  101714. * @return Nearest best kernel.
  101715. */
  101716. protected _nearestBestKernel(idealKernel: number): number;
  101717. /**
  101718. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101719. * @param x The point on the Gaussian distribution to sample.
  101720. * @return the value of the Gaussian function at x.
  101721. */
  101722. protected _gaussianWeight(x: number): number;
  101723. /**
  101724. * Generates a string that can be used as a floating point number in GLSL.
  101725. * @param x Value to print.
  101726. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101727. * @return GLSL float string.
  101728. */
  101729. protected _glslFloat(x: number, decimalFigures?: number): string;
  101730. }
  101731. }
  101732. declare module BABYLON {
  101733. /**
  101734. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101735. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101736. * You can then easily use it as a reflectionTexture on a flat surface.
  101737. * In case the surface is not a plane, please consider relying on reflection probes.
  101738. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101739. */
  101740. export class MirrorTexture extends RenderTargetTexture {
  101741. private scene;
  101742. /**
  101743. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  101744. * 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.
  101745. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101746. */
  101747. mirrorPlane: Plane;
  101748. /**
  101749. * Define the blur ratio used to blur the reflection if needed.
  101750. */
  101751. set blurRatio(value: number);
  101752. get blurRatio(): number;
  101753. /**
  101754. * Define the adaptive blur kernel used to blur the reflection if needed.
  101755. * This will autocompute the closest best match for the `blurKernel`
  101756. */
  101757. set adaptiveBlurKernel(value: number);
  101758. /**
  101759. * Define the blur kernel 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 blurKernel(value: number);
  101763. /**
  101764. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  101765. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101766. */
  101767. set blurKernelX(value: number);
  101768. get blurKernelX(): number;
  101769. /**
  101770. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  101771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101772. */
  101773. set blurKernelY(value: number);
  101774. get blurKernelY(): number;
  101775. private _autoComputeBlurKernel;
  101776. protected _onRatioRescale(): void;
  101777. private _updateGammaSpace;
  101778. private _imageProcessingConfigChangeObserver;
  101779. private _transformMatrix;
  101780. private _mirrorMatrix;
  101781. private _savedViewMatrix;
  101782. private _blurX;
  101783. private _blurY;
  101784. private _adaptiveBlurKernel;
  101785. private _blurKernelX;
  101786. private _blurKernelY;
  101787. private _blurRatio;
  101788. /**
  101789. * Instantiates a Mirror Texture.
  101790. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101791. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101792. * You can then easily use it as a reflectionTexture on a flat surface.
  101793. * In case the surface is not a plane, please consider relying on reflection probes.
  101794. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101795. * @param name
  101796. * @param size
  101797. * @param scene
  101798. * @param generateMipMaps
  101799. * @param type
  101800. * @param samplingMode
  101801. * @param generateDepthBuffer
  101802. */
  101803. constructor(name: string, size: number | {
  101804. width: number;
  101805. height: number;
  101806. } | {
  101807. ratio: number;
  101808. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101809. private _preparePostProcesses;
  101810. /**
  101811. * Clone the mirror texture.
  101812. * @returns the cloned texture
  101813. */
  101814. clone(): MirrorTexture;
  101815. /**
  101816. * Serialize the texture to a JSON representation you could use in Parse later on
  101817. * @returns the serialized JSON representation
  101818. */
  101819. serialize(): any;
  101820. /**
  101821. * Dispose the texture and release its associated resources.
  101822. */
  101823. dispose(): void;
  101824. }
  101825. }
  101826. declare module BABYLON {
  101827. /**
  101828. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101829. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101830. */
  101831. export class Texture extends BaseTexture {
  101832. /**
  101833. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101834. */
  101835. static SerializeBuffers: boolean;
  101836. /** @hidden */
  101837. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101838. /** @hidden */
  101839. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101840. /** @hidden */
  101841. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101842. /** nearest is mag = nearest and min = nearest and mip = linear */
  101843. static readonly NEAREST_SAMPLINGMODE: number;
  101844. /** nearest is mag = nearest and min = nearest and mip = linear */
  101845. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101846. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101847. static readonly BILINEAR_SAMPLINGMODE: number;
  101848. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101849. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101850. /** Trilinear is mag = linear and min = linear and mip = linear */
  101851. static readonly TRILINEAR_SAMPLINGMODE: number;
  101852. /** Trilinear is mag = linear and min = linear and mip = linear */
  101853. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101854. /** mag = nearest and min = nearest and mip = nearest */
  101855. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101856. /** mag = nearest and min = linear and mip = nearest */
  101857. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101858. /** mag = nearest and min = linear and mip = linear */
  101859. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101860. /** mag = nearest and min = linear and mip = none */
  101861. static readonly NEAREST_LINEAR: number;
  101862. /** mag = nearest and min = nearest and mip = none */
  101863. static readonly NEAREST_NEAREST: number;
  101864. /** mag = linear and min = nearest and mip = nearest */
  101865. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101866. /** mag = linear and min = nearest and mip = linear */
  101867. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101868. /** mag = linear and min = linear and mip = none */
  101869. static readonly LINEAR_LINEAR: number;
  101870. /** mag = linear and min = nearest and mip = none */
  101871. static readonly LINEAR_NEAREST: number;
  101872. /** Explicit coordinates mode */
  101873. static readonly EXPLICIT_MODE: number;
  101874. /** Spherical coordinates mode */
  101875. static readonly SPHERICAL_MODE: number;
  101876. /** Planar coordinates mode */
  101877. static readonly PLANAR_MODE: number;
  101878. /** Cubic coordinates mode */
  101879. static readonly CUBIC_MODE: number;
  101880. /** Projection coordinates mode */
  101881. static readonly PROJECTION_MODE: number;
  101882. /** Inverse Cubic coordinates mode */
  101883. static readonly SKYBOX_MODE: number;
  101884. /** Inverse Cubic coordinates mode */
  101885. static readonly INVCUBIC_MODE: number;
  101886. /** Equirectangular coordinates mode */
  101887. static readonly EQUIRECTANGULAR_MODE: number;
  101888. /** Equirectangular Fixed coordinates mode */
  101889. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101890. /** Equirectangular Fixed Mirrored coordinates mode */
  101891. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101892. /** Texture is not repeating outside of 0..1 UVs */
  101893. static readonly CLAMP_ADDRESSMODE: number;
  101894. /** Texture is repeating outside of 0..1 UVs */
  101895. static readonly WRAP_ADDRESSMODE: number;
  101896. /** Texture is repeating and mirrored */
  101897. static readonly MIRROR_ADDRESSMODE: number;
  101898. /**
  101899. * 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
  101900. */
  101901. static UseSerializedUrlIfAny: boolean;
  101902. /**
  101903. * Define the url of the texture.
  101904. */
  101905. url: Nullable<string>;
  101906. /**
  101907. * Define an offset on the texture to offset the u coordinates of the UVs
  101908. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101909. */
  101910. uOffset: number;
  101911. /**
  101912. * Define an offset on the texture to offset the v coordinates of the UVs
  101913. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101914. */
  101915. vOffset: number;
  101916. /**
  101917. * Define an offset on the texture to scale the u coordinates of the UVs
  101918. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101919. */
  101920. uScale: number;
  101921. /**
  101922. * Define an offset on the texture to scale the v coordinates of the UVs
  101923. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101924. */
  101925. vScale: number;
  101926. /**
  101927. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101928. * @see https://doc.babylonjs.com/how_to/more_materials
  101929. */
  101930. uAng: number;
  101931. /**
  101932. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101933. * @see https://doc.babylonjs.com/how_to/more_materials
  101934. */
  101935. vAng: number;
  101936. /**
  101937. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101938. * @see https://doc.babylonjs.com/how_to/more_materials
  101939. */
  101940. wAng: number;
  101941. /**
  101942. * Defines the center of rotation (U)
  101943. */
  101944. uRotationCenter: number;
  101945. /**
  101946. * Defines the center of rotation (V)
  101947. */
  101948. vRotationCenter: number;
  101949. /**
  101950. * Defines the center of rotation (W)
  101951. */
  101952. wRotationCenter: number;
  101953. /**
  101954. * Are mip maps generated for this texture or not.
  101955. */
  101956. get noMipmap(): boolean;
  101957. /**
  101958. * List of inspectable custom properties (used by the Inspector)
  101959. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101960. */
  101961. inspectableCustomProperties: Nullable<IInspectable[]>;
  101962. private _noMipmap;
  101963. /** @hidden */
  101964. _invertY: boolean;
  101965. private _rowGenerationMatrix;
  101966. private _cachedTextureMatrix;
  101967. private _projectionModeMatrix;
  101968. private _t0;
  101969. private _t1;
  101970. private _t2;
  101971. private _cachedUOffset;
  101972. private _cachedVOffset;
  101973. private _cachedUScale;
  101974. private _cachedVScale;
  101975. private _cachedUAng;
  101976. private _cachedVAng;
  101977. private _cachedWAng;
  101978. private _cachedProjectionMatrixId;
  101979. private _cachedCoordinatesMode;
  101980. /** @hidden */
  101981. protected _initialSamplingMode: number;
  101982. /** @hidden */
  101983. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101984. private _deleteBuffer;
  101985. protected _format: Nullable<number>;
  101986. private _delayedOnLoad;
  101987. private _delayedOnError;
  101988. private _mimeType?;
  101989. /**
  101990. * Observable triggered once the texture has been loaded.
  101991. */
  101992. onLoadObservable: Observable<Texture>;
  101993. protected _isBlocking: boolean;
  101994. /**
  101995. * Is the texture preventing material to render while loading.
  101996. * If false, a default texture will be used instead of the loading one during the preparation step.
  101997. */
  101998. set isBlocking(value: boolean);
  101999. get isBlocking(): boolean;
  102000. /**
  102001. * Get the current sampling mode associated with the texture.
  102002. */
  102003. get samplingMode(): number;
  102004. /**
  102005. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  102006. */
  102007. get invertY(): boolean;
  102008. /**
  102009. * Instantiates a new texture.
  102010. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102011. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102012. * @param url defines the url of the picture to load as a texture
  102013. * @param sceneOrEngine defines the scene or engine the texture will belong to
  102014. * @param noMipmap defines if the texture will require mip maps or not
  102015. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  102016. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102017. * @param onLoad defines a callback triggered when the texture has been loaded
  102018. * @param onError defines a callback triggered when an error occurred during the loading session
  102019. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  102020. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  102021. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102022. * @param mimeType defines an optional mime type information
  102023. */
  102024. 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);
  102025. /**
  102026. * Update the url (and optional buffer) of this texture if url was null during construction.
  102027. * @param url the url of the texture
  102028. * @param buffer the buffer of the texture (defaults to null)
  102029. * @param onLoad callback called when the texture is loaded (defaults to null)
  102030. */
  102031. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  102032. /**
  102033. * Finish the loading sequence of a texture flagged as delayed load.
  102034. * @hidden
  102035. */
  102036. delayLoad(): void;
  102037. private _prepareRowForTextureGeneration;
  102038. /**
  102039. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  102040. * @returns the transform matrix of the texture.
  102041. */
  102042. getTextureMatrix(uBase?: number): Matrix;
  102043. /**
  102044. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  102045. * @returns The reflection texture transform
  102046. */
  102047. getReflectionTextureMatrix(): Matrix;
  102048. /**
  102049. * Clones the texture.
  102050. * @returns the cloned texture
  102051. */
  102052. clone(): Texture;
  102053. /**
  102054. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102055. * @returns The JSON representation of the texture
  102056. */
  102057. serialize(): any;
  102058. /**
  102059. * Get the current class name of the texture useful for serialization or dynamic coding.
  102060. * @returns "Texture"
  102061. */
  102062. getClassName(): string;
  102063. /**
  102064. * Dispose the texture and release its associated resources.
  102065. */
  102066. dispose(): void;
  102067. /**
  102068. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  102069. * @param parsedTexture Define the JSON representation of the texture
  102070. * @param scene Define the scene the parsed texture should be instantiated in
  102071. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102072. * @returns The parsed texture if successful
  102073. */
  102074. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  102075. /**
  102076. * Creates a texture from its base 64 representation.
  102077. * @param data Define the base64 payload without the data: prefix
  102078. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102079. * @param scene Define the scene the texture should belong to
  102080. * @param noMipmap Forces the texture to not create mip map information if true
  102081. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102082. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102083. * @param onLoad define a callback triggered when the texture has been loaded
  102084. * @param onError define a callback triggered when an error occurred during the loading session
  102085. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102086. * @returns the created texture
  102087. */
  102088. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  102089. /**
  102090. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  102091. * @param data Define the base64 payload without the data: prefix
  102092. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102093. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  102094. * @param scene Define the scene the texture should belong to
  102095. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  102096. * @param noMipmap Forces the texture to not create mip map information if true
  102097. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102098. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102099. * @param onLoad define a callback triggered when the texture has been loaded
  102100. * @param onError define a callback triggered when an error occurred during the loading session
  102101. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102102. * @returns the created texture
  102103. */
  102104. 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;
  102105. }
  102106. }
  102107. declare module BABYLON {
  102108. /**
  102109. * PostProcessManager is used to manage one or more post processes or post process pipelines
  102110. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102111. */
  102112. export class PostProcessManager {
  102113. private _scene;
  102114. private _indexBuffer;
  102115. private _vertexBuffers;
  102116. /**
  102117. * Creates a new instance PostProcess
  102118. * @param scene The scene that the post process is associated with.
  102119. */
  102120. constructor(scene: Scene);
  102121. private _prepareBuffers;
  102122. private _buildIndexBuffer;
  102123. /**
  102124. * Rebuilds the vertex buffers of the manager.
  102125. * @hidden
  102126. */
  102127. _rebuild(): void;
  102128. /**
  102129. * Prepares a frame to be run through a post process.
  102130. * @param sourceTexture The input texture to the post procesess. (default: null)
  102131. * @param postProcesses An array of post processes to be run. (default: null)
  102132. * @returns True if the post processes were able to be run.
  102133. * @hidden
  102134. */
  102135. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  102136. /**
  102137. * Manually render a set of post processes to a texture.
  102138. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  102139. * @param postProcesses An array of post processes to be run.
  102140. * @param targetTexture The target texture to render to.
  102141. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  102142. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  102143. * @param lodLevel defines which lod of the texture to render to
  102144. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  102145. */
  102146. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  102147. /**
  102148. * Finalize the result of the output of the postprocesses.
  102149. * @param doNotPresent If true the result will not be displayed to the screen.
  102150. * @param targetTexture The target texture to render to.
  102151. * @param faceIndex The index of the face to bind the target texture to.
  102152. * @param postProcesses The array of post processes to render.
  102153. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  102154. * @hidden
  102155. */
  102156. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  102157. /**
  102158. * Disposes of the post process manager.
  102159. */
  102160. dispose(): void;
  102161. }
  102162. }
  102163. declare module BABYLON {
  102164. /**
  102165. * This Helps creating a texture that will be created from a camera in your scene.
  102166. * It is basically a dynamic texture that could be used to create special effects for instance.
  102167. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  102168. */
  102169. export class RenderTargetTexture extends Texture {
  102170. isCube: boolean;
  102171. /**
  102172. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  102173. */
  102174. static readonly REFRESHRATE_RENDER_ONCE: number;
  102175. /**
  102176. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  102177. */
  102178. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  102179. /**
  102180. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  102181. * the central point of your effect and can save a lot of performances.
  102182. */
  102183. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  102184. /**
  102185. * Use this predicate to dynamically define the list of mesh you want to render.
  102186. * If set, the renderList property will be overwritten.
  102187. */
  102188. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  102189. private _renderList;
  102190. /**
  102191. * Use this list to define the list of mesh you want to render.
  102192. */
  102193. get renderList(): Nullable<Array<AbstractMesh>>;
  102194. set renderList(value: Nullable<Array<AbstractMesh>>);
  102195. /**
  102196. * Use this function to overload the renderList array at rendering time.
  102197. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  102198. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  102199. * the cube (if the RTT is a cube, else layerOrFace=0).
  102200. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  102201. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  102202. * hold dummy elements!
  102203. */
  102204. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  102205. private _hookArray;
  102206. /**
  102207. * Define if particles should be rendered in your texture.
  102208. */
  102209. renderParticles: boolean;
  102210. /**
  102211. * Define if sprites should be rendered in your texture.
  102212. */
  102213. renderSprites: boolean;
  102214. /**
  102215. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  102216. */
  102217. coordinatesMode: number;
  102218. /**
  102219. * Define the camera used to render the texture.
  102220. */
  102221. activeCamera: Nullable<Camera>;
  102222. /**
  102223. * Override the mesh isReady function with your own one.
  102224. */
  102225. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  102226. /**
  102227. * Override the render function of the texture with your own one.
  102228. */
  102229. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  102230. /**
  102231. * Define if camera post processes should be use while rendering the texture.
  102232. */
  102233. useCameraPostProcesses: boolean;
  102234. /**
  102235. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  102236. */
  102237. ignoreCameraViewport: boolean;
  102238. private _postProcessManager;
  102239. private _postProcesses;
  102240. private _resizeObserver;
  102241. /**
  102242. * An event triggered when the texture is unbind.
  102243. */
  102244. onBeforeBindObservable: Observable<RenderTargetTexture>;
  102245. /**
  102246. * An event triggered when the texture is unbind.
  102247. */
  102248. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  102249. private _onAfterUnbindObserver;
  102250. /**
  102251. * Set a after unbind callback in the texture.
  102252. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  102253. */
  102254. set onAfterUnbind(callback: () => void);
  102255. /**
  102256. * An event triggered before rendering the texture
  102257. */
  102258. onBeforeRenderObservable: Observable<number>;
  102259. private _onBeforeRenderObserver;
  102260. /**
  102261. * Set a before render callback in the texture.
  102262. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  102263. */
  102264. set onBeforeRender(callback: (faceIndex: number) => void);
  102265. /**
  102266. * An event triggered after rendering the texture
  102267. */
  102268. onAfterRenderObservable: Observable<number>;
  102269. private _onAfterRenderObserver;
  102270. /**
  102271. * Set a after render callback in the texture.
  102272. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  102273. */
  102274. set onAfterRender(callback: (faceIndex: number) => void);
  102275. /**
  102276. * An event triggered after the texture clear
  102277. */
  102278. onClearObservable: Observable<Engine>;
  102279. private _onClearObserver;
  102280. /**
  102281. * Set a clear callback in the texture.
  102282. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  102283. */
  102284. set onClear(callback: (Engine: Engine) => void);
  102285. /**
  102286. * An event triggered when the texture is resized.
  102287. */
  102288. onResizeObservable: Observable<RenderTargetTexture>;
  102289. /**
  102290. * Define the clear color of the Render Target if it should be different from the scene.
  102291. */
  102292. clearColor: Color4;
  102293. protected _size: number | {
  102294. width: number;
  102295. height: number;
  102296. layers?: number;
  102297. };
  102298. protected _initialSizeParameter: number | {
  102299. width: number;
  102300. height: number;
  102301. } | {
  102302. ratio: number;
  102303. };
  102304. protected _sizeRatio: Nullable<number>;
  102305. /** @hidden */
  102306. _generateMipMaps: boolean;
  102307. protected _renderingManager: RenderingManager;
  102308. /** @hidden */
  102309. _waitingRenderList: string[];
  102310. protected _doNotChangeAspectRatio: boolean;
  102311. protected _currentRefreshId: number;
  102312. protected _refreshRate: number;
  102313. protected _textureMatrix: Matrix;
  102314. protected _samples: number;
  102315. protected _renderTargetOptions: RenderTargetCreationOptions;
  102316. /**
  102317. * Gets render target creation options that were used.
  102318. */
  102319. get renderTargetOptions(): RenderTargetCreationOptions;
  102320. protected _onRatioRescale(): void;
  102321. /**
  102322. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  102323. * It must define where the camera used to render the texture is set
  102324. */
  102325. boundingBoxPosition: Vector3;
  102326. private _boundingBoxSize;
  102327. /**
  102328. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  102329. * When defined, the cubemap will switch to local mode
  102330. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102331. * @example https://www.babylonjs-playground.com/#RNASML
  102332. */
  102333. set boundingBoxSize(value: Vector3);
  102334. get boundingBoxSize(): Vector3;
  102335. /**
  102336. * In case the RTT has been created with a depth texture, get the associated
  102337. * depth texture.
  102338. * Otherwise, return null.
  102339. */
  102340. get depthStencilTexture(): Nullable<InternalTexture>;
  102341. /**
  102342. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  102343. * or used a shadow, depth texture...
  102344. * @param name The friendly name of the texture
  102345. * @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)
  102346. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  102347. * @param generateMipMaps True if mip maps need to be generated after render.
  102348. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  102349. * @param type The type of the buffer in the RTT (int, half float, float...)
  102350. * @param isCube True if a cube texture needs to be created
  102351. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  102352. * @param generateDepthBuffer True to generate a depth buffer
  102353. * @param generateStencilBuffer True to generate a stencil buffer
  102354. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  102355. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  102356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102357. */
  102358. constructor(name: string, size: number | {
  102359. width: number;
  102360. height: number;
  102361. layers?: number;
  102362. } | {
  102363. ratio: number;
  102364. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102365. /**
  102366. * Creates a depth stencil texture.
  102367. * This is only available in WebGL 2 or with the depth texture extension available.
  102368. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102369. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102370. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102371. */
  102372. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102373. private _processSizeParameter;
  102374. /**
  102375. * Define the number of samples to use in case of MSAA.
  102376. * It defaults to one meaning no MSAA has been enabled.
  102377. */
  102378. get samples(): number;
  102379. set samples(value: number);
  102380. /**
  102381. * Resets the refresh counter of the texture and start bak from scratch.
  102382. * Could be useful to regenerate the texture if it is setup to render only once.
  102383. */
  102384. resetRefreshCounter(): void;
  102385. /**
  102386. * Define the refresh rate of the texture or the rendering frequency.
  102387. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102388. */
  102389. get refreshRate(): number;
  102390. set refreshRate(value: number);
  102391. /**
  102392. * Adds a post process to the render target rendering passes.
  102393. * @param postProcess define the post process to add
  102394. */
  102395. addPostProcess(postProcess: PostProcess): void;
  102396. /**
  102397. * Clear all the post processes attached to the render target
  102398. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102399. */
  102400. clearPostProcesses(dispose?: boolean): void;
  102401. /**
  102402. * Remove one of the post process from the list of attached post processes to the texture
  102403. * @param postProcess define the post process to remove from the list
  102404. */
  102405. removePostProcess(postProcess: PostProcess): void;
  102406. /** @hidden */
  102407. _shouldRender(): boolean;
  102408. /**
  102409. * Gets the actual render size of the texture.
  102410. * @returns the width of the render size
  102411. */
  102412. getRenderSize(): number;
  102413. /**
  102414. * Gets the actual render width of the texture.
  102415. * @returns the width of the render size
  102416. */
  102417. getRenderWidth(): number;
  102418. /**
  102419. * Gets the actual render height of the texture.
  102420. * @returns the height of the render size
  102421. */
  102422. getRenderHeight(): number;
  102423. /**
  102424. * Gets the actual number of layers of the texture.
  102425. * @returns the number of layers
  102426. */
  102427. getRenderLayers(): number;
  102428. /**
  102429. * Get if the texture can be rescaled or not.
  102430. */
  102431. get canRescale(): boolean;
  102432. /**
  102433. * Resize the texture using a ratio.
  102434. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  102435. */
  102436. scale(ratio: number): void;
  102437. /**
  102438. * Get the texture reflection matrix used to rotate/transform the reflection.
  102439. * @returns the reflection matrix
  102440. */
  102441. getReflectionTextureMatrix(): Matrix;
  102442. /**
  102443. * Resize the texture to a new desired size.
  102444. * Be carrefull as it will recreate all the data in the new texture.
  102445. * @param size Define the new size. It can be:
  102446. * - a number for squared texture,
  102447. * - an object containing { width: number, height: number }
  102448. * - or an object containing a ratio { ratio: number }
  102449. */
  102450. resize(size: number | {
  102451. width: number;
  102452. height: number;
  102453. } | {
  102454. ratio: number;
  102455. }): void;
  102456. private _defaultRenderListPrepared;
  102457. /**
  102458. * Renders all the objects from the render list into the texture.
  102459. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  102460. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  102461. */
  102462. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  102463. private _bestReflectionRenderTargetDimension;
  102464. private _prepareRenderingManager;
  102465. /**
  102466. * @hidden
  102467. * @param faceIndex face index to bind to if this is a cubetexture
  102468. * @param layer defines the index of the texture to bind in the array
  102469. */
  102470. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  102471. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102472. private renderToTarget;
  102473. /**
  102474. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102475. * This allowed control for front to back rendering or reversly depending of the special needs.
  102476. *
  102477. * @param renderingGroupId The rendering group id corresponding to its index
  102478. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102479. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102480. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102481. */
  102482. 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;
  102483. /**
  102484. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102485. *
  102486. * @param renderingGroupId The rendering group id corresponding to its index
  102487. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102488. */
  102489. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102490. /**
  102491. * Clones the texture.
  102492. * @returns the cloned texture
  102493. */
  102494. clone(): RenderTargetTexture;
  102495. /**
  102496. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102497. * @returns The JSON representation of the texture
  102498. */
  102499. serialize(): any;
  102500. /**
  102501. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  102502. */
  102503. disposeFramebufferObjects(): void;
  102504. /**
  102505. * Dispose the texture and release its associated resources.
  102506. */
  102507. dispose(): void;
  102508. /** @hidden */
  102509. _rebuild(): void;
  102510. /**
  102511. * Clear the info related to rendering groups preventing retention point in material dispose.
  102512. */
  102513. freeRenderingGroups(): void;
  102514. /**
  102515. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  102516. * @returns the view count
  102517. */
  102518. getViewCount(): number;
  102519. }
  102520. }
  102521. declare module BABYLON {
  102522. /**
  102523. * Class used to manipulate GUIDs
  102524. */
  102525. export class GUID {
  102526. /**
  102527. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102528. * Be aware Math.random() could cause collisions, but:
  102529. * "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"
  102530. * @returns a pseudo random id
  102531. */
  102532. static RandomId(): string;
  102533. }
  102534. }
  102535. declare module BABYLON {
  102536. /**
  102537. * Options to be used when creating a shadow depth material
  102538. */
  102539. export interface IIOptionShadowDepthMaterial {
  102540. /** Variables in the vertex shader code that need to have their names remapped.
  102541. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  102542. * "var_name" should be either: worldPos or vNormalW
  102543. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  102544. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  102545. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  102546. */
  102547. remappedVariables?: string[];
  102548. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  102549. standalone?: boolean;
  102550. }
  102551. /**
  102552. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  102553. */
  102554. export class ShadowDepthWrapper {
  102555. private _scene;
  102556. private _options?;
  102557. private _baseMaterial;
  102558. private _onEffectCreatedObserver;
  102559. private _subMeshToEffect;
  102560. private _subMeshToDepthEffect;
  102561. private _meshes;
  102562. /** @hidden */
  102563. _matriceNames: any;
  102564. /** Gets the standalone status of the wrapper */
  102565. get standalone(): boolean;
  102566. /** Gets the base material the wrapper is built upon */
  102567. get baseMaterial(): Material;
  102568. /**
  102569. * Instantiate a new shadow depth wrapper.
  102570. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  102571. * generate the shadow depth map. For more information, please refer to the documentation:
  102572. * https://doc.babylonjs.com/babylon101/shadows
  102573. * @param baseMaterial Material to wrap
  102574. * @param scene Define the scene the material belongs to
  102575. * @param options Options used to create the wrapper
  102576. */
  102577. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  102578. /**
  102579. * Gets the effect to use to generate the depth map
  102580. * @param subMesh subMesh to get the effect for
  102581. * @param shadowGenerator shadow generator to get the effect for
  102582. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  102583. */
  102584. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  102585. /**
  102586. * Specifies that the submesh is ready to be used for depth rendering
  102587. * @param subMesh submesh to check
  102588. * @param defines the list of defines to take into account when checking the effect
  102589. * @param shadowGenerator combined with subMesh, it defines the effect to check
  102590. * @param useInstances specifies that instances should be used
  102591. * @returns a boolean indicating that the submesh is ready or not
  102592. */
  102593. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  102594. /**
  102595. * Disposes the resources
  102596. */
  102597. dispose(): void;
  102598. private _makeEffect;
  102599. }
  102600. }
  102601. declare module BABYLON {
  102602. interface ThinEngine {
  102603. /**
  102604. * Unbind a list of render target textures from the webGL context
  102605. * This is used only when drawBuffer extension or webGL2 are active
  102606. * @param textures defines the render target textures to unbind
  102607. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102608. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102609. */
  102610. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102611. /**
  102612. * Create a multi render target texture
  102613. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102614. * @param size defines the size of the texture
  102615. * @param options defines the creation options
  102616. * @returns the cube texture as an InternalTexture
  102617. */
  102618. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102619. /**
  102620. * Update the sample count for a given multiple render target texture
  102621. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102622. * @param textures defines the textures to update
  102623. * @param samples defines the sample count to set
  102624. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102625. */
  102626. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102627. /**
  102628. * Select a subsets of attachments to draw to.
  102629. * @param attachments gl attachments
  102630. */
  102631. bindAttachments(attachments: number[]): void;
  102632. }
  102633. }
  102634. declare module BABYLON {
  102635. /**
  102636. * Creation options of the multi render target texture.
  102637. */
  102638. export interface IMultiRenderTargetOptions {
  102639. /**
  102640. * Define if the texture needs to create mip maps after render.
  102641. */
  102642. generateMipMaps?: boolean;
  102643. /**
  102644. * Define the types of all the draw buffers we want to create
  102645. */
  102646. types?: number[];
  102647. /**
  102648. * Define the sampling modes of all the draw buffers we want to create
  102649. */
  102650. samplingModes?: number[];
  102651. /**
  102652. * Define if a depth buffer is required
  102653. */
  102654. generateDepthBuffer?: boolean;
  102655. /**
  102656. * Define if a stencil buffer is required
  102657. */
  102658. generateStencilBuffer?: boolean;
  102659. /**
  102660. * Define if a depth texture is required instead of a depth buffer
  102661. */
  102662. generateDepthTexture?: boolean;
  102663. /**
  102664. * Define the number of desired draw buffers
  102665. */
  102666. textureCount?: number;
  102667. /**
  102668. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102669. */
  102670. doNotChangeAspectRatio?: boolean;
  102671. /**
  102672. * Define the default type of the buffers we are creating
  102673. */
  102674. defaultType?: number;
  102675. }
  102676. /**
  102677. * A multi render target, like a render target provides the ability to render to a texture.
  102678. * Unlike the render target, it can render to several draw buffers in one draw.
  102679. * This is specially interesting in deferred rendering or for any effects requiring more than
  102680. * just one color from a single pass.
  102681. */
  102682. export class MultiRenderTarget extends RenderTargetTexture {
  102683. private _internalTextures;
  102684. private _textures;
  102685. private _multiRenderTargetOptions;
  102686. private _count;
  102687. /**
  102688. * Get if draw buffers are currently supported by the used hardware and browser.
  102689. */
  102690. get isSupported(): boolean;
  102691. /**
  102692. * Get the list of textures generated by the multi render target.
  102693. */
  102694. get textures(): Texture[];
  102695. /**
  102696. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102697. */
  102698. get count(): number;
  102699. /**
  102700. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102701. */
  102702. get depthTexture(): Texture;
  102703. /**
  102704. * Set the wrapping mode on U 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 wrapU(wrap: number);
  102708. /**
  102709. * Set the wrapping mode on V of all the textures we are rendering to.
  102710. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102711. */
  102712. set wrapV(wrap: number);
  102713. /**
  102714. * Instantiate a new multi render target texture.
  102715. * A multi render target, like a render target provides the ability to render to a texture.
  102716. * Unlike the render target, it can render to several draw buffers in one draw.
  102717. * This is specially interesting in deferred rendering or for any effects requiring more than
  102718. * just one color from a single pass.
  102719. * @param name Define the name of the texture
  102720. * @param size Define the size of the buffers to render to
  102721. * @param count Define the number of target we are rendering into
  102722. * @param scene Define the scene the texture belongs to
  102723. * @param options Define the options used to create the multi render target
  102724. */
  102725. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102726. /** @hidden */
  102727. _rebuild(): void;
  102728. private _createInternalTextures;
  102729. private _createTextures;
  102730. /**
  102731. * Define the number of samples used if MSAA is enabled.
  102732. */
  102733. get samples(): number;
  102734. set samples(value: number);
  102735. /**
  102736. * Resize all the textures in the multi render target.
  102737. * Be carrefull as it will recreate all the data in the new texture.
  102738. * @param size Define the new size
  102739. */
  102740. resize(size: any): void;
  102741. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102742. /**
  102743. * Dispose the render targets and their associated resources
  102744. */
  102745. dispose(): void;
  102746. /**
  102747. * Release all the underlying texture used as draw buffers.
  102748. */
  102749. releaseInternalTextures(): void;
  102750. }
  102751. }
  102752. declare module BABYLON {
  102753. /** @hidden */
  102754. export var imageProcessingPixelShader: {
  102755. name: string;
  102756. shader: string;
  102757. };
  102758. }
  102759. declare module BABYLON {
  102760. /**
  102761. * ImageProcessingPostProcess
  102762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102763. */
  102764. export class ImageProcessingPostProcess extends PostProcess {
  102765. /**
  102766. * Default configuration related to image processing available in the PBR Material.
  102767. */
  102768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102769. /**
  102770. * Gets the image processing configuration used either in this material.
  102771. */
  102772. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102773. /**
  102774. * Sets the Default image processing configuration used either in the this material.
  102775. *
  102776. * If sets to null, the scene one is in use.
  102777. */
  102778. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102779. /**
  102780. * Keep track of the image processing observer to allow dispose and replace.
  102781. */
  102782. private _imageProcessingObserver;
  102783. /**
  102784. * Attaches a new image processing configuration to the PBR Material.
  102785. * @param configuration
  102786. */
  102787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102788. /**
  102789. * If the post process is supported.
  102790. */
  102791. get isSupported(): boolean;
  102792. /**
  102793. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102794. */
  102795. get colorCurves(): Nullable<ColorCurves>;
  102796. /**
  102797. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102798. */
  102799. set colorCurves(value: Nullable<ColorCurves>);
  102800. /**
  102801. * Gets wether the color curves effect is enabled.
  102802. */
  102803. get colorCurvesEnabled(): boolean;
  102804. /**
  102805. * Sets wether the color curves effect is enabled.
  102806. */
  102807. set colorCurvesEnabled(value: boolean);
  102808. /**
  102809. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102810. */
  102811. get colorGradingTexture(): Nullable<BaseTexture>;
  102812. /**
  102813. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102814. */
  102815. set colorGradingTexture(value: Nullable<BaseTexture>);
  102816. /**
  102817. * Gets wether the color grading effect is enabled.
  102818. */
  102819. get colorGradingEnabled(): boolean;
  102820. /**
  102821. * Gets wether the color grading effect is enabled.
  102822. */
  102823. set colorGradingEnabled(value: boolean);
  102824. /**
  102825. * Gets exposure used in the effect.
  102826. */
  102827. get exposure(): number;
  102828. /**
  102829. * Sets exposure used in the effect.
  102830. */
  102831. set exposure(value: number);
  102832. /**
  102833. * Gets wether tonemapping is enabled or not.
  102834. */
  102835. get toneMappingEnabled(): boolean;
  102836. /**
  102837. * Sets wether tonemapping is enabled or not
  102838. */
  102839. set toneMappingEnabled(value: boolean);
  102840. /**
  102841. * Gets the type of tone mapping effect.
  102842. */
  102843. get toneMappingType(): number;
  102844. /**
  102845. * Sets the type of tone mapping effect.
  102846. */
  102847. set toneMappingType(value: number);
  102848. /**
  102849. * Gets contrast used in the effect.
  102850. */
  102851. get contrast(): number;
  102852. /**
  102853. * Sets contrast used in the effect.
  102854. */
  102855. set contrast(value: number);
  102856. /**
  102857. * Gets Vignette stretch size.
  102858. */
  102859. get vignetteStretch(): number;
  102860. /**
  102861. * Sets Vignette stretch size.
  102862. */
  102863. set vignetteStretch(value: number);
  102864. /**
  102865. * Gets Vignette centre X Offset.
  102866. */
  102867. get vignetteCentreX(): number;
  102868. /**
  102869. * Sets Vignette centre X Offset.
  102870. */
  102871. set vignetteCentreX(value: number);
  102872. /**
  102873. * Gets Vignette centre Y Offset.
  102874. */
  102875. get vignetteCentreY(): number;
  102876. /**
  102877. * Sets Vignette centre Y Offset.
  102878. */
  102879. set vignetteCentreY(value: number);
  102880. /**
  102881. * Gets Vignette weight or intensity of the vignette effect.
  102882. */
  102883. get vignetteWeight(): number;
  102884. /**
  102885. * Sets Vignette weight or intensity of the vignette effect.
  102886. */
  102887. set vignetteWeight(value: number);
  102888. /**
  102889. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102890. * if vignetteEnabled is set to true.
  102891. */
  102892. get vignetteColor(): Color4;
  102893. /**
  102894. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102895. * if vignetteEnabled is set to true.
  102896. */
  102897. set vignetteColor(value: Color4);
  102898. /**
  102899. * Gets Camera field of view used by the Vignette effect.
  102900. */
  102901. get vignetteCameraFov(): number;
  102902. /**
  102903. * Sets Camera field of view used by the Vignette effect.
  102904. */
  102905. set vignetteCameraFov(value: number);
  102906. /**
  102907. * Gets the vignette blend mode allowing different kind of effect.
  102908. */
  102909. get vignetteBlendMode(): number;
  102910. /**
  102911. * Sets the vignette blend mode allowing different kind of effect.
  102912. */
  102913. set vignetteBlendMode(value: number);
  102914. /**
  102915. * Gets wether the vignette effect is enabled.
  102916. */
  102917. get vignetteEnabled(): boolean;
  102918. /**
  102919. * Sets wether the vignette effect is enabled.
  102920. */
  102921. set vignetteEnabled(value: boolean);
  102922. private _fromLinearSpace;
  102923. /**
  102924. * Gets wether the input of the processing is in Gamma or Linear Space.
  102925. */
  102926. get fromLinearSpace(): boolean;
  102927. /**
  102928. * Sets wether the input of the processing is in Gamma or Linear Space.
  102929. */
  102930. set fromLinearSpace(value: boolean);
  102931. /**
  102932. * Defines cache preventing GC.
  102933. */
  102934. private _defines;
  102935. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102936. /**
  102937. * "ImageProcessingPostProcess"
  102938. * @returns "ImageProcessingPostProcess"
  102939. */
  102940. getClassName(): string;
  102941. /**
  102942. * @hidden
  102943. */
  102944. _updateParameters(): void;
  102945. dispose(camera?: Camera): void;
  102946. }
  102947. }
  102948. declare module BABYLON {
  102949. /** @hidden */
  102950. export var fibonacci: {
  102951. name: string;
  102952. shader: string;
  102953. };
  102954. }
  102955. declare module BABYLON {
  102956. /** @hidden */
  102957. export var subSurfaceScatteringFunctions: {
  102958. name: string;
  102959. shader: string;
  102960. };
  102961. }
  102962. declare module BABYLON {
  102963. /** @hidden */
  102964. export var diffusionProfile: {
  102965. name: string;
  102966. shader: string;
  102967. };
  102968. }
  102969. declare module BABYLON {
  102970. /** @hidden */
  102971. export var subSurfaceScatteringPixelShader: {
  102972. name: string;
  102973. shader: string;
  102974. };
  102975. }
  102976. declare module BABYLON {
  102977. /**
  102978. * Sub surface scattering post process
  102979. */
  102980. export class SubSurfaceScatteringPostProcess extends PostProcess {
  102981. /** @hidden */
  102982. texelWidth: number;
  102983. /** @hidden */
  102984. texelHeight: number;
  102985. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  102986. }
  102987. }
  102988. declare module BABYLON {
  102989. /**
  102990. * Interface for defining prepass effects in the prepass post-process pipeline
  102991. */
  102992. export interface PrePassEffectConfiguration {
  102993. /**
  102994. * Post process to attach for this effect
  102995. */
  102996. postProcess: PostProcess;
  102997. /**
  102998. * Is the effect enabled
  102999. */
  103000. enabled: boolean;
  103001. /**
  103002. * Disposes the effect configuration
  103003. */
  103004. dispose(): void;
  103005. /**
  103006. * Disposes the effect configuration
  103007. */
  103008. createPostProcess: () => PostProcess;
  103009. }
  103010. }
  103011. declare module BABYLON {
  103012. /**
  103013. * Contains all parameters needed for the prepass to perform
  103014. * screen space subsurface scattering
  103015. */
  103016. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  103017. private _ssDiffusionS;
  103018. private _ssFilterRadii;
  103019. private _ssDiffusionD;
  103020. /**
  103021. * Post process to attach for screen space subsurface scattering
  103022. */
  103023. postProcess: SubSurfaceScatteringPostProcess;
  103024. /**
  103025. * Diffusion profile color for subsurface scattering
  103026. */
  103027. get ssDiffusionS(): number[];
  103028. /**
  103029. * Diffusion profile max color channel value for subsurface scattering
  103030. */
  103031. get ssDiffusionD(): number[];
  103032. /**
  103033. * Diffusion profile filter radius for subsurface scattering
  103034. */
  103035. get ssFilterRadii(): number[];
  103036. /**
  103037. * Is subsurface enabled
  103038. */
  103039. enabled: boolean;
  103040. /**
  103041. * Diffusion profile colors for subsurface scattering
  103042. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  103043. * See ...
  103044. * Note that you can only store up to 5 of them
  103045. */
  103046. ssDiffusionProfileColors: Color3[];
  103047. /**
  103048. * Defines the ratio real world => scene units.
  103049. * Used for subsurface scattering
  103050. */
  103051. metersPerUnit: number;
  103052. private _scene;
  103053. /**
  103054. * Builds a subsurface configuration object
  103055. * @param scene The scene
  103056. */
  103057. constructor(scene: Scene);
  103058. /**
  103059. * Adds a new diffusion profile.
  103060. * Useful for more realistic subsurface scattering on diverse materials.
  103061. * @param color The color of the diffusion profile. Should be the average color of the material.
  103062. * @return The index of the diffusion profile for the material subsurface configuration
  103063. */
  103064. addDiffusionProfile(color: Color3): number;
  103065. /**
  103066. * Creates the sss post process
  103067. * @return The created post process
  103068. */
  103069. createPostProcess(): SubSurfaceScatteringPostProcess;
  103070. /**
  103071. * Deletes all diffusion profiles.
  103072. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  103073. */
  103074. clearAllDiffusionProfiles(): void;
  103075. /**
  103076. * Disposes this object
  103077. */
  103078. dispose(): void;
  103079. /**
  103080. * @hidden
  103081. * https://zero-radiance.github.io/post/sampling-diffusion/
  103082. *
  103083. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  103084. * ------------------------------------------------------------------------------------
  103085. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  103086. * PDF[r, phi, s] = r * R[r, phi, s]
  103087. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  103088. * ------------------------------------------------------------------------------------
  103089. * We importance sample the color channel with the widest scattering distance.
  103090. */
  103091. getDiffusionProfileParameters(color: Color3): number;
  103092. /**
  103093. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  103094. * 'u' is the random number (the value of the CDF): [0, 1).
  103095. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  103096. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  103097. */
  103098. private _sampleBurleyDiffusionProfile;
  103099. }
  103100. }
  103101. declare module BABYLON {
  103102. /**
  103103. * Renders a pre pass of the scene
  103104. * This means every mesh in the scene will be rendered to a render target texture
  103105. * And then this texture will be composited to the rendering canvas with post processes
  103106. * It is necessary for effects like subsurface scattering or deferred shading
  103107. */
  103108. export class PrePassRenderer {
  103109. /** @hidden */
  103110. static _SceneComponentInitialization: (scene: Scene) => void;
  103111. private _scene;
  103112. private _engine;
  103113. private _isDirty;
  103114. /**
  103115. * Number of textures in the multi render target texture where the scene is directly rendered
  103116. */
  103117. readonly mrtCount: number;
  103118. /**
  103119. * The render target where the scene is directly rendered
  103120. */
  103121. prePassRT: MultiRenderTarget;
  103122. private _mrtTypes;
  103123. private _multiRenderAttachments;
  103124. private _defaultAttachments;
  103125. private _clearAttachments;
  103126. private _postProcesses;
  103127. private readonly _clearColor;
  103128. /**
  103129. * Image processing post process for composition
  103130. */
  103131. imageProcessingPostProcess: ImageProcessingPostProcess;
  103132. /**
  103133. * Configuration for sub surface scattering post process
  103134. */
  103135. subSurfaceConfiguration: SubSurfaceConfiguration;
  103136. /**
  103137. * Should materials render their geometry on the MRT
  103138. */
  103139. materialsShouldRenderGeometry: boolean;
  103140. /**
  103141. * Should materials render the irradiance information on the MRT
  103142. */
  103143. materialsShouldRenderIrradiance: boolean;
  103144. private _enabled;
  103145. /**
  103146. * Indicates if the prepass is enabled
  103147. */
  103148. get enabled(): boolean;
  103149. /**
  103150. * How many samples are used for MSAA of the scene render target
  103151. */
  103152. get samples(): number;
  103153. set samples(n: number);
  103154. /**
  103155. * Instanciates a prepass renderer
  103156. * @param scene The scene
  103157. */
  103158. constructor(scene: Scene);
  103159. private _initializeAttachments;
  103160. private _createCompositionEffect;
  103161. /**
  103162. * Indicates if rendering a prepass is supported
  103163. */
  103164. get isSupported(): boolean;
  103165. /**
  103166. * Sets the proper output textures to draw in the engine.
  103167. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103168. */
  103169. bindAttachmentsForEffect(effect: Effect): void;
  103170. /**
  103171. * @hidden
  103172. */
  103173. _beforeCameraDraw(): void;
  103174. /**
  103175. * @hidden
  103176. */
  103177. _afterCameraDraw(): void;
  103178. private _checkRTSize;
  103179. private _bindFrameBuffer;
  103180. /**
  103181. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103182. */
  103183. clear(): void;
  103184. private _setState;
  103185. private _enable;
  103186. private _disable;
  103187. private _resetPostProcessChain;
  103188. private _bindPostProcessChain;
  103189. /**
  103190. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103191. */
  103192. markAsDirty(): void;
  103193. private _update;
  103194. /**
  103195. * Disposes the prepass renderer.
  103196. */
  103197. dispose(): void;
  103198. }
  103199. }
  103200. declare module BABYLON {
  103201. /**
  103202. * Options for compiling materials.
  103203. */
  103204. export interface IMaterialCompilationOptions {
  103205. /**
  103206. * Defines whether clip planes are enabled.
  103207. */
  103208. clipPlane: boolean;
  103209. /**
  103210. * Defines whether instances are enabled.
  103211. */
  103212. useInstances: boolean;
  103213. }
  103214. /**
  103215. * Options passed when calling customShaderNameResolve
  103216. */
  103217. export interface ICustomShaderNameResolveOptions {
  103218. /**
  103219. * 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
  103220. */
  103221. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  103222. }
  103223. /**
  103224. * Base class for the main features of a material in Babylon.js
  103225. */
  103226. export class Material implements IAnimatable {
  103227. /**
  103228. * Returns the triangle fill mode
  103229. */
  103230. static readonly TriangleFillMode: number;
  103231. /**
  103232. * Returns the wireframe mode
  103233. */
  103234. static readonly WireFrameFillMode: number;
  103235. /**
  103236. * Returns the point fill mode
  103237. */
  103238. static readonly PointFillMode: number;
  103239. /**
  103240. * Returns the point list draw mode
  103241. */
  103242. static readonly PointListDrawMode: number;
  103243. /**
  103244. * Returns the line list draw mode
  103245. */
  103246. static readonly LineListDrawMode: number;
  103247. /**
  103248. * Returns the line loop draw mode
  103249. */
  103250. static readonly LineLoopDrawMode: number;
  103251. /**
  103252. * Returns the line strip draw mode
  103253. */
  103254. static readonly LineStripDrawMode: number;
  103255. /**
  103256. * Returns the triangle strip draw mode
  103257. */
  103258. static readonly TriangleStripDrawMode: number;
  103259. /**
  103260. * Returns the triangle fan draw mode
  103261. */
  103262. static readonly TriangleFanDrawMode: number;
  103263. /**
  103264. * Stores the clock-wise side orientation
  103265. */
  103266. static readonly ClockWiseSideOrientation: number;
  103267. /**
  103268. * Stores the counter clock-wise side orientation
  103269. */
  103270. static readonly CounterClockWiseSideOrientation: number;
  103271. /**
  103272. * The dirty texture flag value
  103273. */
  103274. static readonly TextureDirtyFlag: number;
  103275. /**
  103276. * The dirty light flag value
  103277. */
  103278. static readonly LightDirtyFlag: number;
  103279. /**
  103280. * The dirty fresnel flag value
  103281. */
  103282. static readonly FresnelDirtyFlag: number;
  103283. /**
  103284. * The dirty attribute flag value
  103285. */
  103286. static readonly AttributesDirtyFlag: number;
  103287. /**
  103288. * The dirty misc flag value
  103289. */
  103290. static readonly MiscDirtyFlag: number;
  103291. /**
  103292. * The all dirty flag value
  103293. */
  103294. static readonly AllDirtyFlag: number;
  103295. /**
  103296. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103297. */
  103298. static readonly MATERIAL_OPAQUE: number;
  103299. /**
  103300. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103301. */
  103302. static readonly MATERIAL_ALPHATEST: number;
  103303. /**
  103304. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103305. */
  103306. static readonly MATERIAL_ALPHABLEND: number;
  103307. /**
  103308. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103309. * They are also discarded below the alpha cutoff threshold to improve performances.
  103310. */
  103311. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  103312. /**
  103313. * The Whiteout 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_WHITEOUT: number;
  103317. /**
  103318. * The Reoriented Normal Mapping method is used to blend normals.
  103319. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103320. */
  103321. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  103322. /**
  103323. * Custom callback helping to override the default shader used in the material.
  103324. */
  103325. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  103326. /**
  103327. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  103328. */
  103329. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  103330. /**
  103331. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  103332. * This means that the material can keep using a previous shader while a new one is being compiled.
  103333. * This is mostly used when shader parallel compilation is supported (true by default)
  103334. */
  103335. allowShaderHotSwapping: boolean;
  103336. /**
  103337. * The ID of the material
  103338. */
  103339. id: string;
  103340. /**
  103341. * Gets or sets the unique id of the material
  103342. */
  103343. uniqueId: number;
  103344. /**
  103345. * The name of the material
  103346. */
  103347. name: string;
  103348. /**
  103349. * Gets or sets user defined metadata
  103350. */
  103351. metadata: any;
  103352. /**
  103353. * For internal use only. Please do not use.
  103354. */
  103355. reservedDataStore: any;
  103356. /**
  103357. * Specifies if the ready state should be checked on each call
  103358. */
  103359. checkReadyOnEveryCall: boolean;
  103360. /**
  103361. * Specifies if the ready state should be checked once
  103362. */
  103363. checkReadyOnlyOnce: boolean;
  103364. /**
  103365. * The state of the material
  103366. */
  103367. state: string;
  103368. /**
  103369. * If the material can be rendered to several textures with MRT extension
  103370. */
  103371. get canRenderToMRT(): boolean;
  103372. /**
  103373. * The alpha value of the material
  103374. */
  103375. protected _alpha: number;
  103376. /**
  103377. * List of inspectable custom properties (used by the Inspector)
  103378. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103379. */
  103380. inspectableCustomProperties: IInspectable[];
  103381. /**
  103382. * Sets the alpha value of the material
  103383. */
  103384. set alpha(value: number);
  103385. /**
  103386. * Gets the alpha value of the material
  103387. */
  103388. get alpha(): number;
  103389. /**
  103390. * Specifies if back face culling is enabled
  103391. */
  103392. protected _backFaceCulling: boolean;
  103393. /**
  103394. * Sets the back-face culling state
  103395. */
  103396. set backFaceCulling(value: boolean);
  103397. /**
  103398. * Gets the back-face culling state
  103399. */
  103400. get backFaceCulling(): boolean;
  103401. /**
  103402. * Stores the value for side orientation
  103403. */
  103404. sideOrientation: number;
  103405. /**
  103406. * Callback triggered when the material is compiled
  103407. */
  103408. onCompiled: Nullable<(effect: Effect) => void>;
  103409. /**
  103410. * Callback triggered when an error occurs
  103411. */
  103412. onError: Nullable<(effect: Effect, errors: string) => void>;
  103413. /**
  103414. * Callback triggered to get the render target textures
  103415. */
  103416. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  103417. /**
  103418. * Gets a boolean indicating that current material needs to register RTT
  103419. */
  103420. get hasRenderTargetTextures(): boolean;
  103421. /**
  103422. * Specifies if the material should be serialized
  103423. */
  103424. doNotSerialize: boolean;
  103425. /**
  103426. * @hidden
  103427. */
  103428. _storeEffectOnSubMeshes: boolean;
  103429. /**
  103430. * Stores the animations for the material
  103431. */
  103432. animations: Nullable<Array<Animation>>;
  103433. /**
  103434. * An event triggered when the material is disposed
  103435. */
  103436. onDisposeObservable: Observable<Material>;
  103437. /**
  103438. * An observer which watches for dispose events
  103439. */
  103440. private _onDisposeObserver;
  103441. private _onUnBindObservable;
  103442. /**
  103443. * Called during a dispose event
  103444. */
  103445. set onDispose(callback: () => void);
  103446. private _onBindObservable;
  103447. /**
  103448. * An event triggered when the material is bound
  103449. */
  103450. get onBindObservable(): Observable<AbstractMesh>;
  103451. /**
  103452. * An observer which watches for bind events
  103453. */
  103454. private _onBindObserver;
  103455. /**
  103456. * Called during a bind event
  103457. */
  103458. set onBind(callback: (Mesh: AbstractMesh) => void);
  103459. /**
  103460. * An event triggered when the material is unbound
  103461. */
  103462. get onUnBindObservable(): Observable<Material>;
  103463. protected _onEffectCreatedObservable: Nullable<Observable<{
  103464. effect: Effect;
  103465. subMesh: Nullable<SubMesh>;
  103466. }>>;
  103467. /**
  103468. * An event triggered when the effect is (re)created
  103469. */
  103470. get onEffectCreatedObservable(): Observable<{
  103471. effect: Effect;
  103472. subMesh: Nullable<SubMesh>;
  103473. }>;
  103474. /**
  103475. * Stores the value of the alpha mode
  103476. */
  103477. private _alphaMode;
  103478. /**
  103479. * Sets the value of the alpha mode.
  103480. *
  103481. * | Value | Type | Description |
  103482. * | --- | --- | --- |
  103483. * | 0 | ALPHA_DISABLE | |
  103484. * | 1 | ALPHA_ADD | |
  103485. * | 2 | ALPHA_COMBINE | |
  103486. * | 3 | ALPHA_SUBTRACT | |
  103487. * | 4 | ALPHA_MULTIPLY | |
  103488. * | 5 | ALPHA_MAXIMIZED | |
  103489. * | 6 | ALPHA_ONEONE | |
  103490. * | 7 | ALPHA_PREMULTIPLIED | |
  103491. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  103492. * | 9 | ALPHA_INTERPOLATE | |
  103493. * | 10 | ALPHA_SCREENMODE | |
  103494. *
  103495. */
  103496. set alphaMode(value: number);
  103497. /**
  103498. * Gets the value of the alpha mode
  103499. */
  103500. get alphaMode(): number;
  103501. /**
  103502. * Stores the state of the need depth pre-pass value
  103503. */
  103504. private _needDepthPrePass;
  103505. /**
  103506. * Sets the need depth pre-pass value
  103507. */
  103508. set needDepthPrePass(value: boolean);
  103509. /**
  103510. * Gets the depth pre-pass value
  103511. */
  103512. get needDepthPrePass(): boolean;
  103513. /**
  103514. * Specifies if depth writing should be disabled
  103515. */
  103516. disableDepthWrite: boolean;
  103517. /**
  103518. * Specifies if color writing should be disabled
  103519. */
  103520. disableColorWrite: boolean;
  103521. /**
  103522. * Specifies if depth writing should be forced
  103523. */
  103524. forceDepthWrite: boolean;
  103525. /**
  103526. * Specifies the depth function that should be used. 0 means the default engine function
  103527. */
  103528. depthFunction: number;
  103529. /**
  103530. * Specifies if there should be a separate pass for culling
  103531. */
  103532. separateCullingPass: boolean;
  103533. /**
  103534. * Stores the state specifing if fog should be enabled
  103535. */
  103536. private _fogEnabled;
  103537. /**
  103538. * Sets the state for enabling fog
  103539. */
  103540. set fogEnabled(value: boolean);
  103541. /**
  103542. * Gets the value of the fog enabled state
  103543. */
  103544. get fogEnabled(): boolean;
  103545. /**
  103546. * Stores the size of points
  103547. */
  103548. pointSize: number;
  103549. /**
  103550. * Stores the z offset value
  103551. */
  103552. zOffset: number;
  103553. get wireframe(): boolean;
  103554. /**
  103555. * Sets the state of wireframe mode
  103556. */
  103557. set wireframe(value: boolean);
  103558. /**
  103559. * Gets the value specifying if point clouds are enabled
  103560. */
  103561. get pointsCloud(): boolean;
  103562. /**
  103563. * Sets the state of point cloud mode
  103564. */
  103565. set pointsCloud(value: boolean);
  103566. /**
  103567. * Gets the material fill mode
  103568. */
  103569. get fillMode(): number;
  103570. /**
  103571. * Sets the material fill mode
  103572. */
  103573. set fillMode(value: number);
  103574. /**
  103575. * @hidden
  103576. * Stores the effects for the material
  103577. */
  103578. _effect: Nullable<Effect>;
  103579. /**
  103580. * Specifies if uniform buffers should be used
  103581. */
  103582. private _useUBO;
  103583. /**
  103584. * Stores a reference to the scene
  103585. */
  103586. private _scene;
  103587. /**
  103588. * Stores the fill mode state
  103589. */
  103590. private _fillMode;
  103591. /**
  103592. * Specifies if the depth write state should be cached
  103593. */
  103594. private _cachedDepthWriteState;
  103595. /**
  103596. * Specifies if the color write state should be cached
  103597. */
  103598. private _cachedColorWriteState;
  103599. /**
  103600. * Specifies if the depth function state should be cached
  103601. */
  103602. private _cachedDepthFunctionState;
  103603. /**
  103604. * Stores the uniform buffer
  103605. */
  103606. protected _uniformBuffer: UniformBuffer;
  103607. /** @hidden */
  103608. _indexInSceneMaterialArray: number;
  103609. /** @hidden */
  103610. meshMap: Nullable<{
  103611. [id: string]: AbstractMesh | undefined;
  103612. }>;
  103613. /**
  103614. * Creates a material instance
  103615. * @param name defines the name of the material
  103616. * @param scene defines the scene to reference
  103617. * @param doNotAdd specifies if the material should be added to the scene
  103618. */
  103619. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  103620. /**
  103621. * Returns a string representation of the current material
  103622. * @param fullDetails defines a boolean indicating which levels of logging is desired
  103623. * @returns a string with material information
  103624. */
  103625. toString(fullDetails?: boolean): string;
  103626. /**
  103627. * Gets the class name of the material
  103628. * @returns a string with the class name of the material
  103629. */
  103630. getClassName(): string;
  103631. /**
  103632. * Specifies if updates for the material been locked
  103633. */
  103634. get isFrozen(): boolean;
  103635. /**
  103636. * Locks updates for the material
  103637. */
  103638. freeze(): void;
  103639. /**
  103640. * Unlocks updates for the material
  103641. */
  103642. unfreeze(): void;
  103643. /**
  103644. * Specifies if the material is ready to be used
  103645. * @param mesh defines the mesh to check
  103646. * @param useInstances specifies if instances should be used
  103647. * @returns a boolean indicating if the material is ready to be used
  103648. */
  103649. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103650. /**
  103651. * Specifies that the submesh is ready to be used
  103652. * @param mesh defines the mesh to check
  103653. * @param subMesh defines which submesh to check
  103654. * @param useInstances specifies that instances should be used
  103655. * @returns a boolean indicating that the submesh is ready or not
  103656. */
  103657. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103658. /**
  103659. * Returns the material effect
  103660. * @returns the effect associated with the material
  103661. */
  103662. getEffect(): Nullable<Effect>;
  103663. /**
  103664. * Returns the current scene
  103665. * @returns a Scene
  103666. */
  103667. getScene(): Scene;
  103668. /**
  103669. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103670. */
  103671. protected _forceAlphaTest: boolean;
  103672. /**
  103673. * The transparency mode of the material.
  103674. */
  103675. protected _transparencyMode: Nullable<number>;
  103676. /**
  103677. * Gets the current transparency mode.
  103678. */
  103679. get transparencyMode(): Nullable<number>;
  103680. /**
  103681. * Sets the transparency mode of the material.
  103682. *
  103683. * | Value | Type | Description |
  103684. * | ----- | ----------------------------------- | ----------- |
  103685. * | 0 | OPAQUE | |
  103686. * | 1 | ALPHATEST | |
  103687. * | 2 | ALPHABLEND | |
  103688. * | 3 | ALPHATESTANDBLEND | |
  103689. *
  103690. */
  103691. set transparencyMode(value: Nullable<number>);
  103692. /**
  103693. * Returns true if alpha blending should be disabled.
  103694. */
  103695. protected get _disableAlphaBlending(): boolean;
  103696. /**
  103697. * Specifies whether or not this material should be rendered in alpha blend mode.
  103698. * @returns a boolean specifying if alpha blending is needed
  103699. */
  103700. needAlphaBlending(): boolean;
  103701. /**
  103702. * Specifies if the mesh will require alpha blending
  103703. * @param mesh defines the mesh to check
  103704. * @returns a boolean specifying if alpha blending is needed for the mesh
  103705. */
  103706. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103707. /**
  103708. * Specifies whether or not this material should be rendered in alpha test mode.
  103709. * @returns a boolean specifying if an alpha test is needed.
  103710. */
  103711. needAlphaTesting(): boolean;
  103712. /**
  103713. * Specifies if material alpha testing should be turned on for the mesh
  103714. * @param mesh defines the mesh to check
  103715. */
  103716. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  103717. /**
  103718. * Gets the texture used for the alpha test
  103719. * @returns the texture to use for alpha testing
  103720. */
  103721. getAlphaTestTexture(): Nullable<BaseTexture>;
  103722. /**
  103723. * Marks the material to indicate that it needs to be re-calculated
  103724. */
  103725. markDirty(): void;
  103726. /** @hidden */
  103727. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  103728. /**
  103729. * Binds the material to the mesh
  103730. * @param world defines the world transformation matrix
  103731. * @param mesh defines the mesh to bind the material to
  103732. */
  103733. bind(world: Matrix, mesh?: Mesh): void;
  103734. /**
  103735. * Binds the submesh to the material
  103736. * @param world defines the world transformation matrix
  103737. * @param mesh defines the mesh containing the submesh
  103738. * @param subMesh defines the submesh to bind the material to
  103739. */
  103740. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103741. /**
  103742. * Binds the world matrix to the material
  103743. * @param world defines the world transformation matrix
  103744. */
  103745. bindOnlyWorldMatrix(world: Matrix): void;
  103746. /**
  103747. * Binds the scene's uniform buffer to the effect.
  103748. * @param effect defines the effect to bind to the scene uniform buffer
  103749. * @param sceneUbo defines the uniform buffer storing scene data
  103750. */
  103751. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  103752. /**
  103753. * Binds the view matrix to the effect
  103754. * @param effect defines the effect to bind the view matrix to
  103755. */
  103756. bindView(effect: Effect): void;
  103757. /**
  103758. * Binds the view projection matrix to the effect
  103759. * @param effect defines the effect to bind the view projection matrix to
  103760. */
  103761. bindViewProjection(effect: Effect): void;
  103762. /**
  103763. * Processes to execute after binding the material to a mesh
  103764. * @param mesh defines the rendered mesh
  103765. */
  103766. protected _afterBind(mesh?: Mesh): void;
  103767. /**
  103768. * Unbinds the material from the mesh
  103769. */
  103770. unbind(): void;
  103771. /**
  103772. * Gets the active textures from the material
  103773. * @returns an array of textures
  103774. */
  103775. getActiveTextures(): BaseTexture[];
  103776. /**
  103777. * Specifies if the material uses a texture
  103778. * @param texture defines the texture to check against the material
  103779. * @returns a boolean specifying if the material uses the texture
  103780. */
  103781. hasTexture(texture: BaseTexture): boolean;
  103782. /**
  103783. * Makes a duplicate of the material, and gives it a new name
  103784. * @param name defines the new name for the duplicated material
  103785. * @returns the cloned material
  103786. */
  103787. clone(name: string): Nullable<Material>;
  103788. /**
  103789. * Gets the meshes bound to the material
  103790. * @returns an array of meshes bound to the material
  103791. */
  103792. getBindedMeshes(): AbstractMesh[];
  103793. /**
  103794. * Force shader compilation
  103795. * @param mesh defines the mesh associated with this material
  103796. * @param onCompiled defines a function to execute once the material is compiled
  103797. * @param options defines the options to configure the compilation
  103798. * @param onError defines a function to execute if the material fails compiling
  103799. */
  103800. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  103801. /**
  103802. * Force shader compilation
  103803. * @param mesh defines the mesh that will use this material
  103804. * @param options defines additional options for compiling the shaders
  103805. * @returns a promise that resolves when the compilation completes
  103806. */
  103807. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  103808. private static readonly _AllDirtyCallBack;
  103809. private static readonly _ImageProcessingDirtyCallBack;
  103810. private static readonly _TextureDirtyCallBack;
  103811. private static readonly _FresnelDirtyCallBack;
  103812. private static readonly _MiscDirtyCallBack;
  103813. private static readonly _LightsDirtyCallBack;
  103814. private static readonly _AttributeDirtyCallBack;
  103815. private static _FresnelAndMiscDirtyCallBack;
  103816. private static _TextureAndMiscDirtyCallBack;
  103817. private static readonly _DirtyCallbackArray;
  103818. private static readonly _RunDirtyCallBacks;
  103819. /**
  103820. * Marks a define in the material to indicate that it needs to be re-computed
  103821. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  103822. */
  103823. markAsDirty(flag: number): void;
  103824. /**
  103825. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  103826. * @param func defines a function which checks material defines against the submeshes
  103827. */
  103828. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  103829. /**
  103830. * Indicates that the scene should check if the rendering now needs a prepass
  103831. */
  103832. protected _markScenePrePassDirty(): void;
  103833. /**
  103834. * Indicates that we need to re-calculated for all submeshes
  103835. */
  103836. protected _markAllSubMeshesAsAllDirty(): void;
  103837. /**
  103838. * Indicates that image processing needs to be re-calculated for all submeshes
  103839. */
  103840. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  103841. /**
  103842. * Indicates that textures need to be re-calculated for all submeshes
  103843. */
  103844. protected _markAllSubMeshesAsTexturesDirty(): void;
  103845. /**
  103846. * Indicates that fresnel needs to be re-calculated for all submeshes
  103847. */
  103848. protected _markAllSubMeshesAsFresnelDirty(): void;
  103849. /**
  103850. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  103851. */
  103852. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  103853. /**
  103854. * Indicates that lights need to be re-calculated for all submeshes
  103855. */
  103856. protected _markAllSubMeshesAsLightsDirty(): void;
  103857. /**
  103858. * Indicates that attributes need to be re-calculated for all submeshes
  103859. */
  103860. protected _markAllSubMeshesAsAttributesDirty(): void;
  103861. /**
  103862. * Indicates that misc needs to be re-calculated for all submeshes
  103863. */
  103864. protected _markAllSubMeshesAsMiscDirty(): void;
  103865. /**
  103866. * Indicates that textures and misc need to be re-calculated for all submeshes
  103867. */
  103868. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  103869. /**
  103870. * Sets the required values to the prepass renderer.
  103871. * @param prePassRenderer defines the prepass renderer to setup.
  103872. * @returns true if the pre pass is needed.
  103873. */
  103874. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103875. /**
  103876. * Disposes the material
  103877. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103878. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103879. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103880. */
  103881. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103882. /** @hidden */
  103883. private releaseVertexArrayObject;
  103884. /**
  103885. * Serializes this material
  103886. * @returns the serialized material object
  103887. */
  103888. serialize(): any;
  103889. /**
  103890. * Creates a material from parsed material data
  103891. * @param parsedMaterial defines parsed material data
  103892. * @param scene defines the hosting scene
  103893. * @param rootUrl defines the root URL to use to load textures
  103894. * @returns a new material
  103895. */
  103896. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  103897. }
  103898. }
  103899. declare module BABYLON {
  103900. /**
  103901. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103902. * separate meshes. This can be use to improve performances.
  103903. * @see https://doc.babylonjs.com/how_to/multi_materials
  103904. */
  103905. export class MultiMaterial extends Material {
  103906. private _subMaterials;
  103907. /**
  103908. * Gets or Sets the list of Materials used within the multi material.
  103909. * They need to be ordered according to the submeshes order in the associated mesh
  103910. */
  103911. get subMaterials(): Nullable<Material>[];
  103912. set subMaterials(value: Nullable<Material>[]);
  103913. /**
  103914. * Function used to align with Node.getChildren()
  103915. * @returns the list of Materials used within the multi material
  103916. */
  103917. getChildren(): Nullable<Material>[];
  103918. /**
  103919. * Instantiates a new Multi Material
  103920. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103921. * separate meshes. This can be use to improve performances.
  103922. * @see https://doc.babylonjs.com/how_to/multi_materials
  103923. * @param name Define the name in the scene
  103924. * @param scene Define the scene the material belongs to
  103925. */
  103926. constructor(name: string, scene: Scene);
  103927. private _hookArray;
  103928. /**
  103929. * Get one of the submaterial by its index in the submaterials array
  103930. * @param index The index to look the sub material at
  103931. * @returns The Material if the index has been defined
  103932. */
  103933. getSubMaterial(index: number): Nullable<Material>;
  103934. /**
  103935. * Get the list of active textures for the whole sub materials list.
  103936. * @returns All the textures that will be used during the rendering
  103937. */
  103938. getActiveTextures(): BaseTexture[];
  103939. /**
  103940. * Gets the current class name of the material e.g. "MultiMaterial"
  103941. * Mainly use in serialization.
  103942. * @returns the class name
  103943. */
  103944. getClassName(): string;
  103945. /**
  103946. * Checks if the material is ready to render the requested sub mesh
  103947. * @param mesh Define the mesh the submesh belongs to
  103948. * @param subMesh Define the sub mesh to look readyness for
  103949. * @param useInstances Define whether or not the material is used with instances
  103950. * @returns true if ready, otherwise false
  103951. */
  103952. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103953. /**
  103954. * Clones the current material and its related sub materials
  103955. * @param name Define the name of the newly cloned material
  103956. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  103957. * @returns the cloned material
  103958. */
  103959. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  103960. /**
  103961. * Serializes the materials into a JSON representation.
  103962. * @returns the JSON representation
  103963. */
  103964. serialize(): any;
  103965. /**
  103966. * Dispose the material and release its associated resources
  103967. * @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)
  103968. * @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)
  103969. * @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)
  103970. */
  103971. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  103972. /**
  103973. * Creates a MultiMaterial from parsed MultiMaterial data.
  103974. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  103975. * @param scene defines the hosting scene
  103976. * @returns a new MultiMaterial
  103977. */
  103978. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  103979. }
  103980. }
  103981. declare module BABYLON {
  103982. /**
  103983. * Defines a subdivision inside a mesh
  103984. */
  103985. export class SubMesh implements ICullable {
  103986. /** the material index to use */
  103987. materialIndex: number;
  103988. /** vertex index start */
  103989. verticesStart: number;
  103990. /** vertices count */
  103991. verticesCount: number;
  103992. /** index start */
  103993. indexStart: number;
  103994. /** indices count */
  103995. indexCount: number;
  103996. /** @hidden */
  103997. _materialDefines: Nullable<MaterialDefines>;
  103998. /** @hidden */
  103999. _materialEffect: Nullable<Effect>;
  104000. /** @hidden */
  104001. _effectOverride: Nullable<Effect>;
  104002. /**
  104003. * Gets material defines used by the effect associated to the sub mesh
  104004. */
  104005. get materialDefines(): Nullable<MaterialDefines>;
  104006. /**
  104007. * Sets material defines used by the effect associated to the sub mesh
  104008. */
  104009. set materialDefines(defines: Nullable<MaterialDefines>);
  104010. /**
  104011. * Gets associated effect
  104012. */
  104013. get effect(): Nullable<Effect>;
  104014. /**
  104015. * Sets associated effect (effect used to render this submesh)
  104016. * @param effect defines the effect to associate with
  104017. * @param defines defines the set of defines used to compile this effect
  104018. */
  104019. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  104020. /** @hidden */
  104021. _linesIndexCount: number;
  104022. private _mesh;
  104023. private _renderingMesh;
  104024. private _boundingInfo;
  104025. private _linesIndexBuffer;
  104026. /** @hidden */
  104027. _lastColliderWorldVertices: Nullable<Vector3[]>;
  104028. /** @hidden */
  104029. _trianglePlanes: Plane[];
  104030. /** @hidden */
  104031. _lastColliderTransformMatrix: Nullable<Matrix>;
  104032. /** @hidden */
  104033. _renderId: number;
  104034. /** @hidden */
  104035. _alphaIndex: number;
  104036. /** @hidden */
  104037. _distanceToCamera: number;
  104038. /** @hidden */
  104039. _id: number;
  104040. private _currentMaterial;
  104041. /**
  104042. * Add a new submesh to a mesh
  104043. * @param materialIndex defines the material index to use
  104044. * @param verticesStart defines vertex index start
  104045. * @param verticesCount defines vertices count
  104046. * @param indexStart defines index start
  104047. * @param indexCount defines indices count
  104048. * @param mesh defines the parent mesh
  104049. * @param renderingMesh defines an optional rendering mesh
  104050. * @param createBoundingBox defines if bounding box should be created for this submesh
  104051. * @returns the new submesh
  104052. */
  104053. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  104054. /**
  104055. * Creates a new submesh
  104056. * @param materialIndex defines the material index to use
  104057. * @param verticesStart defines vertex index start
  104058. * @param verticesCount defines vertices count
  104059. * @param indexStart defines index start
  104060. * @param indexCount defines indices count
  104061. * @param mesh defines the parent mesh
  104062. * @param renderingMesh defines an optional rendering mesh
  104063. * @param createBoundingBox defines if bounding box should be created for this submesh
  104064. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  104065. */
  104066. constructor(
  104067. /** the material index to use */
  104068. materialIndex: number,
  104069. /** vertex index start */
  104070. verticesStart: number,
  104071. /** vertices count */
  104072. verticesCount: number,
  104073. /** index start */
  104074. indexStart: number,
  104075. /** indices count */
  104076. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  104077. /**
  104078. * Returns true if this submesh covers the entire parent mesh
  104079. * @ignorenaming
  104080. */
  104081. get IsGlobal(): boolean;
  104082. /**
  104083. * Returns the submesh BoudingInfo object
  104084. * @returns current bounding info (or mesh's one if the submesh is global)
  104085. */
  104086. getBoundingInfo(): BoundingInfo;
  104087. /**
  104088. * Sets the submesh BoundingInfo
  104089. * @param boundingInfo defines the new bounding info to use
  104090. * @returns the SubMesh
  104091. */
  104092. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  104093. /**
  104094. * Returns the mesh of the current submesh
  104095. * @return the parent mesh
  104096. */
  104097. getMesh(): AbstractMesh;
  104098. /**
  104099. * Returns the rendering mesh of the submesh
  104100. * @returns the rendering mesh (could be different from parent mesh)
  104101. */
  104102. getRenderingMesh(): Mesh;
  104103. /**
  104104. * Returns the replacement mesh of the submesh
  104105. * @returns the replacement mesh (could be different from parent mesh)
  104106. */
  104107. getReplacementMesh(): Nullable<AbstractMesh>;
  104108. /**
  104109. * Returns the effective mesh of the submesh
  104110. * @returns the effective mesh (could be different from parent mesh)
  104111. */
  104112. getEffectiveMesh(): AbstractMesh;
  104113. /**
  104114. * Returns the submesh material
  104115. * @returns null or the current material
  104116. */
  104117. getMaterial(): Nullable<Material>;
  104118. private _IsMultiMaterial;
  104119. /**
  104120. * Sets a new updated BoundingInfo object to the submesh
  104121. * @param data defines an optional position array to use to determine the bounding info
  104122. * @returns the SubMesh
  104123. */
  104124. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  104125. /** @hidden */
  104126. _checkCollision(collider: Collider): boolean;
  104127. /**
  104128. * Updates the submesh BoundingInfo
  104129. * @param world defines the world matrix to use to update the bounding info
  104130. * @returns the submesh
  104131. */
  104132. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  104133. /**
  104134. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  104135. * @param frustumPlanes defines the frustum planes
  104136. * @returns true if the submesh is intersecting with the frustum
  104137. */
  104138. isInFrustum(frustumPlanes: Plane[]): boolean;
  104139. /**
  104140. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  104141. * @param frustumPlanes defines the frustum planes
  104142. * @returns true if the submesh is inside the frustum
  104143. */
  104144. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104145. /**
  104146. * Renders the submesh
  104147. * @param enableAlphaMode defines if alpha needs to be used
  104148. * @returns the submesh
  104149. */
  104150. render(enableAlphaMode: boolean): SubMesh;
  104151. /**
  104152. * @hidden
  104153. */
  104154. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  104155. /**
  104156. * Checks if the submesh intersects with a ray
  104157. * @param ray defines the ray to test
  104158. * @returns true is the passed ray intersects the submesh bounding box
  104159. */
  104160. canIntersects(ray: Ray): boolean;
  104161. /**
  104162. * Intersects current submesh with a ray
  104163. * @param ray defines the ray to test
  104164. * @param positions defines mesh's positions array
  104165. * @param indices defines mesh's indices array
  104166. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104167. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104168. * @returns intersection info or null if no intersection
  104169. */
  104170. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  104171. /** @hidden */
  104172. private _intersectLines;
  104173. /** @hidden */
  104174. private _intersectUnIndexedLines;
  104175. /** @hidden */
  104176. private _intersectTriangles;
  104177. /** @hidden */
  104178. private _intersectUnIndexedTriangles;
  104179. /** @hidden */
  104180. _rebuild(): void;
  104181. /**
  104182. * Creates a new submesh from the passed mesh
  104183. * @param newMesh defines the new hosting mesh
  104184. * @param newRenderingMesh defines an optional rendering mesh
  104185. * @returns the new submesh
  104186. */
  104187. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  104188. /**
  104189. * Release associated resources
  104190. */
  104191. dispose(): void;
  104192. /**
  104193. * Gets the class name
  104194. * @returns the string "SubMesh".
  104195. */
  104196. getClassName(): string;
  104197. /**
  104198. * Creates a new submesh from indices data
  104199. * @param materialIndex the index of the main mesh material
  104200. * @param startIndex the index where to start the copy in the mesh indices array
  104201. * @param indexCount the number of indices to copy then from the startIndex
  104202. * @param mesh the main mesh to create the submesh from
  104203. * @param renderingMesh the optional rendering mesh
  104204. * @returns a new submesh
  104205. */
  104206. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  104207. }
  104208. }
  104209. declare module BABYLON {
  104210. /**
  104211. * Class used to represent data loading progression
  104212. */
  104213. export class SceneLoaderFlags {
  104214. private static _ForceFullSceneLoadingForIncremental;
  104215. private static _ShowLoadingScreen;
  104216. private static _CleanBoneMatrixWeights;
  104217. private static _loggingLevel;
  104218. /**
  104219. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104220. */
  104221. static get ForceFullSceneLoadingForIncremental(): boolean;
  104222. static set ForceFullSceneLoadingForIncremental(value: boolean);
  104223. /**
  104224. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104225. */
  104226. static get ShowLoadingScreen(): boolean;
  104227. static set ShowLoadingScreen(value: boolean);
  104228. /**
  104229. * Defines the current logging level (while loading the scene)
  104230. * @ignorenaming
  104231. */
  104232. static get loggingLevel(): number;
  104233. static set loggingLevel(value: number);
  104234. /**
  104235. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104236. */
  104237. static get CleanBoneMatrixWeights(): boolean;
  104238. static set CleanBoneMatrixWeights(value: boolean);
  104239. }
  104240. }
  104241. declare module BABYLON {
  104242. /**
  104243. * Class used to store geometry data (vertex buffers + index buffer)
  104244. */
  104245. export class Geometry implements IGetSetVerticesData {
  104246. /**
  104247. * Gets or sets the ID of the geometry
  104248. */
  104249. id: string;
  104250. /**
  104251. * Gets or sets the unique ID of the geometry
  104252. */
  104253. uniqueId: number;
  104254. /**
  104255. * Gets the delay loading state of the geometry (none by default which means not delayed)
  104256. */
  104257. delayLoadState: number;
  104258. /**
  104259. * Gets the file containing the data to load when running in delay load state
  104260. */
  104261. delayLoadingFile: Nullable<string>;
  104262. /**
  104263. * Callback called when the geometry is updated
  104264. */
  104265. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  104266. private _scene;
  104267. private _engine;
  104268. private _meshes;
  104269. private _totalVertices;
  104270. /** @hidden */
  104271. _indices: IndicesArray;
  104272. /** @hidden */
  104273. _vertexBuffers: {
  104274. [key: string]: VertexBuffer;
  104275. };
  104276. private _isDisposed;
  104277. private _extend;
  104278. private _boundingBias;
  104279. /** @hidden */
  104280. _delayInfo: Array<string>;
  104281. private _indexBuffer;
  104282. private _indexBufferIsUpdatable;
  104283. /** @hidden */
  104284. _boundingInfo: Nullable<BoundingInfo>;
  104285. /** @hidden */
  104286. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  104287. /** @hidden */
  104288. _softwareSkinningFrameId: number;
  104289. private _vertexArrayObjects;
  104290. private _updatable;
  104291. /** @hidden */
  104292. _positions: Nullable<Vector3[]>;
  104293. /**
  104294. * 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
  104295. */
  104296. get boundingBias(): Vector2;
  104297. /**
  104298. * 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
  104299. */
  104300. set boundingBias(value: Vector2);
  104301. /**
  104302. * Static function used to attach a new empty geometry to a mesh
  104303. * @param mesh defines the mesh to attach the geometry to
  104304. * @returns the new Geometry
  104305. */
  104306. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  104307. /** Get the list of meshes using this geometry */
  104308. get meshes(): Mesh[];
  104309. /**
  104310. * 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
  104311. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  104312. */
  104313. useBoundingInfoFromGeometry: boolean;
  104314. /**
  104315. * Creates a new geometry
  104316. * @param id defines the unique ID
  104317. * @param scene defines the hosting scene
  104318. * @param vertexData defines the VertexData used to get geometry data
  104319. * @param updatable defines if geometry must be updatable (false by default)
  104320. * @param mesh defines the mesh that will be associated with the geometry
  104321. */
  104322. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  104323. /**
  104324. * Gets the current extend of the geometry
  104325. */
  104326. get extend(): {
  104327. minimum: Vector3;
  104328. maximum: Vector3;
  104329. };
  104330. /**
  104331. * Gets the hosting scene
  104332. * @returns the hosting Scene
  104333. */
  104334. getScene(): Scene;
  104335. /**
  104336. * Gets the hosting engine
  104337. * @returns the hosting Engine
  104338. */
  104339. getEngine(): Engine;
  104340. /**
  104341. * Defines if the geometry is ready to use
  104342. * @returns true if the geometry is ready to be used
  104343. */
  104344. isReady(): boolean;
  104345. /**
  104346. * Gets a value indicating that the geometry should not be serialized
  104347. */
  104348. get doNotSerialize(): boolean;
  104349. /** @hidden */
  104350. _rebuild(): void;
  104351. /**
  104352. * Affects all geometry data in one call
  104353. * @param vertexData defines the geometry data
  104354. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  104355. */
  104356. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  104357. /**
  104358. * Set specific vertex data
  104359. * @param kind defines the data kind (Position, normal, etc...)
  104360. * @param data defines the vertex data to use
  104361. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104362. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104363. */
  104364. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104365. /**
  104366. * Removes a specific vertex data
  104367. * @param kind defines the data kind (Position, normal, etc...)
  104368. */
  104369. removeVerticesData(kind: string): void;
  104370. /**
  104371. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104372. * @param buffer defines the vertex buffer to use
  104373. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104374. */
  104375. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104376. /**
  104377. * Update a specific vertex buffer
  104378. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104379. * It will do nothing if the buffer is not updatable
  104380. * @param kind defines the data kind (Position, normal, etc...)
  104381. * @param data defines the data to use
  104382. * @param offset defines the offset in the target buffer where to store the data
  104383. * @param useBytes set to true if the offset is in bytes
  104384. */
  104385. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104386. /**
  104387. * Update a specific vertex buffer
  104388. * This function will create a new buffer if the current one is not updatable
  104389. * @param kind defines the data kind (Position, normal, etc...)
  104390. * @param data defines the data to use
  104391. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104392. */
  104393. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104394. private _updateBoundingInfo;
  104395. /** @hidden */
  104396. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104397. /**
  104398. * Gets total number of vertices
  104399. * @returns the total number of vertices
  104400. */
  104401. getTotalVertices(): number;
  104402. /**
  104403. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104404. * @param kind defines the data kind (Position, normal, etc...)
  104405. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104406. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104407. * @returns a float array containing vertex data
  104408. */
  104409. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104410. /**
  104411. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104412. * @param kind defines the data kind (Position, normal, etc...)
  104413. * @returns true if the vertex buffer with the specified kind is updatable
  104414. */
  104415. isVertexBufferUpdatable(kind: string): boolean;
  104416. /**
  104417. * Gets a specific vertex buffer
  104418. * @param kind defines the data kind (Position, normal, etc...)
  104419. * @returns a VertexBuffer
  104420. */
  104421. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104422. /**
  104423. * Returns all vertex buffers
  104424. * @return an object holding all vertex buffers indexed by kind
  104425. */
  104426. getVertexBuffers(): Nullable<{
  104427. [key: string]: VertexBuffer;
  104428. }>;
  104429. /**
  104430. * Gets a boolean indicating if specific vertex buffer is present
  104431. * @param kind defines the data kind (Position, normal, etc...)
  104432. * @returns true if data is present
  104433. */
  104434. isVerticesDataPresent(kind: string): boolean;
  104435. /**
  104436. * Gets a list of all attached data kinds (Position, normal, etc...)
  104437. * @returns a list of string containing all kinds
  104438. */
  104439. getVerticesDataKinds(): string[];
  104440. /**
  104441. * Update index buffer
  104442. * @param indices defines the indices to store in the index buffer
  104443. * @param offset defines the offset in the target buffer where to store the data
  104444. * @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)
  104445. */
  104446. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  104447. /**
  104448. * Creates a new index buffer
  104449. * @param indices defines the indices to store in the index buffer
  104450. * @param totalVertices defines the total number of vertices (could be null)
  104451. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104452. */
  104453. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  104454. /**
  104455. * Return the total number of indices
  104456. * @returns the total number of indices
  104457. */
  104458. getTotalIndices(): number;
  104459. /**
  104460. * Gets the index buffer array
  104461. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104462. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104463. * @returns the index buffer array
  104464. */
  104465. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104466. /**
  104467. * Gets the index buffer
  104468. * @return the index buffer
  104469. */
  104470. getIndexBuffer(): Nullable<DataBuffer>;
  104471. /** @hidden */
  104472. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  104473. /**
  104474. * Release the associated resources for a specific mesh
  104475. * @param mesh defines the source mesh
  104476. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  104477. */
  104478. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  104479. /**
  104480. * Apply current geometry to a given mesh
  104481. * @param mesh defines the mesh to apply geometry to
  104482. */
  104483. applyToMesh(mesh: Mesh): void;
  104484. private _updateExtend;
  104485. private _applyToMesh;
  104486. private notifyUpdate;
  104487. /**
  104488. * Load the geometry if it was flagged as delay loaded
  104489. * @param scene defines the hosting scene
  104490. * @param onLoaded defines a callback called when the geometry is loaded
  104491. */
  104492. load(scene: Scene, onLoaded?: () => void): void;
  104493. private _queueLoad;
  104494. /**
  104495. * Invert the geometry to move from a right handed system to a left handed one.
  104496. */
  104497. toLeftHanded(): void;
  104498. /** @hidden */
  104499. _resetPointsArrayCache(): void;
  104500. /** @hidden */
  104501. _generatePointsArray(): boolean;
  104502. /**
  104503. * Gets a value indicating if the geometry is disposed
  104504. * @returns true if the geometry was disposed
  104505. */
  104506. isDisposed(): boolean;
  104507. private _disposeVertexArrayObjects;
  104508. /**
  104509. * Free all associated resources
  104510. */
  104511. dispose(): void;
  104512. /**
  104513. * Clone the current geometry into a new geometry
  104514. * @param id defines the unique ID of the new geometry
  104515. * @returns a new geometry object
  104516. */
  104517. copy(id: string): Geometry;
  104518. /**
  104519. * Serialize the current geometry info (and not the vertices data) into a JSON object
  104520. * @return a JSON representation of the current geometry data (without the vertices data)
  104521. */
  104522. serialize(): any;
  104523. private toNumberArray;
  104524. /**
  104525. * Serialize all vertices data into a JSON oject
  104526. * @returns a JSON representation of the current geometry data
  104527. */
  104528. serializeVerticeData(): any;
  104529. /**
  104530. * Extracts a clone of a mesh geometry
  104531. * @param mesh defines the source mesh
  104532. * @param id defines the unique ID of the new geometry object
  104533. * @returns the new geometry object
  104534. */
  104535. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  104536. /**
  104537. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  104538. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104539. * Be aware Math.random() could cause collisions, but:
  104540. * "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"
  104541. * @returns a string containing a new GUID
  104542. */
  104543. static RandomId(): string;
  104544. /** @hidden */
  104545. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  104546. private static _CleanMatricesWeights;
  104547. /**
  104548. * Create a new geometry from persisted data (Using .babylon file format)
  104549. * @param parsedVertexData defines the persisted data
  104550. * @param scene defines the hosting scene
  104551. * @param rootUrl defines the root url to use to load assets (like delayed data)
  104552. * @returns the new geometry object
  104553. */
  104554. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  104555. }
  104556. }
  104557. declare module BABYLON {
  104558. /**
  104559. * Define an interface for all classes that will get and set the data on vertices
  104560. */
  104561. export interface IGetSetVerticesData {
  104562. /**
  104563. * Gets a boolean indicating if specific vertex data is present
  104564. * @param kind defines the vertex data kind to use
  104565. * @returns true is data kind is present
  104566. */
  104567. isVerticesDataPresent(kind: string): boolean;
  104568. /**
  104569. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104570. * @param kind defines the data kind (Position, normal, etc...)
  104571. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104572. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104573. * @returns a float array containing vertex data
  104574. */
  104575. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104576. /**
  104577. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104578. * @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.
  104579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104580. * @returns the indices array or an empty array if the mesh has no geometry
  104581. */
  104582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104583. /**
  104584. * Set specific vertex data
  104585. * @param kind defines the data kind (Position, normal, etc...)
  104586. * @param data defines the vertex data to use
  104587. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104588. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104589. */
  104590. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  104591. /**
  104592. * Update a specific associated vertex buffer
  104593. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104594. * - VertexBuffer.PositionKind
  104595. * - VertexBuffer.UVKind
  104596. * - VertexBuffer.UV2Kind
  104597. * - VertexBuffer.UV3Kind
  104598. * - VertexBuffer.UV4Kind
  104599. * - VertexBuffer.UV5Kind
  104600. * - VertexBuffer.UV6Kind
  104601. * - VertexBuffer.ColorKind
  104602. * - VertexBuffer.MatricesIndicesKind
  104603. * - VertexBuffer.MatricesIndicesExtraKind
  104604. * - VertexBuffer.MatricesWeightsKind
  104605. * - VertexBuffer.MatricesWeightsExtraKind
  104606. * @param data defines the data source
  104607. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104608. * @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)
  104609. */
  104610. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  104611. /**
  104612. * Creates a new index buffer
  104613. * @param indices defines the indices to store in the index buffer
  104614. * @param totalVertices defines the total number of vertices (could be null)
  104615. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104616. */
  104617. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  104618. }
  104619. /**
  104620. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  104621. */
  104622. export class VertexData {
  104623. /**
  104624. * Mesh side orientation : usually the external or front surface
  104625. */
  104626. static readonly FRONTSIDE: number;
  104627. /**
  104628. * Mesh side orientation : usually the internal or back surface
  104629. */
  104630. static readonly BACKSIDE: number;
  104631. /**
  104632. * Mesh side orientation : both internal and external or front and back surfaces
  104633. */
  104634. static readonly DOUBLESIDE: number;
  104635. /**
  104636. * Mesh side orientation : by default, `FRONTSIDE`
  104637. */
  104638. static readonly DEFAULTSIDE: number;
  104639. /**
  104640. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  104641. */
  104642. positions: Nullable<FloatArray>;
  104643. /**
  104644. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  104645. */
  104646. normals: Nullable<FloatArray>;
  104647. /**
  104648. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  104649. */
  104650. tangents: Nullable<FloatArray>;
  104651. /**
  104652. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104653. */
  104654. uvs: Nullable<FloatArray>;
  104655. /**
  104656. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104657. */
  104658. uvs2: Nullable<FloatArray>;
  104659. /**
  104660. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104661. */
  104662. uvs3: Nullable<FloatArray>;
  104663. /**
  104664. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104665. */
  104666. uvs4: Nullable<FloatArray>;
  104667. /**
  104668. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104669. */
  104670. uvs5: Nullable<FloatArray>;
  104671. /**
  104672. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104673. */
  104674. uvs6: Nullable<FloatArray>;
  104675. /**
  104676. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  104677. */
  104678. colors: Nullable<FloatArray>;
  104679. /**
  104680. * 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).
  104681. */
  104682. matricesIndices: Nullable<FloatArray>;
  104683. /**
  104684. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  104685. */
  104686. matricesWeights: Nullable<FloatArray>;
  104687. /**
  104688. * An array extending the number of possible indices
  104689. */
  104690. matricesIndicesExtra: Nullable<FloatArray>;
  104691. /**
  104692. * An array extending the number of possible weights when the number of indices is extended
  104693. */
  104694. matricesWeightsExtra: Nullable<FloatArray>;
  104695. /**
  104696. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  104697. */
  104698. indices: Nullable<IndicesArray>;
  104699. /**
  104700. * Uses the passed data array to set the set the values for the specified kind of data
  104701. * @param data a linear array of floating numbers
  104702. * @param kind the type of data that is being set, eg positions, colors etc
  104703. */
  104704. set(data: FloatArray, kind: string): void;
  104705. /**
  104706. * Associates the vertexData to the passed Mesh.
  104707. * Sets it as updatable or not (default `false`)
  104708. * @param mesh the mesh the vertexData is applied to
  104709. * @param updatable when used and having the value true allows new data to update the vertexData
  104710. * @returns the VertexData
  104711. */
  104712. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  104713. /**
  104714. * Associates the vertexData to the passed Geometry.
  104715. * Sets it as updatable or not (default `false`)
  104716. * @param geometry the geometry the vertexData is applied to
  104717. * @param updatable when used and having the value true allows new data to update the vertexData
  104718. * @returns VertexData
  104719. */
  104720. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  104721. /**
  104722. * Updates the associated mesh
  104723. * @param mesh the mesh to be updated
  104724. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104725. * @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
  104726. * @returns VertexData
  104727. */
  104728. updateMesh(mesh: Mesh): VertexData;
  104729. /**
  104730. * Updates the associated geometry
  104731. * @param geometry the geometry to be updated
  104732. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104733. * @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
  104734. * @returns VertexData.
  104735. */
  104736. updateGeometry(geometry: Geometry): VertexData;
  104737. private _applyTo;
  104738. private _update;
  104739. /**
  104740. * Transforms each position and each normal of the vertexData according to the passed Matrix
  104741. * @param matrix the transforming matrix
  104742. * @returns the VertexData
  104743. */
  104744. transform(matrix: Matrix): VertexData;
  104745. /**
  104746. * Merges the passed VertexData into the current one
  104747. * @param other the VertexData to be merged into the current one
  104748. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  104749. * @returns the modified VertexData
  104750. */
  104751. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  104752. private _mergeElement;
  104753. private _validate;
  104754. /**
  104755. * Serializes the VertexData
  104756. * @returns a serialized object
  104757. */
  104758. serialize(): any;
  104759. /**
  104760. * Extracts the vertexData from a mesh
  104761. * @param mesh the mesh from which to extract the VertexData
  104762. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  104763. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104764. * @returns the object VertexData associated to the passed mesh
  104765. */
  104766. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104767. /**
  104768. * Extracts the vertexData from the geometry
  104769. * @param geometry the geometry from which to extract the VertexData
  104770. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  104771. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104772. * @returns the object VertexData associated to the passed mesh
  104773. */
  104774. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104775. private static _ExtractFrom;
  104776. /**
  104777. * Creates the VertexData for a Ribbon
  104778. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  104779. * * pathArray array of paths, each of which an array of successive Vector3
  104780. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  104781. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  104782. * * 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
  104783. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104784. * * 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)
  104785. * * 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)
  104786. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  104787. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  104788. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  104789. * @returns the VertexData of the ribbon
  104790. */
  104791. static CreateRibbon(options: {
  104792. pathArray: Vector3[][];
  104793. closeArray?: boolean;
  104794. closePath?: boolean;
  104795. offset?: number;
  104796. sideOrientation?: number;
  104797. frontUVs?: Vector4;
  104798. backUVs?: Vector4;
  104799. invertUV?: boolean;
  104800. uvs?: Vector2[];
  104801. colors?: Color4[];
  104802. }): VertexData;
  104803. /**
  104804. * Creates the VertexData for a box
  104805. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104806. * * size sets the width, height and depth of the box to the value of size, optional default 1
  104807. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  104808. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  104809. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  104810. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104811. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104813. * * 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)
  104814. * * 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)
  104815. * @returns the VertexData of the box
  104816. */
  104817. static CreateBox(options: {
  104818. size?: number;
  104819. width?: number;
  104820. height?: number;
  104821. depth?: number;
  104822. faceUV?: Vector4[];
  104823. faceColors?: Color4[];
  104824. sideOrientation?: number;
  104825. frontUVs?: Vector4;
  104826. backUVs?: Vector4;
  104827. }): VertexData;
  104828. /**
  104829. * Creates the VertexData for a tiled box
  104830. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104831. * * faceTiles sets the pattern, tile size and number of tiles for a face
  104832. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104833. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104835. * @returns the VertexData of the box
  104836. */
  104837. static CreateTiledBox(options: {
  104838. pattern?: number;
  104839. width?: number;
  104840. height?: number;
  104841. depth?: number;
  104842. tileSize?: number;
  104843. tileWidth?: number;
  104844. tileHeight?: number;
  104845. alignHorizontal?: number;
  104846. alignVertical?: number;
  104847. faceUV?: Vector4[];
  104848. faceColors?: Color4[];
  104849. sideOrientation?: number;
  104850. }): VertexData;
  104851. /**
  104852. * Creates the VertexData for a tiled plane
  104853. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104854. * * pattern a limited pattern arrangement depending on the number
  104855. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  104856. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  104857. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  104858. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104859. * * 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)
  104860. * * 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)
  104861. * @returns the VertexData of the tiled plane
  104862. */
  104863. static CreateTiledPlane(options: {
  104864. pattern?: number;
  104865. tileSize?: number;
  104866. tileWidth?: number;
  104867. tileHeight?: number;
  104868. size?: number;
  104869. width?: number;
  104870. height?: number;
  104871. alignHorizontal?: number;
  104872. alignVertical?: number;
  104873. sideOrientation?: number;
  104874. frontUVs?: Vector4;
  104875. backUVs?: Vector4;
  104876. }): VertexData;
  104877. /**
  104878. * Creates the VertexData for an ellipsoid, defaults to a sphere
  104879. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104880. * * segments sets the number of horizontal strips optional, default 32
  104881. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  104882. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  104883. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  104884. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  104885. * * 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
  104886. * * 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
  104887. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104888. * * 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)
  104889. * * 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)
  104890. * @returns the VertexData of the ellipsoid
  104891. */
  104892. static CreateSphere(options: {
  104893. segments?: number;
  104894. diameter?: number;
  104895. diameterX?: number;
  104896. diameterY?: number;
  104897. diameterZ?: number;
  104898. arc?: number;
  104899. slice?: number;
  104900. sideOrientation?: number;
  104901. frontUVs?: Vector4;
  104902. backUVs?: Vector4;
  104903. }): VertexData;
  104904. /**
  104905. * Creates the VertexData for a cylinder, cone or prism
  104906. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104907. * * height sets the height (y direction) of the cylinder, optional, default 2
  104908. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  104909. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  104910. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  104911. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104912. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  104913. * * 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
  104914. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104915. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104916. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  104917. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  104918. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104919. * * 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)
  104920. * * 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)
  104921. * @returns the VertexData of the cylinder, cone or prism
  104922. */
  104923. static CreateCylinder(options: {
  104924. height?: number;
  104925. diameterTop?: number;
  104926. diameterBottom?: number;
  104927. diameter?: number;
  104928. tessellation?: number;
  104929. subdivisions?: number;
  104930. arc?: number;
  104931. faceColors?: Color4[];
  104932. faceUV?: Vector4[];
  104933. hasRings?: boolean;
  104934. enclose?: boolean;
  104935. sideOrientation?: number;
  104936. frontUVs?: Vector4;
  104937. backUVs?: Vector4;
  104938. }): VertexData;
  104939. /**
  104940. * Creates the VertexData for a torus
  104941. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104942. * * diameter the diameter of the torus, optional default 1
  104943. * * thickness the diameter of the tube forming the torus, optional default 0.5
  104944. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104946. * * 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)
  104947. * * 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)
  104948. * @returns the VertexData of the torus
  104949. */
  104950. static CreateTorus(options: {
  104951. diameter?: number;
  104952. thickness?: number;
  104953. tessellation?: number;
  104954. sideOrientation?: number;
  104955. frontUVs?: Vector4;
  104956. backUVs?: Vector4;
  104957. }): VertexData;
  104958. /**
  104959. * Creates the VertexData of the LineSystem
  104960. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  104961. * - lines an array of lines, each line being an array of successive Vector3
  104962. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  104963. * @returns the VertexData of the LineSystem
  104964. */
  104965. static CreateLineSystem(options: {
  104966. lines: Vector3[][];
  104967. colors?: Nullable<Color4[][]>;
  104968. }): VertexData;
  104969. /**
  104970. * Create the VertexData for a DashedLines
  104971. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  104972. * - points an array successive Vector3
  104973. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  104974. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  104975. * - dashNb the intended total number of dashes, optional, default 200
  104976. * @returns the VertexData for the DashedLines
  104977. */
  104978. static CreateDashedLines(options: {
  104979. points: Vector3[];
  104980. dashSize?: number;
  104981. gapSize?: number;
  104982. dashNb?: number;
  104983. }): VertexData;
  104984. /**
  104985. * Creates the VertexData for a Ground
  104986. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  104987. * - width the width (x direction) of the ground, optional, default 1
  104988. * - height the height (z direction) of the ground, optional, default 1
  104989. * - subdivisions the number of subdivisions per side, optional, default 1
  104990. * @returns the VertexData of the Ground
  104991. */
  104992. static CreateGround(options: {
  104993. width?: number;
  104994. height?: number;
  104995. subdivisions?: number;
  104996. subdivisionsX?: number;
  104997. subdivisionsY?: number;
  104998. }): VertexData;
  104999. /**
  105000. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  105001. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105002. * * xmin the ground minimum X coordinate, optional, default -1
  105003. * * zmin the ground minimum Z coordinate, optional, default -1
  105004. * * xmax the ground maximum X coordinate, optional, default 1
  105005. * * zmax the ground maximum Z coordinate, optional, default 1
  105006. * * 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}
  105007. * * 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}
  105008. * @returns the VertexData of the TiledGround
  105009. */
  105010. static CreateTiledGround(options: {
  105011. xmin: number;
  105012. zmin: number;
  105013. xmax: number;
  105014. zmax: number;
  105015. subdivisions?: {
  105016. w: number;
  105017. h: number;
  105018. };
  105019. precision?: {
  105020. w: number;
  105021. h: number;
  105022. };
  105023. }): VertexData;
  105024. /**
  105025. * Creates the VertexData of the Ground designed from a heightmap
  105026. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  105027. * * width the width (x direction) of the ground
  105028. * * height the height (z direction) of the ground
  105029. * * subdivisions the number of subdivisions per side
  105030. * * minHeight the minimum altitude on the ground, optional, default 0
  105031. * * maxHeight the maximum altitude on the ground, optional default 1
  105032. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  105033. * * buffer the array holding the image color data
  105034. * * bufferWidth the width of image
  105035. * * bufferHeight the height of image
  105036. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  105037. * @returns the VertexData of the Ground designed from a heightmap
  105038. */
  105039. static CreateGroundFromHeightMap(options: {
  105040. width: number;
  105041. height: number;
  105042. subdivisions: number;
  105043. minHeight: number;
  105044. maxHeight: number;
  105045. colorFilter: Color3;
  105046. buffer: Uint8Array;
  105047. bufferWidth: number;
  105048. bufferHeight: number;
  105049. alphaFilter: number;
  105050. }): VertexData;
  105051. /**
  105052. * Creates the VertexData for a Plane
  105053. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  105054. * * size sets the width and height of the plane to the value of size, optional default 1
  105055. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  105056. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  105057. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105058. * * 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)
  105059. * * 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)
  105060. * @returns the VertexData of the box
  105061. */
  105062. static CreatePlane(options: {
  105063. size?: number;
  105064. width?: number;
  105065. height?: number;
  105066. sideOrientation?: number;
  105067. frontUVs?: Vector4;
  105068. backUVs?: Vector4;
  105069. }): VertexData;
  105070. /**
  105071. * Creates the VertexData of the Disc or regular Polygon
  105072. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  105073. * * radius the radius of the disc, optional default 0.5
  105074. * * tessellation the number of polygon sides, optional, default 64
  105075. * * 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
  105076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105077. * * 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)
  105078. * * 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)
  105079. * @returns the VertexData of the box
  105080. */
  105081. static CreateDisc(options: {
  105082. radius?: number;
  105083. tessellation?: number;
  105084. arc?: number;
  105085. sideOrientation?: number;
  105086. frontUVs?: Vector4;
  105087. backUVs?: Vector4;
  105088. }): VertexData;
  105089. /**
  105090. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  105091. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  105092. * @param polygon a mesh built from polygonTriangulation.build()
  105093. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105094. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105095. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105096. * @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)
  105097. * @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)
  105098. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  105099. * @returns the VertexData of the Polygon
  105100. */
  105101. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  105102. /**
  105103. * Creates the VertexData of the IcoSphere
  105104. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  105105. * * radius the radius of the IcoSphere, optional default 1
  105106. * * radiusX allows stretching in the x direction, optional, default radius
  105107. * * radiusY allows stretching in the y direction, optional, default radius
  105108. * * radiusZ allows stretching in the z direction, optional, default radius
  105109. * * flat when true creates a flat shaded mesh, optional, default true
  105110. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105112. * * 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)
  105113. * * 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)
  105114. * @returns the VertexData of the IcoSphere
  105115. */
  105116. static CreateIcoSphere(options: {
  105117. radius?: number;
  105118. radiusX?: number;
  105119. radiusY?: number;
  105120. radiusZ?: number;
  105121. flat?: boolean;
  105122. subdivisions?: number;
  105123. sideOrientation?: number;
  105124. frontUVs?: Vector4;
  105125. backUVs?: Vector4;
  105126. }): VertexData;
  105127. /**
  105128. * Creates the VertexData for a Polyhedron
  105129. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  105130. * * type provided types are:
  105131. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  105132. * * 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)
  105133. * * size the size of the IcoSphere, optional default 1
  105134. * * sizeX allows stretching in the x direction, optional, default size
  105135. * * sizeY allows stretching in the y direction, optional, default size
  105136. * * sizeZ allows stretching in the z direction, optional, default size
  105137. * * 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
  105138. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105139. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105140. * * flat when true creates a flat shaded mesh, optional, default true
  105141. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105142. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105143. * * 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)
  105144. * * 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)
  105145. * @returns the VertexData of the Polyhedron
  105146. */
  105147. static CreatePolyhedron(options: {
  105148. type?: number;
  105149. size?: number;
  105150. sizeX?: number;
  105151. sizeY?: number;
  105152. sizeZ?: number;
  105153. custom?: any;
  105154. faceUV?: Vector4[];
  105155. faceColors?: Color4[];
  105156. flat?: boolean;
  105157. sideOrientation?: number;
  105158. frontUVs?: Vector4;
  105159. backUVs?: Vector4;
  105160. }): VertexData;
  105161. /**
  105162. * Creates the VertexData for a TorusKnot
  105163. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  105164. * * radius the radius of the torus knot, optional, default 2
  105165. * * tube the thickness of the tube, optional, default 0.5
  105166. * * radialSegments the number of sides on each tube segments, optional, default 32
  105167. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  105168. * * p the number of windings around the z axis, optional, default 2
  105169. * * q the number of windings around the x axis, optional, default 3
  105170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105171. * * 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)
  105172. * * 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)
  105173. * @returns the VertexData of the Torus Knot
  105174. */
  105175. static CreateTorusKnot(options: {
  105176. radius?: number;
  105177. tube?: number;
  105178. radialSegments?: number;
  105179. tubularSegments?: number;
  105180. p?: number;
  105181. q?: number;
  105182. sideOrientation?: number;
  105183. frontUVs?: Vector4;
  105184. backUVs?: Vector4;
  105185. }): VertexData;
  105186. /**
  105187. * Compute normals for given positions and indices
  105188. * @param positions an array of vertex positions, [...., x, y, z, ......]
  105189. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  105190. * @param normals an array of vertex normals, [...., x, y, z, ......]
  105191. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  105192. * * facetNormals : optional array of facet normals (vector3)
  105193. * * facetPositions : optional array of facet positions (vector3)
  105194. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  105195. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  105196. * * bInfo : optional bounding info, required for facetPartitioning computation
  105197. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  105198. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  105199. * * useRightHandedSystem: optional boolean to for right handed system computation
  105200. * * depthSort : optional boolean to enable the facet depth sort computation
  105201. * * distanceTo : optional Vector3 to compute the facet depth from this location
  105202. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  105203. */
  105204. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  105205. facetNormals?: any;
  105206. facetPositions?: any;
  105207. facetPartitioning?: any;
  105208. ratio?: number;
  105209. bInfo?: any;
  105210. bbSize?: Vector3;
  105211. subDiv?: any;
  105212. useRightHandedSystem?: boolean;
  105213. depthSort?: boolean;
  105214. distanceTo?: Vector3;
  105215. depthSortedFacets?: any;
  105216. }): void;
  105217. /** @hidden */
  105218. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  105219. /**
  105220. * Applies VertexData created from the imported parameters to the geometry
  105221. * @param parsedVertexData the parsed data from an imported file
  105222. * @param geometry the geometry to apply the VertexData to
  105223. */
  105224. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  105225. }
  105226. }
  105227. declare module BABYLON {
  105228. /**
  105229. * Defines a target to use with MorphTargetManager
  105230. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105231. */
  105232. export class MorphTarget implements IAnimatable {
  105233. /** defines the name of the target */
  105234. name: string;
  105235. /**
  105236. * Gets or sets the list of animations
  105237. */
  105238. animations: Animation[];
  105239. private _scene;
  105240. private _positions;
  105241. private _normals;
  105242. private _tangents;
  105243. private _uvs;
  105244. private _influence;
  105245. private _uniqueId;
  105246. /**
  105247. * Observable raised when the influence changes
  105248. */
  105249. onInfluenceChanged: Observable<boolean>;
  105250. /** @hidden */
  105251. _onDataLayoutChanged: Observable<void>;
  105252. /**
  105253. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105254. */
  105255. get influence(): number;
  105256. set influence(influence: number);
  105257. /**
  105258. * Gets or sets the id of the morph Target
  105259. */
  105260. id: string;
  105261. private _animationPropertiesOverride;
  105262. /**
  105263. * Gets or sets the animation properties override
  105264. */
  105265. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105266. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105267. /**
  105268. * Creates a new MorphTarget
  105269. * @param name defines the name of the target
  105270. * @param influence defines the influence to use
  105271. * @param scene defines the scene the morphtarget belongs to
  105272. */
  105273. constructor(
  105274. /** defines the name of the target */
  105275. name: string, influence?: number, scene?: Nullable<Scene>);
  105276. /**
  105277. * Gets the unique ID of this manager
  105278. */
  105279. get uniqueId(): number;
  105280. /**
  105281. * Gets a boolean defining if the target contains position data
  105282. */
  105283. get hasPositions(): boolean;
  105284. /**
  105285. * Gets a boolean defining if the target contains normal data
  105286. */
  105287. get hasNormals(): boolean;
  105288. /**
  105289. * Gets a boolean defining if the target contains tangent data
  105290. */
  105291. get hasTangents(): boolean;
  105292. /**
  105293. * Gets a boolean defining if the target contains texture coordinates data
  105294. */
  105295. get hasUVs(): boolean;
  105296. /**
  105297. * Affects position data to this target
  105298. * @param data defines the position data to use
  105299. */
  105300. setPositions(data: Nullable<FloatArray>): void;
  105301. /**
  105302. * Gets the position data stored in this target
  105303. * @returns a FloatArray containing the position data (or null if not present)
  105304. */
  105305. getPositions(): Nullable<FloatArray>;
  105306. /**
  105307. * Affects normal data to this target
  105308. * @param data defines the normal data to use
  105309. */
  105310. setNormals(data: Nullable<FloatArray>): void;
  105311. /**
  105312. * Gets the normal data stored in this target
  105313. * @returns a FloatArray containing the normal data (or null if not present)
  105314. */
  105315. getNormals(): Nullable<FloatArray>;
  105316. /**
  105317. * Affects tangent data to this target
  105318. * @param data defines the tangent data to use
  105319. */
  105320. setTangents(data: Nullable<FloatArray>): void;
  105321. /**
  105322. * Gets the tangent data stored in this target
  105323. * @returns a FloatArray containing the tangent data (or null if not present)
  105324. */
  105325. getTangents(): Nullable<FloatArray>;
  105326. /**
  105327. * Affects texture coordinates data to this target
  105328. * @param data defines the texture coordinates data to use
  105329. */
  105330. setUVs(data: Nullable<FloatArray>): void;
  105331. /**
  105332. * Gets the texture coordinates data stored in this target
  105333. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  105334. */
  105335. getUVs(): Nullable<FloatArray>;
  105336. /**
  105337. * Clone the current target
  105338. * @returns a new MorphTarget
  105339. */
  105340. clone(): MorphTarget;
  105341. /**
  105342. * Serializes the current target into a Serialization object
  105343. * @returns the serialized object
  105344. */
  105345. serialize(): any;
  105346. /**
  105347. * Returns the string "MorphTarget"
  105348. * @returns "MorphTarget"
  105349. */
  105350. getClassName(): string;
  105351. /**
  105352. * Creates a new target from serialized data
  105353. * @param serializationObject defines the serialized data to use
  105354. * @returns a new MorphTarget
  105355. */
  105356. static Parse(serializationObject: any): MorphTarget;
  105357. /**
  105358. * Creates a MorphTarget from mesh data
  105359. * @param mesh defines the source mesh
  105360. * @param name defines the name to use for the new target
  105361. * @param influence defines the influence to attach to the target
  105362. * @returns a new MorphTarget
  105363. */
  105364. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105365. }
  105366. }
  105367. declare module BABYLON {
  105368. /**
  105369. * This class is used to deform meshes using morphing between different targets
  105370. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105371. */
  105372. export class MorphTargetManager {
  105373. private _targets;
  105374. private _targetInfluenceChangedObservers;
  105375. private _targetDataLayoutChangedObservers;
  105376. private _activeTargets;
  105377. private _scene;
  105378. private _influences;
  105379. private _supportsNormals;
  105380. private _supportsTangents;
  105381. private _supportsUVs;
  105382. private _vertexCount;
  105383. private _uniqueId;
  105384. private _tempInfluences;
  105385. /**
  105386. * Gets or sets a boolean indicating if normals must be morphed
  105387. */
  105388. enableNormalMorphing: boolean;
  105389. /**
  105390. * Gets or sets a boolean indicating if tangents must be morphed
  105391. */
  105392. enableTangentMorphing: boolean;
  105393. /**
  105394. * Gets or sets a boolean indicating if UV must be morphed
  105395. */
  105396. enableUVMorphing: boolean;
  105397. /**
  105398. * Creates a new MorphTargetManager
  105399. * @param scene defines the current scene
  105400. */
  105401. constructor(scene?: Nullable<Scene>);
  105402. /**
  105403. * Gets the unique ID of this manager
  105404. */
  105405. get uniqueId(): number;
  105406. /**
  105407. * Gets the number of vertices handled by this manager
  105408. */
  105409. get vertexCount(): number;
  105410. /**
  105411. * Gets a boolean indicating if this manager supports morphing of normals
  105412. */
  105413. get supportsNormals(): boolean;
  105414. /**
  105415. * Gets a boolean indicating if this manager supports morphing of tangents
  105416. */
  105417. get supportsTangents(): boolean;
  105418. /**
  105419. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  105420. */
  105421. get supportsUVs(): boolean;
  105422. /**
  105423. * Gets the number of targets stored in this manager
  105424. */
  105425. get numTargets(): number;
  105426. /**
  105427. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105428. */
  105429. get numInfluencers(): number;
  105430. /**
  105431. * Gets the list of influences (one per target)
  105432. */
  105433. get influences(): Float32Array;
  105434. /**
  105435. * Gets the active target at specified index. An active target is a target with an influence > 0
  105436. * @param index defines the index to check
  105437. * @returns the requested target
  105438. */
  105439. getActiveTarget(index: number): MorphTarget;
  105440. /**
  105441. * Gets the target at specified index
  105442. * @param index defines the index to check
  105443. * @returns the requested target
  105444. */
  105445. getTarget(index: number): MorphTarget;
  105446. /**
  105447. * Add a new target to this manager
  105448. * @param target defines the target to add
  105449. */
  105450. addTarget(target: MorphTarget): void;
  105451. /**
  105452. * Removes a target from the manager
  105453. * @param target defines the target to remove
  105454. */
  105455. removeTarget(target: MorphTarget): void;
  105456. /**
  105457. * Clone the current manager
  105458. * @returns a new MorphTargetManager
  105459. */
  105460. clone(): MorphTargetManager;
  105461. /**
  105462. * Serializes the current manager into a Serialization object
  105463. * @returns the serialized object
  105464. */
  105465. serialize(): any;
  105466. private _syncActiveTargets;
  105467. /**
  105468. * Syncrhonize the targets with all the meshes using this morph target manager
  105469. */
  105470. synchronize(): void;
  105471. /**
  105472. * Creates a new MorphTargetManager from serialized data
  105473. * @param serializationObject defines the serialized data
  105474. * @param scene defines the hosting scene
  105475. * @returns the new MorphTargetManager
  105476. */
  105477. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  105478. }
  105479. }
  105480. declare module BABYLON {
  105481. /**
  105482. * Class used to represent a specific level of detail of a mesh
  105483. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105484. */
  105485. export class MeshLODLevel {
  105486. /** Defines the distance where this level should start being displayed */
  105487. distance: number;
  105488. /** Defines the mesh to use to render this level */
  105489. mesh: Nullable<Mesh>;
  105490. /**
  105491. * Creates a new LOD level
  105492. * @param distance defines the distance where this level should star being displayed
  105493. * @param mesh defines the mesh to use to render this level
  105494. */
  105495. constructor(
  105496. /** Defines the distance where this level should start being displayed */
  105497. distance: number,
  105498. /** Defines the mesh to use to render this level */
  105499. mesh: Nullable<Mesh>);
  105500. }
  105501. }
  105502. declare module BABYLON {
  105503. /**
  105504. * Helper class used to generate a canvas to manipulate images
  105505. */
  105506. export class CanvasGenerator {
  105507. /**
  105508. * Create a new canvas (or offscreen canvas depending on the context)
  105509. * @param width defines the expected width
  105510. * @param height defines the expected height
  105511. * @return a new canvas or offscreen canvas
  105512. */
  105513. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  105514. }
  105515. }
  105516. declare module BABYLON {
  105517. /**
  105518. * Mesh representing the gorund
  105519. */
  105520. export class GroundMesh extends Mesh {
  105521. /** If octree should be generated */
  105522. generateOctree: boolean;
  105523. private _heightQuads;
  105524. /** @hidden */
  105525. _subdivisionsX: number;
  105526. /** @hidden */
  105527. _subdivisionsY: number;
  105528. /** @hidden */
  105529. _width: number;
  105530. /** @hidden */
  105531. _height: number;
  105532. /** @hidden */
  105533. _minX: number;
  105534. /** @hidden */
  105535. _maxX: number;
  105536. /** @hidden */
  105537. _minZ: number;
  105538. /** @hidden */
  105539. _maxZ: number;
  105540. constructor(name: string, scene: Scene);
  105541. /**
  105542. * "GroundMesh"
  105543. * @returns "GroundMesh"
  105544. */
  105545. getClassName(): string;
  105546. /**
  105547. * The minimum of x and y subdivisions
  105548. */
  105549. get subdivisions(): number;
  105550. /**
  105551. * X subdivisions
  105552. */
  105553. get subdivisionsX(): number;
  105554. /**
  105555. * Y subdivisions
  105556. */
  105557. get subdivisionsY(): number;
  105558. /**
  105559. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  105560. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105561. * @param chunksCount the number of subdivisions for x and y
  105562. * @param octreeBlocksSize (Default: 32)
  105563. */
  105564. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  105565. /**
  105566. * Returns a height (y) value in the Worl system :
  105567. * the ground altitude at the coordinates (x, z) expressed in the World system.
  105568. * @param x x coordinate
  105569. * @param z z coordinate
  105570. * @returns the ground y position if (x, z) are outside the ground surface.
  105571. */
  105572. getHeightAtCoordinates(x: number, z: number): number;
  105573. /**
  105574. * Returns a normalized vector (Vector3) orthogonal to the ground
  105575. * at the ground coordinates (x, z) expressed in the World system.
  105576. * @param x x coordinate
  105577. * @param z z coordinate
  105578. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  105579. */
  105580. getNormalAtCoordinates(x: number, z: number): Vector3;
  105581. /**
  105582. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  105583. * at the ground coordinates (x, z) expressed in the World system.
  105584. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  105585. * @param x x coordinate
  105586. * @param z z coordinate
  105587. * @param ref vector to store the result
  105588. * @returns the GroundMesh.
  105589. */
  105590. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  105591. /**
  105592. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  105593. * if the ground has been updated.
  105594. * This can be used in the render loop.
  105595. * @returns the GroundMesh.
  105596. */
  105597. updateCoordinateHeights(): GroundMesh;
  105598. private _getFacetAt;
  105599. private _initHeightQuads;
  105600. private _computeHeightQuads;
  105601. /**
  105602. * Serializes this ground mesh
  105603. * @param serializationObject object to write serialization to
  105604. */
  105605. serialize(serializationObject: any): void;
  105606. /**
  105607. * Parses a serialized ground mesh
  105608. * @param parsedMesh the serialized mesh
  105609. * @param scene the scene to create the ground mesh in
  105610. * @returns the created ground mesh
  105611. */
  105612. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  105613. }
  105614. }
  105615. declare module BABYLON {
  105616. /**
  105617. * Interface for Physics-Joint data
  105618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105619. */
  105620. export interface PhysicsJointData {
  105621. /**
  105622. * The main pivot of the joint
  105623. */
  105624. mainPivot?: Vector3;
  105625. /**
  105626. * The connected pivot of the joint
  105627. */
  105628. connectedPivot?: Vector3;
  105629. /**
  105630. * The main axis of the joint
  105631. */
  105632. mainAxis?: Vector3;
  105633. /**
  105634. * The connected axis of the joint
  105635. */
  105636. connectedAxis?: Vector3;
  105637. /**
  105638. * The collision of the joint
  105639. */
  105640. collision?: boolean;
  105641. /**
  105642. * Native Oimo/Cannon/Energy data
  105643. */
  105644. nativeParams?: any;
  105645. }
  105646. /**
  105647. * This is a holder class for the physics joint created by the physics plugin
  105648. * It holds a set of functions to control the underlying joint
  105649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105650. */
  105651. export class PhysicsJoint {
  105652. /**
  105653. * The type of the physics joint
  105654. */
  105655. type: number;
  105656. /**
  105657. * The data for the physics joint
  105658. */
  105659. jointData: PhysicsJointData;
  105660. private _physicsJoint;
  105661. protected _physicsPlugin: IPhysicsEnginePlugin;
  105662. /**
  105663. * Initializes the physics joint
  105664. * @param type The type of the physics joint
  105665. * @param jointData The data for the physics joint
  105666. */
  105667. constructor(
  105668. /**
  105669. * The type of the physics joint
  105670. */
  105671. type: number,
  105672. /**
  105673. * The data for the physics joint
  105674. */
  105675. jointData: PhysicsJointData);
  105676. /**
  105677. * Gets the physics joint
  105678. */
  105679. get physicsJoint(): any;
  105680. /**
  105681. * Sets the physics joint
  105682. */
  105683. set physicsJoint(newJoint: any);
  105684. /**
  105685. * Sets the physics plugin
  105686. */
  105687. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  105688. /**
  105689. * Execute a function that is physics-plugin specific.
  105690. * @param {Function} func the function that will be executed.
  105691. * It accepts two parameters: the physics world and the physics joint
  105692. */
  105693. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  105694. /**
  105695. * Distance-Joint type
  105696. */
  105697. static DistanceJoint: number;
  105698. /**
  105699. * Hinge-Joint type
  105700. */
  105701. static HingeJoint: number;
  105702. /**
  105703. * Ball-and-Socket joint type
  105704. */
  105705. static BallAndSocketJoint: number;
  105706. /**
  105707. * Wheel-Joint type
  105708. */
  105709. static WheelJoint: number;
  105710. /**
  105711. * Slider-Joint type
  105712. */
  105713. static SliderJoint: number;
  105714. /**
  105715. * Prismatic-Joint type
  105716. */
  105717. static PrismaticJoint: number;
  105718. /**
  105719. * Universal-Joint type
  105720. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  105721. */
  105722. static UniversalJoint: number;
  105723. /**
  105724. * Hinge-Joint 2 type
  105725. */
  105726. static Hinge2Joint: number;
  105727. /**
  105728. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  105729. */
  105730. static PointToPointJoint: number;
  105731. /**
  105732. * Spring-Joint type
  105733. */
  105734. static SpringJoint: number;
  105735. /**
  105736. * Lock-Joint type
  105737. */
  105738. static LockJoint: number;
  105739. }
  105740. /**
  105741. * A class representing a physics distance joint
  105742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105743. */
  105744. export class DistanceJoint extends PhysicsJoint {
  105745. /**
  105746. *
  105747. * @param jointData The data for the Distance-Joint
  105748. */
  105749. constructor(jointData: DistanceJointData);
  105750. /**
  105751. * Update the predefined distance.
  105752. * @param maxDistance The maximum preferred distance
  105753. * @param minDistance The minimum preferred distance
  105754. */
  105755. updateDistance(maxDistance: number, minDistance?: number): void;
  105756. }
  105757. /**
  105758. * Represents a Motor-Enabled Joint
  105759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105760. */
  105761. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  105762. /**
  105763. * Initializes the Motor-Enabled Joint
  105764. * @param type The type of the joint
  105765. * @param jointData The physica joint data for the joint
  105766. */
  105767. constructor(type: number, jointData: PhysicsJointData);
  105768. /**
  105769. * Set the motor values.
  105770. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105771. * @param force the force to apply
  105772. * @param maxForce max force for this motor.
  105773. */
  105774. setMotor(force?: number, maxForce?: number): void;
  105775. /**
  105776. * Set the motor's limits.
  105777. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105778. * @param upperLimit The upper limit of the motor
  105779. * @param lowerLimit The lower limit of the motor
  105780. */
  105781. setLimit(upperLimit: number, lowerLimit?: number): void;
  105782. }
  105783. /**
  105784. * This class represents a single physics Hinge-Joint
  105785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105786. */
  105787. export class HingeJoint extends MotorEnabledJoint {
  105788. /**
  105789. * Initializes the Hinge-Joint
  105790. * @param jointData The joint data for the Hinge-Joint
  105791. */
  105792. constructor(jointData: PhysicsJointData);
  105793. /**
  105794. * Set the motor values.
  105795. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105796. * @param {number} force the force to apply
  105797. * @param {number} maxForce max force for this motor.
  105798. */
  105799. setMotor(force?: number, maxForce?: number): void;
  105800. /**
  105801. * Set the motor's limits.
  105802. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105803. * @param upperLimit The upper limit of the motor
  105804. * @param lowerLimit The lower limit of the motor
  105805. */
  105806. setLimit(upperLimit: number, lowerLimit?: number): void;
  105807. }
  105808. /**
  105809. * This class represents a dual hinge physics joint (same as wheel joint)
  105810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105811. */
  105812. export class Hinge2Joint extends MotorEnabledJoint {
  105813. /**
  105814. * Initializes the Hinge2-Joint
  105815. * @param jointData The joint data for the Hinge2-Joint
  105816. */
  105817. constructor(jointData: PhysicsJointData);
  105818. /**
  105819. * Set the motor values.
  105820. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105821. * @param {number} targetSpeed the speed the motor is to reach
  105822. * @param {number} maxForce max force for this motor.
  105823. * @param {motorIndex} the motor's index, 0 or 1.
  105824. */
  105825. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  105826. /**
  105827. * Set the motor limits.
  105828. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105829. * @param {number} upperLimit the upper limit
  105830. * @param {number} lowerLimit lower limit
  105831. * @param {motorIndex} the motor's index, 0 or 1.
  105832. */
  105833. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105834. }
  105835. /**
  105836. * Interface for a motor enabled joint
  105837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105838. */
  105839. export interface IMotorEnabledJoint {
  105840. /**
  105841. * Physics joint
  105842. */
  105843. physicsJoint: any;
  105844. /**
  105845. * Sets the motor of the motor-enabled joint
  105846. * @param force The force of the motor
  105847. * @param maxForce The maximum force of the motor
  105848. * @param motorIndex The index of the motor
  105849. */
  105850. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  105851. /**
  105852. * Sets the limit of the motor
  105853. * @param upperLimit The upper limit of the motor
  105854. * @param lowerLimit The lower limit of the motor
  105855. * @param motorIndex The index of the motor
  105856. */
  105857. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105858. }
  105859. /**
  105860. * Joint data for a Distance-Joint
  105861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105862. */
  105863. export interface DistanceJointData extends PhysicsJointData {
  105864. /**
  105865. * Max distance the 2 joint objects can be apart
  105866. */
  105867. maxDistance: number;
  105868. }
  105869. /**
  105870. * Joint data from a spring joint
  105871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105872. */
  105873. export interface SpringJointData extends PhysicsJointData {
  105874. /**
  105875. * Length of the spring
  105876. */
  105877. length: number;
  105878. /**
  105879. * Stiffness of the spring
  105880. */
  105881. stiffness: number;
  105882. /**
  105883. * Damping of the spring
  105884. */
  105885. damping: number;
  105886. /** this callback will be called when applying the force to the impostors. */
  105887. forceApplicationCallback: () => void;
  105888. }
  105889. }
  105890. declare module BABYLON {
  105891. /**
  105892. * Holds the data for the raycast result
  105893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105894. */
  105895. export class PhysicsRaycastResult {
  105896. private _hasHit;
  105897. private _hitDistance;
  105898. private _hitNormalWorld;
  105899. private _hitPointWorld;
  105900. private _rayFromWorld;
  105901. private _rayToWorld;
  105902. /**
  105903. * Gets if there was a hit
  105904. */
  105905. get hasHit(): boolean;
  105906. /**
  105907. * Gets the distance from the hit
  105908. */
  105909. get hitDistance(): number;
  105910. /**
  105911. * Gets the hit normal/direction in the world
  105912. */
  105913. get hitNormalWorld(): Vector3;
  105914. /**
  105915. * Gets the hit point in the world
  105916. */
  105917. get hitPointWorld(): Vector3;
  105918. /**
  105919. * Gets the ray "start point" of the ray in the world
  105920. */
  105921. get rayFromWorld(): Vector3;
  105922. /**
  105923. * Gets the ray "end point" of the ray in the world
  105924. */
  105925. get rayToWorld(): Vector3;
  105926. /**
  105927. * Sets the hit data (normal & point in world space)
  105928. * @param hitNormalWorld defines the normal in world space
  105929. * @param hitPointWorld defines the point in world space
  105930. */
  105931. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  105932. /**
  105933. * Sets the distance from the start point to the hit point
  105934. * @param distance
  105935. */
  105936. setHitDistance(distance: number): void;
  105937. /**
  105938. * Calculates the distance manually
  105939. */
  105940. calculateHitDistance(): void;
  105941. /**
  105942. * Resets all the values to default
  105943. * @param from The from point on world space
  105944. * @param to The to point on world space
  105945. */
  105946. reset(from?: Vector3, to?: Vector3): void;
  105947. }
  105948. /**
  105949. * Interface for the size containing width and height
  105950. */
  105951. interface IXYZ {
  105952. /**
  105953. * X
  105954. */
  105955. x: number;
  105956. /**
  105957. * Y
  105958. */
  105959. y: number;
  105960. /**
  105961. * Z
  105962. */
  105963. z: number;
  105964. }
  105965. }
  105966. declare module BABYLON {
  105967. /**
  105968. * Interface used to describe a physics joint
  105969. */
  105970. export interface PhysicsImpostorJoint {
  105971. /** Defines the main impostor to which the joint is linked */
  105972. mainImpostor: PhysicsImpostor;
  105973. /** Defines the impostor that is connected to the main impostor using this joint */
  105974. connectedImpostor: PhysicsImpostor;
  105975. /** Defines the joint itself */
  105976. joint: PhysicsJoint;
  105977. }
  105978. /** @hidden */
  105979. export interface IPhysicsEnginePlugin {
  105980. world: any;
  105981. name: string;
  105982. setGravity(gravity: Vector3): void;
  105983. setTimeStep(timeStep: number): void;
  105984. getTimeStep(): number;
  105985. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105986. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105987. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105988. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105989. removePhysicsBody(impostor: PhysicsImpostor): void;
  105990. generateJoint(joint: PhysicsImpostorJoint): void;
  105991. removeJoint(joint: PhysicsImpostorJoint): void;
  105992. isSupported(): boolean;
  105993. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105994. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105995. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105996. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105997. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105998. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105999. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106000. getBodyMass(impostor: PhysicsImpostor): number;
  106001. getBodyFriction(impostor: PhysicsImpostor): number;
  106002. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106003. getBodyRestitution(impostor: PhysicsImpostor): number;
  106004. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106005. getBodyPressure?(impostor: PhysicsImpostor): number;
  106006. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  106007. getBodyStiffness?(impostor: PhysicsImpostor): number;
  106008. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  106009. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  106010. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  106011. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  106012. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  106013. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106014. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106015. sleepBody(impostor: PhysicsImpostor): void;
  106016. wakeUpBody(impostor: PhysicsImpostor): void;
  106017. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106018. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106019. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  106020. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106021. getRadius(impostor: PhysicsImpostor): number;
  106022. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106023. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106024. dispose(): void;
  106025. }
  106026. /**
  106027. * Interface used to define a physics engine
  106028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106029. */
  106030. export interface IPhysicsEngine {
  106031. /**
  106032. * Gets the gravity vector used by the simulation
  106033. */
  106034. gravity: Vector3;
  106035. /**
  106036. * Sets the gravity vector used by the simulation
  106037. * @param gravity defines the gravity vector to use
  106038. */
  106039. setGravity(gravity: Vector3): void;
  106040. /**
  106041. * Set the time step of the physics engine.
  106042. * Default is 1/60.
  106043. * To slow it down, enter 1/600 for example.
  106044. * To speed it up, 1/30
  106045. * @param newTimeStep the new timestep to apply to this world.
  106046. */
  106047. setTimeStep(newTimeStep: number): void;
  106048. /**
  106049. * Get the time step of the physics engine.
  106050. * @returns the current time step
  106051. */
  106052. getTimeStep(): number;
  106053. /**
  106054. * Set the sub time step of the physics engine.
  106055. * Default is 0 meaning there is no sub steps
  106056. * To increase physics resolution precision, set a small value (like 1 ms)
  106057. * @param subTimeStep defines the new sub timestep used for physics resolution.
  106058. */
  106059. setSubTimeStep(subTimeStep: number): void;
  106060. /**
  106061. * Get the sub time step of the physics engine.
  106062. * @returns the current sub time step
  106063. */
  106064. getSubTimeStep(): number;
  106065. /**
  106066. * Release all resources
  106067. */
  106068. dispose(): void;
  106069. /**
  106070. * Gets the name of the current physics plugin
  106071. * @returns the name of the plugin
  106072. */
  106073. getPhysicsPluginName(): string;
  106074. /**
  106075. * Adding a new impostor for the impostor tracking.
  106076. * This will be done by the impostor itself.
  106077. * @param impostor the impostor to add
  106078. */
  106079. addImpostor(impostor: PhysicsImpostor): void;
  106080. /**
  106081. * Remove an impostor from the engine.
  106082. * This impostor and its mesh will not longer be updated by the physics engine.
  106083. * @param impostor the impostor to remove
  106084. */
  106085. removeImpostor(impostor: PhysicsImpostor): void;
  106086. /**
  106087. * Add a joint to the physics engine
  106088. * @param mainImpostor defines the main impostor to which the joint is added.
  106089. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106090. * @param joint defines the joint that will connect both impostors.
  106091. */
  106092. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106093. /**
  106094. * Removes a joint from the simulation
  106095. * @param mainImpostor defines the impostor used with the joint
  106096. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106097. * @param joint defines the joint to remove
  106098. */
  106099. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106100. /**
  106101. * Gets the current plugin used to run the simulation
  106102. * @returns current plugin
  106103. */
  106104. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106105. /**
  106106. * Gets the list of physic impostors
  106107. * @returns an array of PhysicsImpostor
  106108. */
  106109. getImpostors(): Array<PhysicsImpostor>;
  106110. /**
  106111. * Gets the impostor for a physics enabled object
  106112. * @param object defines the object impersonated by the impostor
  106113. * @returns the PhysicsImpostor or null if not found
  106114. */
  106115. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106116. /**
  106117. * Gets the impostor for a physics body object
  106118. * @param body defines physics body used by the impostor
  106119. * @returns the PhysicsImpostor or null if not found
  106120. */
  106121. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106122. /**
  106123. * Does a raycast in the physics world
  106124. * @param from when should the ray start?
  106125. * @param to when should the ray end?
  106126. * @returns PhysicsRaycastResult
  106127. */
  106128. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106129. /**
  106130. * Called by the scene. No need to call it.
  106131. * @param delta defines the timespam between frames
  106132. */
  106133. _step(delta: number): void;
  106134. }
  106135. }
  106136. declare module BABYLON {
  106137. /**
  106138. * The interface for the physics imposter parameters
  106139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106140. */
  106141. export interface PhysicsImpostorParameters {
  106142. /**
  106143. * The mass of the physics imposter
  106144. */
  106145. mass: number;
  106146. /**
  106147. * The friction of the physics imposter
  106148. */
  106149. friction?: number;
  106150. /**
  106151. * The coefficient of restitution of the physics imposter
  106152. */
  106153. restitution?: number;
  106154. /**
  106155. * The native options of the physics imposter
  106156. */
  106157. nativeOptions?: any;
  106158. /**
  106159. * Specifies if the parent should be ignored
  106160. */
  106161. ignoreParent?: boolean;
  106162. /**
  106163. * Specifies if bi-directional transformations should be disabled
  106164. */
  106165. disableBidirectionalTransformation?: boolean;
  106166. /**
  106167. * The pressure inside the physics imposter, soft object only
  106168. */
  106169. pressure?: number;
  106170. /**
  106171. * The stiffness the physics imposter, soft object only
  106172. */
  106173. stiffness?: number;
  106174. /**
  106175. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  106176. */
  106177. velocityIterations?: number;
  106178. /**
  106179. * The number of iterations used in maintaining consistent vertex positions, soft object only
  106180. */
  106181. positionIterations?: number;
  106182. /**
  106183. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  106184. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  106185. * Add to fix multiple points
  106186. */
  106187. fixedPoints?: number;
  106188. /**
  106189. * The collision margin around a soft object
  106190. */
  106191. margin?: number;
  106192. /**
  106193. * The collision margin around a soft object
  106194. */
  106195. damping?: number;
  106196. /**
  106197. * The path for a rope based on an extrusion
  106198. */
  106199. path?: any;
  106200. /**
  106201. * The shape of an extrusion used for a rope based on an extrusion
  106202. */
  106203. shape?: any;
  106204. }
  106205. /**
  106206. * Interface for a physics-enabled object
  106207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106208. */
  106209. export interface IPhysicsEnabledObject {
  106210. /**
  106211. * The position of the physics-enabled object
  106212. */
  106213. position: Vector3;
  106214. /**
  106215. * The rotation of the physics-enabled object
  106216. */
  106217. rotationQuaternion: Nullable<Quaternion>;
  106218. /**
  106219. * The scale of the physics-enabled object
  106220. */
  106221. scaling: Vector3;
  106222. /**
  106223. * The rotation of the physics-enabled object
  106224. */
  106225. rotation?: Vector3;
  106226. /**
  106227. * The parent of the physics-enabled object
  106228. */
  106229. parent?: any;
  106230. /**
  106231. * The bounding info of the physics-enabled object
  106232. * @returns The bounding info of the physics-enabled object
  106233. */
  106234. getBoundingInfo(): BoundingInfo;
  106235. /**
  106236. * Computes the world matrix
  106237. * @param force Specifies if the world matrix should be computed by force
  106238. * @returns A world matrix
  106239. */
  106240. computeWorldMatrix(force: boolean): Matrix;
  106241. /**
  106242. * Gets the world matrix
  106243. * @returns A world matrix
  106244. */
  106245. getWorldMatrix?(): Matrix;
  106246. /**
  106247. * Gets the child meshes
  106248. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  106249. * @returns An array of abstract meshes
  106250. */
  106251. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  106252. /**
  106253. * Gets the vertex data
  106254. * @param kind The type of vertex data
  106255. * @returns A nullable array of numbers, or a float32 array
  106256. */
  106257. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  106258. /**
  106259. * Gets the indices from the mesh
  106260. * @returns A nullable array of index arrays
  106261. */
  106262. getIndices?(): Nullable<IndicesArray>;
  106263. /**
  106264. * Gets the scene from the mesh
  106265. * @returns the indices array or null
  106266. */
  106267. getScene?(): Scene;
  106268. /**
  106269. * Gets the absolute position from the mesh
  106270. * @returns the absolute position
  106271. */
  106272. getAbsolutePosition(): Vector3;
  106273. /**
  106274. * Gets the absolute pivot point from the mesh
  106275. * @returns the absolute pivot point
  106276. */
  106277. getAbsolutePivotPoint(): Vector3;
  106278. /**
  106279. * Rotates the mesh
  106280. * @param axis The axis of rotation
  106281. * @param amount The amount of rotation
  106282. * @param space The space of the rotation
  106283. * @returns The rotation transform node
  106284. */
  106285. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  106286. /**
  106287. * Translates the mesh
  106288. * @param axis The axis of translation
  106289. * @param distance The distance of translation
  106290. * @param space The space of the translation
  106291. * @returns The transform node
  106292. */
  106293. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  106294. /**
  106295. * Sets the absolute position of the mesh
  106296. * @param absolutePosition The absolute position of the mesh
  106297. * @returns The transform node
  106298. */
  106299. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  106300. /**
  106301. * Gets the class name of the mesh
  106302. * @returns The class name
  106303. */
  106304. getClassName(): string;
  106305. }
  106306. /**
  106307. * Represents a physics imposter
  106308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106309. */
  106310. export class PhysicsImpostor {
  106311. /**
  106312. * The physics-enabled object used as the physics imposter
  106313. */
  106314. object: IPhysicsEnabledObject;
  106315. /**
  106316. * The type of the physics imposter
  106317. */
  106318. type: number;
  106319. private _options;
  106320. private _scene?;
  106321. /**
  106322. * The default object size of the imposter
  106323. */
  106324. static DEFAULT_OBJECT_SIZE: Vector3;
  106325. /**
  106326. * The identity quaternion of the imposter
  106327. */
  106328. static IDENTITY_QUATERNION: Quaternion;
  106329. /** @hidden */
  106330. _pluginData: any;
  106331. private _physicsEngine;
  106332. private _physicsBody;
  106333. private _bodyUpdateRequired;
  106334. private _onBeforePhysicsStepCallbacks;
  106335. private _onAfterPhysicsStepCallbacks;
  106336. /** @hidden */
  106337. _onPhysicsCollideCallbacks: Array<{
  106338. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  106339. otherImpostors: Array<PhysicsImpostor>;
  106340. }>;
  106341. private _deltaPosition;
  106342. private _deltaRotation;
  106343. private _deltaRotationConjugated;
  106344. /** @hidden */
  106345. _isFromLine: boolean;
  106346. private _parent;
  106347. private _isDisposed;
  106348. private static _tmpVecs;
  106349. private static _tmpQuat;
  106350. /**
  106351. * Specifies if the physics imposter is disposed
  106352. */
  106353. get isDisposed(): boolean;
  106354. /**
  106355. * Gets the mass of the physics imposter
  106356. */
  106357. get mass(): number;
  106358. set mass(value: number);
  106359. /**
  106360. * Gets the coefficient of friction
  106361. */
  106362. get friction(): number;
  106363. /**
  106364. * Sets the coefficient of friction
  106365. */
  106366. set friction(value: number);
  106367. /**
  106368. * Gets the coefficient of restitution
  106369. */
  106370. get restitution(): number;
  106371. /**
  106372. * Sets the coefficient of restitution
  106373. */
  106374. set restitution(value: number);
  106375. /**
  106376. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106377. */
  106378. get pressure(): number;
  106379. /**
  106380. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106381. */
  106382. set pressure(value: number);
  106383. /**
  106384. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106385. */
  106386. get stiffness(): number;
  106387. /**
  106388. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106389. */
  106390. set stiffness(value: number);
  106391. /**
  106392. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106393. */
  106394. get velocityIterations(): number;
  106395. /**
  106396. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106397. */
  106398. set velocityIterations(value: number);
  106399. /**
  106400. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106401. */
  106402. get positionIterations(): number;
  106403. /**
  106404. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106405. */
  106406. set positionIterations(value: number);
  106407. /**
  106408. * The unique id of the physics imposter
  106409. * set by the physics engine when adding this impostor to the array
  106410. */
  106411. uniqueId: number;
  106412. /**
  106413. * @hidden
  106414. */
  106415. soft: boolean;
  106416. /**
  106417. * @hidden
  106418. */
  106419. segments: number;
  106420. private _joints;
  106421. /**
  106422. * Initializes the physics imposter
  106423. * @param object The physics-enabled object used as the physics imposter
  106424. * @param type The type of the physics imposter
  106425. * @param _options The options for the physics imposter
  106426. * @param _scene The Babylon scene
  106427. */
  106428. constructor(
  106429. /**
  106430. * The physics-enabled object used as the physics imposter
  106431. */
  106432. object: IPhysicsEnabledObject,
  106433. /**
  106434. * The type of the physics imposter
  106435. */
  106436. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  106437. /**
  106438. * This function will completly initialize this impostor.
  106439. * It will create a new body - but only if this mesh has no parent.
  106440. * If it has, this impostor will not be used other than to define the impostor
  106441. * of the child mesh.
  106442. * @hidden
  106443. */
  106444. _init(): void;
  106445. private _getPhysicsParent;
  106446. /**
  106447. * Should a new body be generated.
  106448. * @returns boolean specifying if body initialization is required
  106449. */
  106450. isBodyInitRequired(): boolean;
  106451. /**
  106452. * Sets the updated scaling
  106453. * @param updated Specifies if the scaling is updated
  106454. */
  106455. setScalingUpdated(): void;
  106456. /**
  106457. * Force a regeneration of this or the parent's impostor's body.
  106458. * Use under cautious - This will remove all joints already implemented.
  106459. */
  106460. forceUpdate(): void;
  106461. /**
  106462. * Gets the body that holds this impostor. Either its own, or its parent.
  106463. */
  106464. get physicsBody(): any;
  106465. /**
  106466. * Get the parent of the physics imposter
  106467. * @returns Physics imposter or null
  106468. */
  106469. get parent(): Nullable<PhysicsImpostor>;
  106470. /**
  106471. * Sets the parent of the physics imposter
  106472. */
  106473. set parent(value: Nullable<PhysicsImpostor>);
  106474. /**
  106475. * Set the physics body. Used mainly by the physics engine/plugin
  106476. */
  106477. set physicsBody(physicsBody: any);
  106478. /**
  106479. * Resets the update flags
  106480. */
  106481. resetUpdateFlags(): void;
  106482. /**
  106483. * Gets the object extend size
  106484. * @returns the object extend size
  106485. */
  106486. getObjectExtendSize(): Vector3;
  106487. /**
  106488. * Gets the object center
  106489. * @returns The object center
  106490. */
  106491. getObjectCenter(): Vector3;
  106492. /**
  106493. * Get a specific parameter from the options parameters
  106494. * @param paramName The object parameter name
  106495. * @returns The object parameter
  106496. */
  106497. getParam(paramName: string): any;
  106498. /**
  106499. * Sets a specific parameter in the options given to the physics plugin
  106500. * @param paramName The parameter name
  106501. * @param value The value of the parameter
  106502. */
  106503. setParam(paramName: string, value: number): void;
  106504. /**
  106505. * Specifically change the body's mass option. Won't recreate the physics body object
  106506. * @param mass The mass of the physics imposter
  106507. */
  106508. setMass(mass: number): void;
  106509. /**
  106510. * Gets the linear velocity
  106511. * @returns linear velocity or null
  106512. */
  106513. getLinearVelocity(): Nullable<Vector3>;
  106514. /**
  106515. * Sets the linear velocity
  106516. * @param velocity linear velocity or null
  106517. */
  106518. setLinearVelocity(velocity: Nullable<Vector3>): void;
  106519. /**
  106520. * Gets the angular velocity
  106521. * @returns angular velocity or null
  106522. */
  106523. getAngularVelocity(): Nullable<Vector3>;
  106524. /**
  106525. * Sets the angular velocity
  106526. * @param velocity The velocity or null
  106527. */
  106528. setAngularVelocity(velocity: Nullable<Vector3>): void;
  106529. /**
  106530. * Execute a function with the physics plugin native code
  106531. * Provide a function the will have two variables - the world object and the physics body object
  106532. * @param func The function to execute with the physics plugin native code
  106533. */
  106534. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  106535. /**
  106536. * Register 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. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106540. /**
  106541. * Unregister a function that will be executed before the physics world is stepping forward
  106542. * @param func The function to execute before the physics world is stepped forward
  106543. */
  106544. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106545. /**
  106546. * Register a function that will be executed after the physics step
  106547. * @param func The function to execute after physics step
  106548. */
  106549. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106550. /**
  106551. * Unregisters a function that will be executed after the physics step
  106552. * @param func The function to execute after physics step
  106553. */
  106554. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106555. /**
  106556. * register a function that will be executed when this impostor collides against a different body
  106557. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  106558. * @param func Callback that is executed on collision
  106559. */
  106560. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  106561. /**
  106562. * Unregisters the physics imposter on contact
  106563. * @param collideAgainst The physics object to collide against
  106564. * @param func Callback to execute on collision
  106565. */
  106566. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  106567. private _tmpQuat;
  106568. private _tmpQuat2;
  106569. /**
  106570. * Get the parent rotation
  106571. * @returns The parent rotation
  106572. */
  106573. getParentsRotation(): Quaternion;
  106574. /**
  106575. * this function is executed by the physics engine.
  106576. */
  106577. beforeStep: () => void;
  106578. /**
  106579. * this function is executed by the physics engine
  106580. */
  106581. afterStep: () => void;
  106582. /**
  106583. * Legacy collision detection event support
  106584. */
  106585. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  106586. /**
  106587. * event and body object due to cannon's event-based architecture.
  106588. */
  106589. onCollide: (e: {
  106590. body: any;
  106591. }) => void;
  106592. /**
  106593. * Apply a force
  106594. * @param force The force to apply
  106595. * @param contactPoint The contact point for the force
  106596. * @returns The physics imposter
  106597. */
  106598. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106599. /**
  106600. * Apply an impulse
  106601. * @param force The impulse force
  106602. * @param contactPoint The contact point for the impulse force
  106603. * @returns The physics imposter
  106604. */
  106605. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106606. /**
  106607. * A help function to create a joint
  106608. * @param otherImpostor A physics imposter used to create a joint
  106609. * @param jointType The type of joint
  106610. * @param jointData The data for the joint
  106611. * @returns The physics imposter
  106612. */
  106613. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  106614. /**
  106615. * Add a joint to this impostor with a different impostor
  106616. * @param otherImpostor A physics imposter used to add a joint
  106617. * @param joint The joint to add
  106618. * @returns The physics imposter
  106619. */
  106620. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  106621. /**
  106622. * Add an anchor to a cloth impostor
  106623. * @param otherImpostor rigid impostor to anchor to
  106624. * @param width ratio across width from 0 to 1
  106625. * @param height ratio up height from 0 to 1
  106626. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  106627. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  106628. * @returns impostor the soft imposter
  106629. */
  106630. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106631. /**
  106632. * Add a hook to a rope impostor
  106633. * @param otherImpostor rigid impostor to anchor to
  106634. * @param length ratio across rope from 0 to 1
  106635. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  106636. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  106637. * @returns impostor the rope imposter
  106638. */
  106639. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106640. /**
  106641. * Will keep this body still, in a sleep mode.
  106642. * @returns the physics imposter
  106643. */
  106644. sleep(): PhysicsImpostor;
  106645. /**
  106646. * Wake the body up.
  106647. * @returns The physics imposter
  106648. */
  106649. wakeUp(): PhysicsImpostor;
  106650. /**
  106651. * Clones the physics imposter
  106652. * @param newObject The physics imposter clones to this physics-enabled object
  106653. * @returns A nullable physics imposter
  106654. */
  106655. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106656. /**
  106657. * Disposes the physics imposter
  106658. */
  106659. dispose(): void;
  106660. /**
  106661. * Sets the delta position
  106662. * @param position The delta position amount
  106663. */
  106664. setDeltaPosition(position: Vector3): void;
  106665. /**
  106666. * Sets the delta rotation
  106667. * @param rotation The delta rotation amount
  106668. */
  106669. setDeltaRotation(rotation: Quaternion): void;
  106670. /**
  106671. * Gets the box size of the physics imposter and stores the result in the input parameter
  106672. * @param result Stores the box size
  106673. * @returns The physics imposter
  106674. */
  106675. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  106676. /**
  106677. * Gets the radius of the physics imposter
  106678. * @returns Radius of the physics imposter
  106679. */
  106680. getRadius(): number;
  106681. /**
  106682. * Sync a bone with this impostor
  106683. * @param bone The bone to sync to the impostor.
  106684. * @param boneMesh The mesh that the bone is influencing.
  106685. * @param jointPivot The pivot of the joint / bone in local space.
  106686. * @param distToJoint Optional distance from the impostor to the joint.
  106687. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106688. */
  106689. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  106690. /**
  106691. * Sync impostor to a bone
  106692. * @param bone The bone that the impostor will be synced to.
  106693. * @param boneMesh The mesh that the bone is influencing.
  106694. * @param jointPivot The pivot of the joint / bone in local space.
  106695. * @param distToJoint Optional distance from the impostor to the joint.
  106696. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106697. * @param boneAxis Optional vector3 axis the bone is aligned with
  106698. */
  106699. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  106700. /**
  106701. * No-Imposter type
  106702. */
  106703. static NoImpostor: number;
  106704. /**
  106705. * Sphere-Imposter type
  106706. */
  106707. static SphereImpostor: number;
  106708. /**
  106709. * Box-Imposter type
  106710. */
  106711. static BoxImpostor: number;
  106712. /**
  106713. * Plane-Imposter type
  106714. */
  106715. static PlaneImpostor: number;
  106716. /**
  106717. * Mesh-imposter type
  106718. */
  106719. static MeshImpostor: number;
  106720. /**
  106721. * Capsule-Impostor type (Ammo.js plugin only)
  106722. */
  106723. static CapsuleImpostor: number;
  106724. /**
  106725. * Cylinder-Imposter type
  106726. */
  106727. static CylinderImpostor: number;
  106728. /**
  106729. * Particle-Imposter type
  106730. */
  106731. static ParticleImpostor: number;
  106732. /**
  106733. * Heightmap-Imposter type
  106734. */
  106735. static HeightmapImpostor: number;
  106736. /**
  106737. * ConvexHull-Impostor type (Ammo.js plugin only)
  106738. */
  106739. static ConvexHullImpostor: number;
  106740. /**
  106741. * Custom-Imposter type (Ammo.js plugin only)
  106742. */
  106743. static CustomImpostor: number;
  106744. /**
  106745. * Rope-Imposter type
  106746. */
  106747. static RopeImpostor: number;
  106748. /**
  106749. * Cloth-Imposter type
  106750. */
  106751. static ClothImpostor: number;
  106752. /**
  106753. * Softbody-Imposter type
  106754. */
  106755. static SoftbodyImpostor: number;
  106756. }
  106757. }
  106758. declare module BABYLON {
  106759. /**
  106760. * @hidden
  106761. **/
  106762. export class _CreationDataStorage {
  106763. closePath?: boolean;
  106764. closeArray?: boolean;
  106765. idx: number[];
  106766. dashSize: number;
  106767. gapSize: number;
  106768. path3D: Path3D;
  106769. pathArray: Vector3[][];
  106770. arc: number;
  106771. radius: number;
  106772. cap: number;
  106773. tessellation: number;
  106774. }
  106775. /**
  106776. * @hidden
  106777. **/
  106778. class _InstanceDataStorage {
  106779. visibleInstances: any;
  106780. batchCache: _InstancesBatch;
  106781. instancesBufferSize: number;
  106782. instancesBuffer: Nullable<Buffer>;
  106783. instancesData: Float32Array;
  106784. overridenInstanceCount: number;
  106785. isFrozen: boolean;
  106786. previousBatch: Nullable<_InstancesBatch>;
  106787. hardwareInstancedRendering: boolean;
  106788. sideOrientation: number;
  106789. manualUpdate: boolean;
  106790. }
  106791. /**
  106792. * @hidden
  106793. **/
  106794. export class _InstancesBatch {
  106795. mustReturn: boolean;
  106796. visibleInstances: Nullable<InstancedMesh[]>[];
  106797. renderSelf: boolean[];
  106798. hardwareInstancedRendering: boolean[];
  106799. }
  106800. /**
  106801. * @hidden
  106802. **/
  106803. class _ThinInstanceDataStorage {
  106804. instancesCount: number;
  106805. matrixBuffer: Nullable<Buffer>;
  106806. matrixBufferSize: number;
  106807. matrixData: Nullable<Float32Array>;
  106808. boundingVectors: Array<Vector3>;
  106809. worldMatrices: Nullable<Matrix[]>;
  106810. }
  106811. /**
  106812. * Class used to represent renderable models
  106813. */
  106814. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  106815. /**
  106816. * Mesh side orientation : usually the external or front surface
  106817. */
  106818. static readonly FRONTSIDE: number;
  106819. /**
  106820. * Mesh side orientation : usually the internal or back surface
  106821. */
  106822. static readonly BACKSIDE: number;
  106823. /**
  106824. * Mesh side orientation : both internal and external or front and back surfaces
  106825. */
  106826. static readonly DOUBLESIDE: number;
  106827. /**
  106828. * Mesh side orientation : by default, `FRONTSIDE`
  106829. */
  106830. static readonly DEFAULTSIDE: number;
  106831. /**
  106832. * Mesh cap setting : no cap
  106833. */
  106834. static readonly NO_CAP: number;
  106835. /**
  106836. * Mesh cap setting : one cap at the beginning of the mesh
  106837. */
  106838. static readonly CAP_START: number;
  106839. /**
  106840. * Mesh cap setting : one cap at the end of the mesh
  106841. */
  106842. static readonly CAP_END: number;
  106843. /**
  106844. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  106845. */
  106846. static readonly CAP_ALL: number;
  106847. /**
  106848. * Mesh pattern setting : no flip or rotate
  106849. */
  106850. static readonly NO_FLIP: number;
  106851. /**
  106852. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  106853. */
  106854. static readonly FLIP_TILE: number;
  106855. /**
  106856. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  106857. */
  106858. static readonly ROTATE_TILE: number;
  106859. /**
  106860. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  106861. */
  106862. static readonly FLIP_ROW: number;
  106863. /**
  106864. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  106865. */
  106866. static readonly ROTATE_ROW: number;
  106867. /**
  106868. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  106869. */
  106870. static readonly FLIP_N_ROTATE_TILE: number;
  106871. /**
  106872. * Mesh pattern setting : rotate pattern and rotate
  106873. */
  106874. static readonly FLIP_N_ROTATE_ROW: number;
  106875. /**
  106876. * Mesh tile positioning : part tiles same on left/right or top/bottom
  106877. */
  106878. static readonly CENTER: number;
  106879. /**
  106880. * Mesh tile positioning : part tiles on left
  106881. */
  106882. static readonly LEFT: number;
  106883. /**
  106884. * Mesh tile positioning : part tiles on right
  106885. */
  106886. static readonly RIGHT: number;
  106887. /**
  106888. * Mesh tile positioning : part tiles on top
  106889. */
  106890. static readonly TOP: number;
  106891. /**
  106892. * Mesh tile positioning : part tiles on bottom
  106893. */
  106894. static readonly BOTTOM: number;
  106895. /**
  106896. * Gets the default side orientation.
  106897. * @param orientation the orientation to value to attempt to get
  106898. * @returns the default orientation
  106899. * @hidden
  106900. */
  106901. static _GetDefaultSideOrientation(orientation?: number): number;
  106902. private _internalMeshDataInfo;
  106903. get computeBonesUsingShaders(): boolean;
  106904. set computeBonesUsingShaders(value: boolean);
  106905. /**
  106906. * An event triggered before rendering the mesh
  106907. */
  106908. get onBeforeRenderObservable(): Observable<Mesh>;
  106909. /**
  106910. * An event triggered before binding the mesh
  106911. */
  106912. get onBeforeBindObservable(): Observable<Mesh>;
  106913. /**
  106914. * An event triggered after rendering the mesh
  106915. */
  106916. get onAfterRenderObservable(): Observable<Mesh>;
  106917. /**
  106918. * An event triggered before drawing the mesh
  106919. */
  106920. get onBeforeDrawObservable(): Observable<Mesh>;
  106921. private _onBeforeDrawObserver;
  106922. /**
  106923. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  106924. */
  106925. set onBeforeDraw(callback: () => void);
  106926. get hasInstances(): boolean;
  106927. get hasThinInstances(): boolean;
  106928. /**
  106929. * Gets the delay loading state of the mesh (when delay loading is turned on)
  106930. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  106931. */
  106932. delayLoadState: number;
  106933. /**
  106934. * Gets the list of instances created from this mesh
  106935. * it is not supposed to be modified manually.
  106936. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  106937. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106938. */
  106939. instances: InstancedMesh[];
  106940. /**
  106941. * Gets the file containing delay loading data for this mesh
  106942. */
  106943. delayLoadingFile: string;
  106944. /** @hidden */
  106945. _binaryInfo: any;
  106946. /**
  106947. * User defined function used to change how LOD level selection is done
  106948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106949. */
  106950. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  106951. /**
  106952. * Gets or sets the morph target manager
  106953. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106954. */
  106955. get morphTargetManager(): Nullable<MorphTargetManager>;
  106956. set morphTargetManager(value: Nullable<MorphTargetManager>);
  106957. /** @hidden */
  106958. _creationDataStorage: Nullable<_CreationDataStorage>;
  106959. /** @hidden */
  106960. _geometry: Nullable<Geometry>;
  106961. /** @hidden */
  106962. _delayInfo: Array<string>;
  106963. /** @hidden */
  106964. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  106965. /** @hidden */
  106966. _instanceDataStorage: _InstanceDataStorage;
  106967. /** @hidden */
  106968. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  106969. private _effectiveMaterial;
  106970. /** @hidden */
  106971. _shouldGenerateFlatShading: boolean;
  106972. /** @hidden */
  106973. _originalBuilderSideOrientation: number;
  106974. /**
  106975. * Use this property to change the original side orientation defined at construction time
  106976. */
  106977. overrideMaterialSideOrientation: Nullable<number>;
  106978. /**
  106979. * Gets the source mesh (the one used to clone this one from)
  106980. */
  106981. get source(): Nullable<Mesh>;
  106982. /**
  106983. * Gets or sets a boolean indicating that this mesh does not use index buffer
  106984. */
  106985. get isUnIndexed(): boolean;
  106986. set isUnIndexed(value: boolean);
  106987. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  106988. get worldMatrixInstancedBuffer(): Float32Array;
  106989. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  106990. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  106991. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  106992. /**
  106993. * @constructor
  106994. * @param name The value used by scene.getMeshByName() to do a lookup.
  106995. * @param scene The scene to add this mesh to.
  106996. * @param parent The parent of this mesh, if it has one
  106997. * @param source An optional Mesh from which geometry is shared, cloned.
  106998. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  106999. * When false, achieved by calling a clone(), also passing False.
  107000. * This will make creation of children, recursive.
  107001. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  107002. */
  107003. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  107004. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107005. doNotInstantiate: boolean;
  107006. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107007. /**
  107008. * Gets the class name
  107009. * @returns the string "Mesh".
  107010. */
  107011. getClassName(): string;
  107012. /** @hidden */
  107013. get _isMesh(): boolean;
  107014. /**
  107015. * Returns a description of this mesh
  107016. * @param fullDetails define if full details about this mesh must be used
  107017. * @returns a descriptive string representing this mesh
  107018. */
  107019. toString(fullDetails?: boolean): string;
  107020. /** @hidden */
  107021. _unBindEffect(): void;
  107022. /**
  107023. * Gets a boolean indicating if this mesh has LOD
  107024. */
  107025. get hasLODLevels(): boolean;
  107026. /**
  107027. * Gets the list of MeshLODLevel associated with the current mesh
  107028. * @returns an array of MeshLODLevel
  107029. */
  107030. getLODLevels(): MeshLODLevel[];
  107031. private _sortLODLevels;
  107032. /**
  107033. * Add a mesh as LOD level triggered at the given distance.
  107034. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107035. * @param distance The distance from the center of the object to show this level
  107036. * @param mesh The mesh to be added as LOD level (can be null)
  107037. * @return This mesh (for chaining)
  107038. */
  107039. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  107040. /**
  107041. * Returns the LOD level mesh at the passed distance or null if not found.
  107042. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107043. * @param distance The distance from the center of the object to show this level
  107044. * @returns a Mesh or `null`
  107045. */
  107046. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  107047. /**
  107048. * Remove a mesh from the LOD array
  107049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107050. * @param mesh defines the mesh to be removed
  107051. * @return This mesh (for chaining)
  107052. */
  107053. removeLODLevel(mesh: Mesh): Mesh;
  107054. /**
  107055. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  107056. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107057. * @param camera defines the camera to use to compute distance
  107058. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  107059. * @return This mesh (for chaining)
  107060. */
  107061. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  107062. /**
  107063. * Gets the mesh internal Geometry object
  107064. */
  107065. get geometry(): Nullable<Geometry>;
  107066. /**
  107067. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  107068. * @returns the total number of vertices
  107069. */
  107070. getTotalVertices(): number;
  107071. /**
  107072. * Returns the content of an associated vertex buffer
  107073. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107074. * - VertexBuffer.PositionKind
  107075. * - VertexBuffer.UVKind
  107076. * - VertexBuffer.UV2Kind
  107077. * - VertexBuffer.UV3Kind
  107078. * - VertexBuffer.UV4Kind
  107079. * - VertexBuffer.UV5Kind
  107080. * - VertexBuffer.UV6Kind
  107081. * - VertexBuffer.ColorKind
  107082. * - VertexBuffer.MatricesIndicesKind
  107083. * - VertexBuffer.MatricesIndicesExtraKind
  107084. * - VertexBuffer.MatricesWeightsKind
  107085. * - VertexBuffer.MatricesWeightsExtraKind
  107086. * @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
  107087. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  107088. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  107089. */
  107090. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  107091. /**
  107092. * Returns the mesh VertexBuffer object from the requested `kind`
  107093. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107094. * - VertexBuffer.PositionKind
  107095. * - VertexBuffer.NormalKind
  107096. * - VertexBuffer.UVKind
  107097. * - VertexBuffer.UV2Kind
  107098. * - VertexBuffer.UV3Kind
  107099. * - VertexBuffer.UV4Kind
  107100. * - VertexBuffer.UV5Kind
  107101. * - VertexBuffer.UV6Kind
  107102. * - VertexBuffer.ColorKind
  107103. * - VertexBuffer.MatricesIndicesKind
  107104. * - VertexBuffer.MatricesIndicesExtraKind
  107105. * - VertexBuffer.MatricesWeightsKind
  107106. * - VertexBuffer.MatricesWeightsExtraKind
  107107. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  107108. */
  107109. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  107110. /**
  107111. * Tests if a specific vertex buffer is associated with this mesh
  107112. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107113. * - VertexBuffer.PositionKind
  107114. * - VertexBuffer.NormalKind
  107115. * - VertexBuffer.UVKind
  107116. * - VertexBuffer.UV2Kind
  107117. * - VertexBuffer.UV3Kind
  107118. * - VertexBuffer.UV4Kind
  107119. * - VertexBuffer.UV5Kind
  107120. * - VertexBuffer.UV6Kind
  107121. * - VertexBuffer.ColorKind
  107122. * - VertexBuffer.MatricesIndicesKind
  107123. * - VertexBuffer.MatricesIndicesExtraKind
  107124. * - VertexBuffer.MatricesWeightsKind
  107125. * - VertexBuffer.MatricesWeightsExtraKind
  107126. * @returns a boolean
  107127. */
  107128. isVerticesDataPresent(kind: string): boolean;
  107129. /**
  107130. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  107131. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107132. * - VertexBuffer.PositionKind
  107133. * - VertexBuffer.UVKind
  107134. * - VertexBuffer.UV2Kind
  107135. * - VertexBuffer.UV3Kind
  107136. * - VertexBuffer.UV4Kind
  107137. * - VertexBuffer.UV5Kind
  107138. * - VertexBuffer.UV6Kind
  107139. * - VertexBuffer.ColorKind
  107140. * - VertexBuffer.MatricesIndicesKind
  107141. * - VertexBuffer.MatricesIndicesExtraKind
  107142. * - VertexBuffer.MatricesWeightsKind
  107143. * - VertexBuffer.MatricesWeightsExtraKind
  107144. * @returns a boolean
  107145. */
  107146. isVertexBufferUpdatable(kind: string): boolean;
  107147. /**
  107148. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  107149. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107150. * - VertexBuffer.PositionKind
  107151. * - VertexBuffer.NormalKind
  107152. * - VertexBuffer.UVKind
  107153. * - VertexBuffer.UV2Kind
  107154. * - VertexBuffer.UV3Kind
  107155. * - VertexBuffer.UV4Kind
  107156. * - VertexBuffer.UV5Kind
  107157. * - VertexBuffer.UV6Kind
  107158. * - VertexBuffer.ColorKind
  107159. * - VertexBuffer.MatricesIndicesKind
  107160. * - VertexBuffer.MatricesIndicesExtraKind
  107161. * - VertexBuffer.MatricesWeightsKind
  107162. * - VertexBuffer.MatricesWeightsExtraKind
  107163. * @returns an array of strings
  107164. */
  107165. getVerticesDataKinds(): string[];
  107166. /**
  107167. * Returns a positive integer : the total number of indices in this mesh geometry.
  107168. * @returns the numner of indices or zero if the mesh has no geometry.
  107169. */
  107170. getTotalIndices(): number;
  107171. /**
  107172. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  107173. * @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.
  107174. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  107175. * @returns the indices array or an empty array if the mesh has no geometry
  107176. */
  107177. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  107178. get isBlocked(): boolean;
  107179. /**
  107180. * Determine if the current mesh is ready to be rendered
  107181. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  107182. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  107183. * @returns true if all associated assets are ready (material, textures, shaders)
  107184. */
  107185. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  107186. /**
  107187. * 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.
  107188. */
  107189. get areNormalsFrozen(): boolean;
  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 prevents the mesh normals from being recomputed on next `positions` array update.
  107192. * @returns the current mesh
  107193. */
  107194. freezeNormals(): Mesh;
  107195. /**
  107196. * 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
  107197. * @returns the current mesh
  107198. */
  107199. unfreezeNormals(): Mesh;
  107200. /**
  107201. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  107202. */
  107203. set overridenInstanceCount(count: number);
  107204. /** @hidden */
  107205. _preActivate(): Mesh;
  107206. /** @hidden */
  107207. _preActivateForIntermediateRendering(renderId: number): Mesh;
  107208. /** @hidden */
  107209. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  107210. protected _afterComputeWorldMatrix(): void;
  107211. /** @hidden */
  107212. _postActivate(): void;
  107213. /**
  107214. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  107215. * This means the mesh underlying bounding box and sphere are recomputed.
  107216. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  107217. * @returns the current mesh
  107218. */
  107219. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  107220. /** @hidden */
  107221. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  107222. /**
  107223. * This function will subdivide the mesh into multiple submeshes
  107224. * @param count defines the expected number of submeshes
  107225. */
  107226. subdivide(count: number): void;
  107227. /**
  107228. * Copy a FloatArray into a specific associated vertex buffer
  107229. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107230. * - VertexBuffer.PositionKind
  107231. * - VertexBuffer.UVKind
  107232. * - VertexBuffer.UV2Kind
  107233. * - VertexBuffer.UV3Kind
  107234. * - VertexBuffer.UV4Kind
  107235. * - VertexBuffer.UV5Kind
  107236. * - VertexBuffer.UV6Kind
  107237. * - VertexBuffer.ColorKind
  107238. * - VertexBuffer.MatricesIndicesKind
  107239. * - VertexBuffer.MatricesIndicesExtraKind
  107240. * - VertexBuffer.MatricesWeightsKind
  107241. * - VertexBuffer.MatricesWeightsExtraKind
  107242. * @param data defines the data source
  107243. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107244. * @param stride defines the data stride size (can be null)
  107245. * @returns the current mesh
  107246. */
  107247. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  107248. /**
  107249. * Delete a vertex buffer associated with this mesh
  107250. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  107251. * - VertexBuffer.PositionKind
  107252. * - VertexBuffer.UVKind
  107253. * - VertexBuffer.UV2Kind
  107254. * - VertexBuffer.UV3Kind
  107255. * - VertexBuffer.UV4Kind
  107256. * - VertexBuffer.UV5Kind
  107257. * - VertexBuffer.UV6Kind
  107258. * - VertexBuffer.ColorKind
  107259. * - VertexBuffer.MatricesIndicesKind
  107260. * - VertexBuffer.MatricesIndicesExtraKind
  107261. * - VertexBuffer.MatricesWeightsKind
  107262. * - VertexBuffer.MatricesWeightsExtraKind
  107263. */
  107264. removeVerticesData(kind: string): void;
  107265. /**
  107266. * Flags an associated vertex buffer as updatable
  107267. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  107268. * - VertexBuffer.PositionKind
  107269. * - VertexBuffer.UVKind
  107270. * - VertexBuffer.UV2Kind
  107271. * - VertexBuffer.UV3Kind
  107272. * - VertexBuffer.UV4Kind
  107273. * - VertexBuffer.UV5Kind
  107274. * - VertexBuffer.UV6Kind
  107275. * - VertexBuffer.ColorKind
  107276. * - VertexBuffer.MatricesIndicesKind
  107277. * - VertexBuffer.MatricesIndicesExtraKind
  107278. * - VertexBuffer.MatricesWeightsKind
  107279. * - VertexBuffer.MatricesWeightsExtraKind
  107280. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107281. */
  107282. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  107283. /**
  107284. * Sets the mesh global Vertex Buffer
  107285. * @param buffer defines the buffer to use
  107286. * @returns the current mesh
  107287. */
  107288. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  107289. /**
  107290. * Update a specific associated vertex buffer
  107291. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107292. * - VertexBuffer.PositionKind
  107293. * - VertexBuffer.UVKind
  107294. * - VertexBuffer.UV2Kind
  107295. * - VertexBuffer.UV3Kind
  107296. * - VertexBuffer.UV4Kind
  107297. * - VertexBuffer.UV5Kind
  107298. * - VertexBuffer.UV6Kind
  107299. * - VertexBuffer.ColorKind
  107300. * - VertexBuffer.MatricesIndicesKind
  107301. * - VertexBuffer.MatricesIndicesExtraKind
  107302. * - VertexBuffer.MatricesWeightsKind
  107303. * - VertexBuffer.MatricesWeightsExtraKind
  107304. * @param data defines the data source
  107305. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  107306. * @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)
  107307. * @returns the current mesh
  107308. */
  107309. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  107310. /**
  107311. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  107312. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  107313. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  107314. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  107315. * @returns the current mesh
  107316. */
  107317. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  107318. /**
  107319. * Creates a un-shared specific occurence of the geometry for the mesh.
  107320. * @returns the current mesh
  107321. */
  107322. makeGeometryUnique(): Mesh;
  107323. /**
  107324. * Set the index buffer of this mesh
  107325. * @param indices defines the source data
  107326. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  107327. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  107328. * @returns the current mesh
  107329. */
  107330. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  107331. /**
  107332. * Update the current index buffer
  107333. * @param indices defines the source data
  107334. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  107335. * @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)
  107336. * @returns the current mesh
  107337. */
  107338. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  107339. /**
  107340. * Invert the geometry to move from a right handed system to a left handed one.
  107341. * @returns the current mesh
  107342. */
  107343. toLeftHanded(): Mesh;
  107344. /** @hidden */
  107345. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  107346. /** @hidden */
  107347. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  107348. /**
  107349. * Registers for this mesh a javascript function called just before the rendering process
  107350. * @param func defines the function to call before rendering this mesh
  107351. * @returns the current mesh
  107352. */
  107353. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107354. /**
  107355. * Disposes a previously registered javascript function called before the rendering
  107356. * @param func defines the function to remove
  107357. * @returns the current mesh
  107358. */
  107359. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107360. /**
  107361. * Registers for this mesh a javascript function called just after the rendering is complete
  107362. * @param func defines the function to call after rendering this mesh
  107363. * @returns the current mesh
  107364. */
  107365. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107366. /**
  107367. * Disposes a previously registered javascript function called after the rendering.
  107368. * @param func defines the function to remove
  107369. * @returns the current mesh
  107370. */
  107371. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107372. /** @hidden */
  107373. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107374. /** @hidden */
  107375. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107376. /** @hidden */
  107377. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107378. /** @hidden */
  107379. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107380. /** @hidden */
  107381. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107382. /** @hidden */
  107383. _rebuild(): void;
  107384. /** @hidden */
  107385. _freeze(): void;
  107386. /** @hidden */
  107387. _unFreeze(): void;
  107388. /**
  107389. * 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
  107390. * @param subMesh defines the subMesh to render
  107391. * @param enableAlphaMode defines if alpha mode can be changed
  107392. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107393. * @returns the current mesh
  107394. */
  107395. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107396. private _onBeforeDraw;
  107397. /**
  107398. * Renormalize the mesh and patch it up if there are no weights
  107399. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107400. * However in the case of zero weights then we set just a single influence to 1.
  107401. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107402. */
  107403. cleanMatrixWeights(): void;
  107404. private normalizeSkinFourWeights;
  107405. private normalizeSkinWeightsAndExtra;
  107406. /**
  107407. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107408. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107409. * the user know there was an issue with importing the mesh
  107410. * @returns a validation object with skinned, valid and report string
  107411. */
  107412. validateSkinning(): {
  107413. skinned: boolean;
  107414. valid: boolean;
  107415. report: string;
  107416. };
  107417. /** @hidden */
  107418. _checkDelayState(): Mesh;
  107419. private _queueLoad;
  107420. /**
  107421. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  107422. * A mesh is in the frustum if its bounding box intersects the frustum
  107423. * @param frustumPlanes defines the frustum to test
  107424. * @returns true if the mesh is in the frustum planes
  107425. */
  107426. isInFrustum(frustumPlanes: Plane[]): boolean;
  107427. /**
  107428. * Sets the mesh material by the material or multiMaterial `id` property
  107429. * @param id is a string identifying the material or the multiMaterial
  107430. * @returns the current mesh
  107431. */
  107432. setMaterialByID(id: string): Mesh;
  107433. /**
  107434. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  107435. * @returns an array of IAnimatable
  107436. */
  107437. getAnimatables(): IAnimatable[];
  107438. /**
  107439. * Modifies the mesh geometry according to the passed transformation matrix.
  107440. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  107441. * The mesh normals are modified using the same transformation.
  107442. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107443. * @param transform defines the transform matrix to use
  107444. * @see https://doc.babylonjs.com/resources/baking_transformations
  107445. * @returns the current mesh
  107446. */
  107447. bakeTransformIntoVertices(transform: Matrix): Mesh;
  107448. /**
  107449. * Modifies the mesh geometry according to its own current World Matrix.
  107450. * The mesh World Matrix is then reset.
  107451. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  107452. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107453. * @see https://doc.babylonjs.com/resources/baking_transformations
  107454. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  107455. * @returns the current mesh
  107456. */
  107457. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  107458. /** @hidden */
  107459. get _positions(): Nullable<Vector3[]>;
  107460. /** @hidden */
  107461. _resetPointsArrayCache(): Mesh;
  107462. /** @hidden */
  107463. _generatePointsArray(): boolean;
  107464. /**
  107465. * Returns a new Mesh object generated from the current mesh properties.
  107466. * This method must not get confused with createInstance()
  107467. * @param name is a string, the name given to the new mesh
  107468. * @param newParent can be any Node object (default `null`)
  107469. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  107470. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  107471. * @returns a new mesh
  107472. */
  107473. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  107474. /**
  107475. * Releases resources associated with this mesh.
  107476. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107477. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107478. */
  107479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107480. /** @hidden */
  107481. _disposeInstanceSpecificData(): void;
  107482. /** @hidden */
  107483. _disposeThinInstanceSpecificData(): void;
  107484. /**
  107485. * Modifies the mesh geometry according to a displacement map.
  107486. * 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.
  107487. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107488. * @param url is a string, the URL from the image file is to be downloaded.
  107489. * @param minHeight is the lower limit of the displacement.
  107490. * @param maxHeight is the upper limit of the displacement.
  107491. * @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.
  107492. * @param uvOffset is an optional vector2 used to offset UV.
  107493. * @param uvScale is an optional vector2 used to scale UV.
  107494. * @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.
  107495. * @returns the Mesh.
  107496. */
  107497. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107498. /**
  107499. * Modifies the mesh geometry according to a displacementMap buffer.
  107500. * 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.
  107501. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107502. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  107503. * @param heightMapWidth is the width of the buffer image.
  107504. * @param heightMapHeight is the height of the buffer image.
  107505. * @param minHeight is the lower limit of the displacement.
  107506. * @param maxHeight is the upper limit of the displacement.
  107507. * @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.
  107508. * @param uvOffset is an optional vector2 used to offset UV.
  107509. * @param uvScale is an optional vector2 used to scale UV.
  107510. * @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.
  107511. * @returns the Mesh.
  107512. */
  107513. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107514. /**
  107515. * Modify the mesh to get a flat shading rendering.
  107516. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  107517. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  107518. * @returns current mesh
  107519. */
  107520. convertToFlatShadedMesh(): Mesh;
  107521. /**
  107522. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  107523. * In other words, more vertices, no more indices and a single bigger VBO.
  107524. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  107525. * @returns current mesh
  107526. */
  107527. convertToUnIndexedMesh(): Mesh;
  107528. /**
  107529. * Inverses facet orientations.
  107530. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107531. * @param flipNormals will also inverts the normals
  107532. * @returns current mesh
  107533. */
  107534. flipFaces(flipNormals?: boolean): Mesh;
  107535. /**
  107536. * Increase the number of facets and hence vertices in a mesh
  107537. * Vertex normals are interpolated from existing vertex normals
  107538. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107539. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  107540. */
  107541. increaseVertices(numberPerEdge: number): void;
  107542. /**
  107543. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  107544. * This will undo any application of covertToFlatShadedMesh
  107545. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107546. */
  107547. forceSharedVertices(): void;
  107548. /** @hidden */
  107549. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  107550. /** @hidden */
  107551. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  107552. /**
  107553. * Creates a new InstancedMesh object from the mesh model.
  107554. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107555. * @param name defines the name of the new instance
  107556. * @returns a new InstancedMesh
  107557. */
  107558. createInstance(name: string): InstancedMesh;
  107559. /**
  107560. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  107561. * After this call, all the mesh instances have the same submeshes than the current mesh.
  107562. * @returns the current mesh
  107563. */
  107564. synchronizeInstances(): Mesh;
  107565. /**
  107566. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  107567. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  107568. * This should be used together with the simplification to avoid disappearing triangles.
  107569. * @param successCallback an optional success callback to be called after the optimization finished.
  107570. * @returns the current mesh
  107571. */
  107572. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  107573. /**
  107574. * Serialize current mesh
  107575. * @param serializationObject defines the object which will receive the serialization data
  107576. */
  107577. serialize(serializationObject: any): void;
  107578. /** @hidden */
  107579. _syncGeometryWithMorphTargetManager(): void;
  107580. /** @hidden */
  107581. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  107582. /**
  107583. * Returns a new Mesh object parsed from the source provided.
  107584. * @param parsedMesh is the source
  107585. * @param scene defines the hosting scene
  107586. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  107587. * @returns a new Mesh
  107588. */
  107589. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  107590. /**
  107591. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  107592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107593. * @param name defines the name of the mesh to create
  107594. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  107595. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  107596. * @param closePath creates a seam between the first and the last points of each path of the path array
  107597. * @param offset is taken in account only if the `pathArray` is containing a single path
  107598. * @param scene defines the hosting scene
  107599. * @param updatable defines if the mesh must be flagged as updatable
  107600. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107601. * @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)
  107602. * @returns a new Mesh
  107603. */
  107604. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107605. /**
  107606. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  107607. * @param name defines the name of the mesh to create
  107608. * @param radius sets the radius size (float) of the polygon (default 0.5)
  107609. * @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
  107610. * @param scene defines the hosting scene
  107611. * @param updatable defines if the mesh must be flagged as updatable
  107612. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107613. * @returns a new Mesh
  107614. */
  107615. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107616. /**
  107617. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  107618. * @param name defines the name of the mesh to create
  107619. * @param size sets the size (float) of each box side (default 1)
  107620. * @param scene defines the hosting scene
  107621. * @param updatable defines if the mesh must be flagged as updatable
  107622. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107623. * @returns a new Mesh
  107624. */
  107625. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107626. /**
  107627. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  107628. * @param name defines the name of the mesh to create
  107629. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107630. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107631. * @param scene defines the hosting scene
  107632. * @param updatable defines if the mesh must be flagged as updatable
  107633. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107634. * @returns a new Mesh
  107635. */
  107636. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107637. /**
  107638. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  107639. * @param name defines the name of the mesh to create
  107640. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107641. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107642. * @param scene defines the hosting scene
  107643. * @returns a new Mesh
  107644. */
  107645. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  107646. /**
  107647. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  107648. * @param name defines the name of the mesh to create
  107649. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  107650. * @param diameterTop set the top cap diameter (floats, default 1)
  107651. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  107652. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  107653. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  107654. * @param scene defines the hosting scene
  107655. * @param updatable defines if the mesh must be flagged as updatable
  107656. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107657. * @returns a new Mesh
  107658. */
  107659. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  107660. /**
  107661. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  107662. * @param name defines the name of the mesh to create
  107663. * @param diameter sets the diameter size (float) of the torus (default 1)
  107664. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  107665. * @param tessellation sets the number of torus sides (postive integer, default 16)
  107666. * @param scene defines the hosting scene
  107667. * @param updatable defines if the mesh must be flagged as updatable
  107668. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107669. * @returns a new Mesh
  107670. */
  107671. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107672. /**
  107673. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  107674. * @param name defines the name of the mesh to create
  107675. * @param radius sets the global radius size (float) of the torus knot (default 2)
  107676. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  107677. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  107678. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  107679. * @param p the number of windings on X axis (positive integers, default 2)
  107680. * @param q the number of windings on Y axis (positive integers, default 3)
  107681. * @param scene defines the hosting scene
  107682. * @param updatable defines if the mesh must be flagged as updatable
  107683. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107684. * @returns a new Mesh
  107685. */
  107686. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107687. /**
  107688. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  107689. * @param name defines the name of the mesh to create
  107690. * @param points is an array successive Vector3
  107691. * @param scene defines the hosting scene
  107692. * @param updatable defines if the mesh must be flagged as updatable
  107693. * @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).
  107694. * @returns a new Mesh
  107695. */
  107696. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  107697. /**
  107698. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  107699. * @param name defines the name of the mesh to create
  107700. * @param points is an array successive Vector3
  107701. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  107702. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107703. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  107704. * @param scene defines the hosting scene
  107705. * @param updatable defines if the mesh must be flagged as updatable
  107706. * @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)
  107707. * @returns a new Mesh
  107708. */
  107709. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  107710. /**
  107711. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  107712. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  107713. * 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.
  107714. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107715. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107716. * Remember you can only change the shape positions, not their number when updating a polygon.
  107717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107718. * @param name defines the name of the mesh to create
  107719. * @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
  107720. * @param scene defines the hosting scene
  107721. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107722. * @param updatable defines if the mesh must be flagged as updatable
  107723. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107724. * @param earcutInjection can be used to inject your own earcut reference
  107725. * @returns a new Mesh
  107726. */
  107727. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107728. /**
  107729. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  107730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  107731. * @param name defines the name of the mesh to create
  107732. * @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
  107733. * @param depth defines the height of extrusion
  107734. * @param scene defines the hosting scene
  107735. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107736. * @param updatable defines if the mesh must be flagged as updatable
  107737. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107738. * @param earcutInjection can be used to inject your own earcut reference
  107739. * @returns a new Mesh
  107740. */
  107741. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107742. /**
  107743. * Creates an extruded shape mesh.
  107744. * 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
  107745. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107747. * @param name defines the name of the mesh to create
  107748. * @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
  107749. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107750. * @param scale is the value to scale the shape
  107751. * @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
  107752. * @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
  107753. * @param scene defines the hosting scene
  107754. * @param updatable defines if the mesh must be flagged as updatable
  107755. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107756. * @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)
  107757. * @returns a new Mesh
  107758. */
  107759. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107760. /**
  107761. * Creates an custom extruded shape mesh.
  107762. * The custom extrusion is a parametric shape.
  107763. * It has no predefined shape. Its final shape will depend on the input parameters.
  107764. * Please consider using the same method from the MeshBuilder class instead
  107765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107766. * @param name defines the name of the mesh to create
  107767. * @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
  107768. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107769. * @param scaleFunction is a custom Javascript function called on each path point
  107770. * @param rotationFunction is a custom Javascript function called on each path point
  107771. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107772. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  107773. * @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
  107774. * @param scene defines the hosting scene
  107775. * @param updatable defines if the mesh must be flagged as updatable
  107776. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107777. * @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)
  107778. * @returns a new Mesh
  107779. */
  107780. 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;
  107781. /**
  107782. * Creates lathe mesh.
  107783. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  107784. * Please consider using the same method from the MeshBuilder class instead
  107785. * @param name defines the name of the mesh to create
  107786. * @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
  107787. * @param radius is the radius value of the lathe
  107788. * @param tessellation is the side number of the lathe.
  107789. * @param scene defines the hosting scene
  107790. * @param updatable defines if the mesh must be flagged as updatable
  107791. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107792. * @returns a new Mesh
  107793. */
  107794. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107795. /**
  107796. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  107797. * @param name defines the name of the mesh to create
  107798. * @param size sets the size (float) of both sides of the plane at once (default 1)
  107799. * @param scene defines the hosting scene
  107800. * @param updatable defines if the mesh must be flagged as updatable
  107801. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107802. * @returns a new Mesh
  107803. */
  107804. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107805. /**
  107806. * Creates a ground mesh.
  107807. * Please consider using the same method from the MeshBuilder class instead
  107808. * @param name defines the name of the mesh to create
  107809. * @param width set the width of the ground
  107810. * @param height set the height of the ground
  107811. * @param subdivisions sets the number of subdivisions per side
  107812. * @param scene defines the hosting scene
  107813. * @param updatable defines if the mesh must be flagged as updatable
  107814. * @returns a new Mesh
  107815. */
  107816. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  107817. /**
  107818. * Creates a tiled ground mesh.
  107819. * Please consider using the same method from the MeshBuilder class instead
  107820. * @param name defines the name of the mesh to create
  107821. * @param xmin set the ground minimum X coordinate
  107822. * @param zmin set the ground minimum Y coordinate
  107823. * @param xmax set the ground maximum X coordinate
  107824. * @param zmax set the ground maximum Z coordinate
  107825. * @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
  107826. * @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
  107827. * @param scene defines the hosting scene
  107828. * @param updatable defines if the mesh must be flagged as updatable
  107829. * @returns a new Mesh
  107830. */
  107831. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  107832. w: number;
  107833. h: number;
  107834. }, precision: {
  107835. w: number;
  107836. h: number;
  107837. }, scene: Scene, updatable?: boolean): Mesh;
  107838. /**
  107839. * Creates a ground mesh from a height map.
  107840. * Please consider using the same method from the MeshBuilder class instead
  107841. * @see https://doc.babylonjs.com/babylon101/height_map
  107842. * @param name defines the name of the mesh to create
  107843. * @param url sets the URL of the height map image resource
  107844. * @param width set the ground width size
  107845. * @param height set the ground height size
  107846. * @param subdivisions sets the number of subdivision per side
  107847. * @param minHeight is the minimum altitude on the ground
  107848. * @param maxHeight is the maximum altitude on the ground
  107849. * @param scene defines the hosting scene
  107850. * @param updatable defines if the mesh must be flagged as updatable
  107851. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  107852. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107853. * @returns a new Mesh
  107854. */
  107855. 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;
  107856. /**
  107857. * Creates a tube mesh.
  107858. * The tube is a parametric shape.
  107859. * It has no predefined shape. Its final shape will depend on the input parameters.
  107860. * Please consider using the same method from the MeshBuilder class instead
  107861. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107862. * @param name defines the name of the mesh to create
  107863. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  107864. * @param radius sets the tube radius size
  107865. * @param tessellation is the number of sides on the tubular surface
  107866. * @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
  107867. * @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
  107868. * @param scene defines the hosting scene
  107869. * @param updatable defines if the mesh must be flagged as updatable
  107870. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107871. * @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)
  107872. * @returns a new Mesh
  107873. */
  107874. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  107875. (i: number, distance: number): number;
  107876. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107877. /**
  107878. * Creates a polyhedron mesh.
  107879. * Please consider using the same method from the MeshBuilder class instead.
  107880. * * 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
  107881. * * The parameter `size` (positive float, default 1) sets the polygon size
  107882. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107883. * * 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`
  107884. * * 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
  107885. * * 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)`)
  107886. * * 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
  107887. * * 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
  107888. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107891. * @param name defines the name of the mesh to create
  107892. * @param options defines the options used to create the mesh
  107893. * @param scene defines the hosting scene
  107894. * @returns a new Mesh
  107895. */
  107896. static CreatePolyhedron(name: string, options: {
  107897. type?: number;
  107898. size?: number;
  107899. sizeX?: number;
  107900. sizeY?: number;
  107901. sizeZ?: number;
  107902. custom?: any;
  107903. faceUV?: Vector4[];
  107904. faceColors?: Color4[];
  107905. updatable?: boolean;
  107906. sideOrientation?: number;
  107907. }, scene: Scene): Mesh;
  107908. /**
  107909. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107910. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107911. * * 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`)
  107912. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107913. * * 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
  107914. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107917. * @param name defines the name of the mesh
  107918. * @param options defines the options used to create the mesh
  107919. * @param scene defines the hosting scene
  107920. * @returns a new Mesh
  107921. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107922. */
  107923. static CreateIcoSphere(name: string, options: {
  107924. radius?: number;
  107925. flat?: boolean;
  107926. subdivisions?: number;
  107927. sideOrientation?: number;
  107928. updatable?: boolean;
  107929. }, scene: Scene): Mesh;
  107930. /**
  107931. * Creates a decal mesh.
  107932. * Please consider using the same method from the MeshBuilder class instead.
  107933. * A decal is a mesh usually applied as a model onto the surface of another mesh
  107934. * @param name defines the name of the mesh
  107935. * @param sourceMesh defines the mesh receiving the decal
  107936. * @param position sets the position of the decal in world coordinates
  107937. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  107938. * @param size sets the decal scaling
  107939. * @param angle sets the angle to rotate the decal
  107940. * @returns a new Mesh
  107941. */
  107942. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  107943. /**
  107944. * Prepare internal position array for software CPU skinning
  107945. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  107946. */
  107947. setPositionsForCPUSkinning(): Float32Array;
  107948. /**
  107949. * Prepare internal normal array for software CPU skinning
  107950. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  107951. */
  107952. setNormalsForCPUSkinning(): Float32Array;
  107953. /**
  107954. * Updates the vertex buffer by applying transformation from the bones
  107955. * @param skeleton defines the skeleton to apply to current mesh
  107956. * @returns the current mesh
  107957. */
  107958. applySkeleton(skeleton: Skeleton): Mesh;
  107959. /**
  107960. * 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
  107961. * @param meshes defines the list of meshes to scan
  107962. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  107963. */
  107964. static MinMax(meshes: AbstractMesh[]): {
  107965. min: Vector3;
  107966. max: Vector3;
  107967. };
  107968. /**
  107969. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  107970. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  107971. * @returns a vector3
  107972. */
  107973. static Center(meshesOrMinMaxVector: {
  107974. min: Vector3;
  107975. max: Vector3;
  107976. } | AbstractMesh[]): Vector3;
  107977. /**
  107978. * Merge the array of meshes into a single mesh for performance reasons.
  107979. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  107980. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  107981. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  107982. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  107983. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  107984. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  107985. * @returns a new mesh
  107986. */
  107987. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  107988. /** @hidden */
  107989. addInstance(instance: InstancedMesh): void;
  107990. /** @hidden */
  107991. removeInstance(instance: InstancedMesh): void;
  107992. }
  107993. }
  107994. declare module BABYLON {
  107995. /**
  107996. * This is the base class of all the camera used in the application.
  107997. * @see https://doc.babylonjs.com/features/cameras
  107998. */
  107999. export class Camera extends Node {
  108000. /** @hidden */
  108001. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  108002. /**
  108003. * This is the default projection mode used by the cameras.
  108004. * It helps recreating a feeling of perspective and better appreciate depth.
  108005. * This is the best way to simulate real life cameras.
  108006. */
  108007. static readonly PERSPECTIVE_CAMERA: number;
  108008. /**
  108009. * This helps creating camera with an orthographic mode.
  108010. * 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.
  108011. */
  108012. static readonly ORTHOGRAPHIC_CAMERA: number;
  108013. /**
  108014. * This is the default FOV mode for perspective cameras.
  108015. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  108016. */
  108017. static readonly FOVMODE_VERTICAL_FIXED: number;
  108018. /**
  108019. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  108020. */
  108021. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  108022. /**
  108023. * This specifies ther is no need for a camera rig.
  108024. * Basically only one eye is rendered corresponding to the camera.
  108025. */
  108026. static readonly RIG_MODE_NONE: number;
  108027. /**
  108028. * Simulates a camera Rig with one blue eye and one red eye.
  108029. * This can be use with 3d blue and red glasses.
  108030. */
  108031. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  108032. /**
  108033. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  108034. */
  108035. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  108036. /**
  108037. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  108038. */
  108039. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  108040. /**
  108041. * Defines that both eyes of the camera will be rendered over under each other.
  108042. */
  108043. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  108044. /**
  108045. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  108046. */
  108047. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  108048. /**
  108049. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  108050. */
  108051. static readonly RIG_MODE_VR: number;
  108052. /**
  108053. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  108054. */
  108055. static readonly RIG_MODE_WEBVR: number;
  108056. /**
  108057. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  108058. */
  108059. static readonly RIG_MODE_CUSTOM: number;
  108060. /**
  108061. * Defines if by default attaching controls should prevent the default javascript event to continue.
  108062. */
  108063. static ForceAttachControlToAlwaysPreventDefault: boolean;
  108064. /**
  108065. * Define the input manager associated with the camera.
  108066. */
  108067. inputs: CameraInputsManager<Camera>;
  108068. /** @hidden */
  108069. _position: Vector3;
  108070. /**
  108071. * Define the current local position of the camera in the scene
  108072. */
  108073. get position(): Vector3;
  108074. set position(newPosition: Vector3);
  108075. /**
  108076. * The vector the camera should consider as up.
  108077. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  108078. */
  108079. upVector: Vector3;
  108080. /**
  108081. * Define the current limit on the left side for an orthographic camera
  108082. * In scene unit
  108083. */
  108084. orthoLeft: Nullable<number>;
  108085. /**
  108086. * Define the current limit on the right side for an orthographic camera
  108087. * In scene unit
  108088. */
  108089. orthoRight: Nullable<number>;
  108090. /**
  108091. * Define the current limit on the bottom side for an orthographic camera
  108092. * In scene unit
  108093. */
  108094. orthoBottom: Nullable<number>;
  108095. /**
  108096. * Define the current limit on the top side for an orthographic camera
  108097. * In scene unit
  108098. */
  108099. orthoTop: Nullable<number>;
  108100. /**
  108101. * Field Of View is set in Radians. (default is 0.8)
  108102. */
  108103. fov: number;
  108104. /**
  108105. * Define the minimum distance the camera can see from.
  108106. * This is important to note that the depth buffer are not infinite and the closer it starts
  108107. * the more your scene might encounter depth fighting issue.
  108108. */
  108109. minZ: number;
  108110. /**
  108111. * Define the maximum distance the camera can see to.
  108112. * This is important to note that the depth buffer are not infinite and the further it end
  108113. * the more your scene might encounter depth fighting issue.
  108114. */
  108115. maxZ: number;
  108116. /**
  108117. * Define the default inertia of the camera.
  108118. * This helps giving a smooth feeling to the camera movement.
  108119. */
  108120. inertia: number;
  108121. /**
  108122. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  108123. */
  108124. mode: number;
  108125. /**
  108126. * Define whether the camera is intermediate.
  108127. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  108128. */
  108129. isIntermediate: boolean;
  108130. /**
  108131. * Define the viewport of the camera.
  108132. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  108133. */
  108134. viewport: Viewport;
  108135. /**
  108136. * Restricts the camera to viewing objects with the same layerMask.
  108137. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  108138. */
  108139. layerMask: number;
  108140. /**
  108141. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  108142. */
  108143. fovMode: number;
  108144. /**
  108145. * Rig mode of the camera.
  108146. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  108147. * This is normally controlled byt the camera themselves as internal use.
  108148. */
  108149. cameraRigMode: number;
  108150. /**
  108151. * Defines the distance between both "eyes" in case of a RIG
  108152. */
  108153. interaxialDistance: number;
  108154. /**
  108155. * Defines if stereoscopic rendering is done side by side or over under.
  108156. */
  108157. isStereoscopicSideBySide: boolean;
  108158. /**
  108159. * 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
  108160. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  108161. * else in the scene. (Eg. security camera)
  108162. *
  108163. * 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)
  108164. */
  108165. customRenderTargets: RenderTargetTexture[];
  108166. /**
  108167. * When set, the camera will render to this render target instead of the default canvas
  108168. *
  108169. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  108170. */
  108171. outputRenderTarget: Nullable<RenderTargetTexture>;
  108172. /**
  108173. * Observable triggered when the camera view matrix has changed.
  108174. */
  108175. onViewMatrixChangedObservable: Observable<Camera>;
  108176. /**
  108177. * Observable triggered when the camera Projection matrix has changed.
  108178. */
  108179. onProjectionMatrixChangedObservable: Observable<Camera>;
  108180. /**
  108181. * Observable triggered when the inputs have been processed.
  108182. */
  108183. onAfterCheckInputsObservable: Observable<Camera>;
  108184. /**
  108185. * Observable triggered when reset has been called and applied to the camera.
  108186. */
  108187. onRestoreStateObservable: Observable<Camera>;
  108188. /**
  108189. * Is this camera a part of a rig system?
  108190. */
  108191. isRigCamera: boolean;
  108192. /**
  108193. * If isRigCamera set to true this will be set with the parent camera.
  108194. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  108195. */
  108196. rigParent?: Camera;
  108197. /** @hidden */
  108198. _cameraRigParams: any;
  108199. /** @hidden */
  108200. _rigCameras: Camera[];
  108201. /** @hidden */
  108202. _rigPostProcess: Nullable<PostProcess>;
  108203. protected _webvrViewMatrix: Matrix;
  108204. /** @hidden */
  108205. _skipRendering: boolean;
  108206. /** @hidden */
  108207. _projectionMatrix: Matrix;
  108208. /** @hidden */
  108209. _postProcesses: Nullable<PostProcess>[];
  108210. /** @hidden */
  108211. _activeMeshes: SmartArray<AbstractMesh>;
  108212. protected _globalPosition: Vector3;
  108213. /** @hidden */
  108214. _computedViewMatrix: Matrix;
  108215. private _doNotComputeProjectionMatrix;
  108216. private _transformMatrix;
  108217. private _frustumPlanes;
  108218. private _refreshFrustumPlanes;
  108219. private _storedFov;
  108220. private _stateStored;
  108221. /**
  108222. * Instantiates a new camera object.
  108223. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  108224. * @see https://doc.babylonjs.com/features/cameras
  108225. * @param name Defines the name of the camera in the scene
  108226. * @param position Defines the position of the camera
  108227. * @param scene Defines the scene the camera belongs too
  108228. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  108229. */
  108230. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108231. /**
  108232. * Store current camera state (fov, position, etc..)
  108233. * @returns the camera
  108234. */
  108235. storeState(): Camera;
  108236. /**
  108237. * Restores the camera state values if it has been stored. You must call storeState() first
  108238. */
  108239. protected _restoreStateValues(): boolean;
  108240. /**
  108241. * Restored camera state. You must call storeState() first.
  108242. * @returns true if restored and false otherwise
  108243. */
  108244. restoreState(): boolean;
  108245. /**
  108246. * Gets the class name of the camera.
  108247. * @returns the class name
  108248. */
  108249. getClassName(): string;
  108250. /** @hidden */
  108251. readonly _isCamera: boolean;
  108252. /**
  108253. * Gets a string representation of the camera useful for debug purpose.
  108254. * @param fullDetails Defines that a more verboe level of logging is required
  108255. * @returns the string representation
  108256. */
  108257. toString(fullDetails?: boolean): string;
  108258. /**
  108259. * Gets the current world space position of the camera.
  108260. */
  108261. get globalPosition(): Vector3;
  108262. /**
  108263. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  108264. * @returns the active meshe list
  108265. */
  108266. getActiveMeshes(): SmartArray<AbstractMesh>;
  108267. /**
  108268. * Check whether a mesh is part of the current active mesh list of the camera
  108269. * @param mesh Defines the mesh to check
  108270. * @returns true if active, false otherwise
  108271. */
  108272. isActiveMesh(mesh: Mesh): boolean;
  108273. /**
  108274. * Is this camera ready to be used/rendered
  108275. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  108276. * @return true if the camera is ready
  108277. */
  108278. isReady(completeCheck?: boolean): boolean;
  108279. /** @hidden */
  108280. _initCache(): void;
  108281. /** @hidden */
  108282. _updateCache(ignoreParentClass?: boolean): void;
  108283. /** @hidden */
  108284. _isSynchronized(): boolean;
  108285. /** @hidden */
  108286. _isSynchronizedViewMatrix(): boolean;
  108287. /** @hidden */
  108288. _isSynchronizedProjectionMatrix(): boolean;
  108289. /**
  108290. * Attach the input controls to a specific dom element to get the input from.
  108291. * @param element Defines the element the controls should be listened from
  108292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108293. */
  108294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108295. /**
  108296. * Detach the current controls from the specified dom element.
  108297. * @param element Defines the element to stop listening the inputs from
  108298. */
  108299. detachControl(element: HTMLElement): void;
  108300. /**
  108301. * Update the camera state according to the different inputs gathered during the frame.
  108302. */
  108303. update(): void;
  108304. /** @hidden */
  108305. _checkInputs(): void;
  108306. /** @hidden */
  108307. get rigCameras(): Camera[];
  108308. /**
  108309. * Gets the post process used by the rig cameras
  108310. */
  108311. get rigPostProcess(): Nullable<PostProcess>;
  108312. /**
  108313. * Internal, gets the first post proces.
  108314. * @returns the first post process to be run on this camera.
  108315. */
  108316. _getFirstPostProcess(): Nullable<PostProcess>;
  108317. private _cascadePostProcessesToRigCams;
  108318. /**
  108319. * Attach a post process to the camera.
  108320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108321. * @param postProcess The post process to attach to the camera
  108322. * @param insertAt The position of the post process in case several of them are in use in the scene
  108323. * @returns the position the post process has been inserted at
  108324. */
  108325. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  108326. /**
  108327. * Detach a post process to the camera.
  108328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108329. * @param postProcess The post process to detach from the camera
  108330. */
  108331. detachPostProcess(postProcess: PostProcess): void;
  108332. /**
  108333. * Gets the current world matrix of the camera
  108334. */
  108335. getWorldMatrix(): Matrix;
  108336. /** @hidden */
  108337. _getViewMatrix(): Matrix;
  108338. /**
  108339. * Gets the current view matrix of the camera.
  108340. * @param force forces the camera to recompute the matrix without looking at the cached state
  108341. * @returns the view matrix
  108342. */
  108343. getViewMatrix(force?: boolean): Matrix;
  108344. /**
  108345. * Freeze the projection matrix.
  108346. * It will prevent the cache check of the camera projection compute and can speed up perf
  108347. * if no parameter of the camera are meant to change
  108348. * @param projection Defines manually a projection if necessary
  108349. */
  108350. freezeProjectionMatrix(projection?: Matrix): void;
  108351. /**
  108352. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  108353. */
  108354. unfreezeProjectionMatrix(): void;
  108355. /**
  108356. * Gets the current projection matrix of the camera.
  108357. * @param force forces the camera to recompute the matrix without looking at the cached state
  108358. * @returns the projection matrix
  108359. */
  108360. getProjectionMatrix(force?: boolean): Matrix;
  108361. /**
  108362. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  108363. * @returns a Matrix
  108364. */
  108365. getTransformationMatrix(): Matrix;
  108366. private _updateFrustumPlanes;
  108367. /**
  108368. * Checks if a cullable object (mesh...) is in the camera frustum
  108369. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108370. * @param target The object to check
  108371. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108372. * @returns true if the object is in frustum otherwise false
  108373. */
  108374. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108375. /**
  108376. * Checks if a cullable object (mesh...) is in the camera frustum
  108377. * Unlike isInFrustum this cheks the full bounding box
  108378. * @param target The object to check
  108379. * @returns true if the object is in frustum otherwise false
  108380. */
  108381. isCompletelyInFrustum(target: ICullable): boolean;
  108382. /**
  108383. * Gets a ray in the forward direction from the camera.
  108384. * @param length Defines the length of the ray to create
  108385. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108386. * @param origin Defines the start point of the ray which defaults to the camera position
  108387. * @returns the forward ray
  108388. */
  108389. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108390. /**
  108391. * Gets a ray in the forward direction from the camera.
  108392. * @param refRay the ray to (re)use when setting the values
  108393. * @param length Defines the length of the ray to create
  108394. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108395. * @param origin Defines the start point of the ray which defaults to the camera position
  108396. * @returns the forward ray
  108397. */
  108398. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108399. /**
  108400. * Releases resources associated with this node.
  108401. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108402. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108403. */
  108404. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108405. /** @hidden */
  108406. _isLeftCamera: boolean;
  108407. /**
  108408. * Gets the left camera of a rig setup in case of Rigged Camera
  108409. */
  108410. get isLeftCamera(): boolean;
  108411. /** @hidden */
  108412. _isRightCamera: boolean;
  108413. /**
  108414. * Gets the right camera of a rig setup in case of Rigged Camera
  108415. */
  108416. get isRightCamera(): boolean;
  108417. /**
  108418. * Gets the left camera of a rig setup in case of Rigged Camera
  108419. */
  108420. get leftCamera(): Nullable<FreeCamera>;
  108421. /**
  108422. * Gets the right camera of a rig setup in case of Rigged Camera
  108423. */
  108424. get rightCamera(): Nullable<FreeCamera>;
  108425. /**
  108426. * Gets the left camera target of a rig setup in case of Rigged Camera
  108427. * @returns the target position
  108428. */
  108429. getLeftTarget(): Nullable<Vector3>;
  108430. /**
  108431. * Gets the right camera target of a rig setup in case of Rigged Camera
  108432. * @returns the target position
  108433. */
  108434. getRightTarget(): Nullable<Vector3>;
  108435. /**
  108436. * @hidden
  108437. */
  108438. setCameraRigMode(mode: number, rigParams: any): void;
  108439. /** @hidden */
  108440. static _setStereoscopicRigMode(camera: Camera): void;
  108441. /** @hidden */
  108442. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  108443. /** @hidden */
  108444. static _setVRRigMode(camera: Camera, rigParams: any): void;
  108445. /** @hidden */
  108446. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  108447. /** @hidden */
  108448. _getVRProjectionMatrix(): Matrix;
  108449. protected _updateCameraRotationMatrix(): void;
  108450. protected _updateWebVRCameraRotationMatrix(): void;
  108451. /**
  108452. * This function MUST be overwritten by the different WebVR cameras available.
  108453. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108454. * @hidden
  108455. */
  108456. _getWebVRProjectionMatrix(): Matrix;
  108457. /**
  108458. * This function MUST be overwritten by the different WebVR cameras available.
  108459. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108460. * @hidden
  108461. */
  108462. _getWebVRViewMatrix(): Matrix;
  108463. /** @hidden */
  108464. setCameraRigParameter(name: string, value: any): void;
  108465. /**
  108466. * needs to be overridden by children so sub has required properties to be copied
  108467. * @hidden
  108468. */
  108469. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  108470. /**
  108471. * May need to be overridden by children
  108472. * @hidden
  108473. */
  108474. _updateRigCameras(): void;
  108475. /** @hidden */
  108476. _setupInputs(): void;
  108477. /**
  108478. * Serialiaze the camera setup to a json represention
  108479. * @returns the JSON representation
  108480. */
  108481. serialize(): any;
  108482. /**
  108483. * Clones the current camera.
  108484. * @param name The cloned camera name
  108485. * @returns the cloned camera
  108486. */
  108487. clone(name: string): Camera;
  108488. /**
  108489. * Gets the direction of the camera relative to a given local axis.
  108490. * @param localAxis Defines the reference axis to provide a relative direction.
  108491. * @return the direction
  108492. */
  108493. getDirection(localAxis: Vector3): Vector3;
  108494. /**
  108495. * Returns the current camera absolute rotation
  108496. */
  108497. get absoluteRotation(): Quaternion;
  108498. /**
  108499. * Gets the direction of the camera relative to a given local axis into a passed vector.
  108500. * @param localAxis Defines the reference axis to provide a relative direction.
  108501. * @param result Defines the vector to store the result in
  108502. */
  108503. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  108504. /**
  108505. * Gets a camera constructor for a given camera type
  108506. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  108507. * @param name The name of the camera the result will be able to instantiate
  108508. * @param scene The scene the result will construct the camera in
  108509. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  108510. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  108511. * @returns a factory method to construc the camera
  108512. */
  108513. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  108514. /**
  108515. * Compute the world matrix of the camera.
  108516. * @returns the camera world matrix
  108517. */
  108518. computeWorldMatrix(): Matrix;
  108519. /**
  108520. * Parse a JSON and creates the camera from the parsed information
  108521. * @param parsedCamera The JSON to parse
  108522. * @param scene The scene to instantiate the camera in
  108523. * @returns the newly constructed camera
  108524. */
  108525. static Parse(parsedCamera: any, scene: Scene): Camera;
  108526. }
  108527. }
  108528. declare module BABYLON {
  108529. /**
  108530. * Class containing static functions to help procedurally build meshes
  108531. */
  108532. export class DiscBuilder {
  108533. /**
  108534. * Creates a plane polygonal mesh. By default, this is a disc
  108535. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108536. * * 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
  108537. * * 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
  108538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108541. * @param name defines the name of the mesh
  108542. * @param options defines the options used to create the mesh
  108543. * @param scene defines the hosting scene
  108544. * @returns the plane polygonal mesh
  108545. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108546. */
  108547. static CreateDisc(name: string, options: {
  108548. radius?: number;
  108549. tessellation?: number;
  108550. arc?: number;
  108551. updatable?: boolean;
  108552. sideOrientation?: number;
  108553. frontUVs?: Vector4;
  108554. backUVs?: Vector4;
  108555. }, scene?: Nullable<Scene>): Mesh;
  108556. }
  108557. }
  108558. declare module BABYLON {
  108559. /**
  108560. * Options to be used when creating a FresnelParameters.
  108561. */
  108562. export type IFresnelParametersCreationOptions = {
  108563. /**
  108564. * Define the color used on edges (grazing angle)
  108565. */
  108566. leftColor?: Color3;
  108567. /**
  108568. * Define the color used on center
  108569. */
  108570. rightColor?: Color3;
  108571. /**
  108572. * Define bias applied to computed fresnel term
  108573. */
  108574. bias?: number;
  108575. /**
  108576. * Defined the power exponent applied to fresnel term
  108577. */
  108578. power?: number;
  108579. /**
  108580. * Define if the fresnel effect is enable or not.
  108581. */
  108582. isEnabled?: boolean;
  108583. };
  108584. /**
  108585. * Serialized format for FresnelParameters.
  108586. */
  108587. export type IFresnelParametersSerialized = {
  108588. /**
  108589. * Define the color used on edges (grazing angle) [as an array]
  108590. */
  108591. leftColor: number[];
  108592. /**
  108593. * Define the color used on center [as an array]
  108594. */
  108595. rightColor: number[];
  108596. /**
  108597. * Define bias applied to computed fresnel term
  108598. */
  108599. bias: number;
  108600. /**
  108601. * Defined the power exponent applied to fresnel term
  108602. */
  108603. power?: number;
  108604. /**
  108605. * Define if the fresnel effect is enable or not.
  108606. */
  108607. isEnabled: boolean;
  108608. };
  108609. /**
  108610. * This represents all the required information to add a fresnel effect on a material:
  108611. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108612. */
  108613. export class FresnelParameters {
  108614. private _isEnabled;
  108615. /**
  108616. * Define if the fresnel effect is enable or not.
  108617. */
  108618. get isEnabled(): boolean;
  108619. set isEnabled(value: boolean);
  108620. /**
  108621. * Define the color used on edges (grazing angle)
  108622. */
  108623. leftColor: Color3;
  108624. /**
  108625. * Define the color used on center
  108626. */
  108627. rightColor: Color3;
  108628. /**
  108629. * Define bias applied to computed fresnel term
  108630. */
  108631. bias: number;
  108632. /**
  108633. * Defined the power exponent applied to fresnel term
  108634. */
  108635. power: number;
  108636. /**
  108637. * Creates a new FresnelParameters object.
  108638. *
  108639. * @param options provide your own settings to optionally to override defaults
  108640. */
  108641. constructor(options?: IFresnelParametersCreationOptions);
  108642. /**
  108643. * Clones the current fresnel and its valuues
  108644. * @returns a clone fresnel configuration
  108645. */
  108646. clone(): FresnelParameters;
  108647. /**
  108648. * Determines equality between FresnelParameters objects
  108649. * @param otherFresnelParameters defines the second operand
  108650. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  108651. */
  108652. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  108653. /**
  108654. * Serializes the current fresnel parameters to a JSON representation.
  108655. * @return the JSON serialization
  108656. */
  108657. serialize(): IFresnelParametersSerialized;
  108658. /**
  108659. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  108660. * @param parsedFresnelParameters Define the JSON representation
  108661. * @returns the parsed parameters
  108662. */
  108663. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  108664. }
  108665. }
  108666. declare module BABYLON {
  108667. /**
  108668. * This groups all the flags used to control the materials channel.
  108669. */
  108670. export class MaterialFlags {
  108671. private static _DiffuseTextureEnabled;
  108672. /**
  108673. * Are diffuse textures enabled in the application.
  108674. */
  108675. static get DiffuseTextureEnabled(): boolean;
  108676. static set DiffuseTextureEnabled(value: boolean);
  108677. private static _DetailTextureEnabled;
  108678. /**
  108679. * Are detail textures enabled in the application.
  108680. */
  108681. static get DetailTextureEnabled(): boolean;
  108682. static set DetailTextureEnabled(value: boolean);
  108683. private static _AmbientTextureEnabled;
  108684. /**
  108685. * Are ambient textures enabled in the application.
  108686. */
  108687. static get AmbientTextureEnabled(): boolean;
  108688. static set AmbientTextureEnabled(value: boolean);
  108689. private static _OpacityTextureEnabled;
  108690. /**
  108691. * Are opacity textures enabled in the application.
  108692. */
  108693. static get OpacityTextureEnabled(): boolean;
  108694. static set OpacityTextureEnabled(value: boolean);
  108695. private static _ReflectionTextureEnabled;
  108696. /**
  108697. * Are reflection textures enabled in the application.
  108698. */
  108699. static get ReflectionTextureEnabled(): boolean;
  108700. static set ReflectionTextureEnabled(value: boolean);
  108701. private static _EmissiveTextureEnabled;
  108702. /**
  108703. * Are emissive textures enabled in the application.
  108704. */
  108705. static get EmissiveTextureEnabled(): boolean;
  108706. static set EmissiveTextureEnabled(value: boolean);
  108707. private static _SpecularTextureEnabled;
  108708. /**
  108709. * Are specular textures enabled in the application.
  108710. */
  108711. static get SpecularTextureEnabled(): boolean;
  108712. static set SpecularTextureEnabled(value: boolean);
  108713. private static _BumpTextureEnabled;
  108714. /**
  108715. * Are bump textures enabled in the application.
  108716. */
  108717. static get BumpTextureEnabled(): boolean;
  108718. static set BumpTextureEnabled(value: boolean);
  108719. private static _LightmapTextureEnabled;
  108720. /**
  108721. * Are lightmap textures enabled in the application.
  108722. */
  108723. static get LightmapTextureEnabled(): boolean;
  108724. static set LightmapTextureEnabled(value: boolean);
  108725. private static _RefractionTextureEnabled;
  108726. /**
  108727. * Are refraction textures enabled in the application.
  108728. */
  108729. static get RefractionTextureEnabled(): boolean;
  108730. static set RefractionTextureEnabled(value: boolean);
  108731. private static _ColorGradingTextureEnabled;
  108732. /**
  108733. * Are color grading textures enabled in the application.
  108734. */
  108735. static get ColorGradingTextureEnabled(): boolean;
  108736. static set ColorGradingTextureEnabled(value: boolean);
  108737. private static _FresnelEnabled;
  108738. /**
  108739. * Are fresnels enabled in the application.
  108740. */
  108741. static get FresnelEnabled(): boolean;
  108742. static set FresnelEnabled(value: boolean);
  108743. private static _ClearCoatTextureEnabled;
  108744. /**
  108745. * Are clear coat textures enabled in the application.
  108746. */
  108747. static get ClearCoatTextureEnabled(): boolean;
  108748. static set ClearCoatTextureEnabled(value: boolean);
  108749. private static _ClearCoatBumpTextureEnabled;
  108750. /**
  108751. * Are clear coat bump textures enabled in the application.
  108752. */
  108753. static get ClearCoatBumpTextureEnabled(): boolean;
  108754. static set ClearCoatBumpTextureEnabled(value: boolean);
  108755. private static _ClearCoatTintTextureEnabled;
  108756. /**
  108757. * Are clear coat tint textures enabled in the application.
  108758. */
  108759. static get ClearCoatTintTextureEnabled(): boolean;
  108760. static set ClearCoatTintTextureEnabled(value: boolean);
  108761. private static _SheenTextureEnabled;
  108762. /**
  108763. * Are sheen textures enabled in the application.
  108764. */
  108765. static get SheenTextureEnabled(): boolean;
  108766. static set SheenTextureEnabled(value: boolean);
  108767. private static _AnisotropicTextureEnabled;
  108768. /**
  108769. * Are anisotropic textures enabled in the application.
  108770. */
  108771. static get AnisotropicTextureEnabled(): boolean;
  108772. static set AnisotropicTextureEnabled(value: boolean);
  108773. private static _ThicknessTextureEnabled;
  108774. /**
  108775. * Are thickness textures enabled in the application.
  108776. */
  108777. static get ThicknessTextureEnabled(): boolean;
  108778. static set ThicknessTextureEnabled(value: boolean);
  108779. }
  108780. }
  108781. declare module BABYLON {
  108782. /** @hidden */
  108783. export var defaultFragmentDeclaration: {
  108784. name: string;
  108785. shader: string;
  108786. };
  108787. }
  108788. declare module BABYLON {
  108789. /** @hidden */
  108790. export var defaultUboDeclaration: {
  108791. name: string;
  108792. shader: string;
  108793. };
  108794. }
  108795. declare module BABYLON {
  108796. /** @hidden */
  108797. export var prePassDeclaration: {
  108798. name: string;
  108799. shader: string;
  108800. };
  108801. }
  108802. declare module BABYLON {
  108803. /** @hidden */
  108804. export var lightFragmentDeclaration: {
  108805. name: string;
  108806. shader: string;
  108807. };
  108808. }
  108809. declare module BABYLON {
  108810. /** @hidden */
  108811. export var lightUboDeclaration: {
  108812. name: string;
  108813. shader: string;
  108814. };
  108815. }
  108816. declare module BABYLON {
  108817. /** @hidden */
  108818. export var lightsFragmentFunctions: {
  108819. name: string;
  108820. shader: string;
  108821. };
  108822. }
  108823. declare module BABYLON {
  108824. /** @hidden */
  108825. export var shadowsFragmentFunctions: {
  108826. name: string;
  108827. shader: string;
  108828. };
  108829. }
  108830. declare module BABYLON {
  108831. /** @hidden */
  108832. export var fresnelFunction: {
  108833. name: string;
  108834. shader: string;
  108835. };
  108836. }
  108837. declare module BABYLON {
  108838. /** @hidden */
  108839. export var bumpFragmentMainFunctions: {
  108840. name: string;
  108841. shader: string;
  108842. };
  108843. }
  108844. declare module BABYLON {
  108845. /** @hidden */
  108846. export var bumpFragmentFunctions: {
  108847. name: string;
  108848. shader: string;
  108849. };
  108850. }
  108851. declare module BABYLON {
  108852. /** @hidden */
  108853. export var logDepthDeclaration: {
  108854. name: string;
  108855. shader: string;
  108856. };
  108857. }
  108858. declare module BABYLON {
  108859. /** @hidden */
  108860. export var bumpFragment: {
  108861. name: string;
  108862. shader: string;
  108863. };
  108864. }
  108865. declare module BABYLON {
  108866. /** @hidden */
  108867. export var depthPrePass: {
  108868. name: string;
  108869. shader: string;
  108870. };
  108871. }
  108872. declare module BABYLON {
  108873. /** @hidden */
  108874. export var lightFragment: {
  108875. name: string;
  108876. shader: string;
  108877. };
  108878. }
  108879. declare module BABYLON {
  108880. /** @hidden */
  108881. export var logDepthFragment: {
  108882. name: string;
  108883. shader: string;
  108884. };
  108885. }
  108886. declare module BABYLON {
  108887. /** @hidden */
  108888. export var defaultPixelShader: {
  108889. name: string;
  108890. shader: string;
  108891. };
  108892. }
  108893. declare module BABYLON {
  108894. /** @hidden */
  108895. export var defaultVertexDeclaration: {
  108896. name: string;
  108897. shader: string;
  108898. };
  108899. }
  108900. declare module BABYLON {
  108901. /** @hidden */
  108902. export var bumpVertexDeclaration: {
  108903. name: string;
  108904. shader: string;
  108905. };
  108906. }
  108907. declare module BABYLON {
  108908. /** @hidden */
  108909. export var bumpVertex: {
  108910. name: string;
  108911. shader: string;
  108912. };
  108913. }
  108914. declare module BABYLON {
  108915. /** @hidden */
  108916. export var fogVertex: {
  108917. name: string;
  108918. shader: string;
  108919. };
  108920. }
  108921. declare module BABYLON {
  108922. /** @hidden */
  108923. export var shadowsVertex: {
  108924. name: string;
  108925. shader: string;
  108926. };
  108927. }
  108928. declare module BABYLON {
  108929. /** @hidden */
  108930. export var pointCloudVertex: {
  108931. name: string;
  108932. shader: string;
  108933. };
  108934. }
  108935. declare module BABYLON {
  108936. /** @hidden */
  108937. export var logDepthVertex: {
  108938. name: string;
  108939. shader: string;
  108940. };
  108941. }
  108942. declare module BABYLON {
  108943. /** @hidden */
  108944. export var defaultVertexShader: {
  108945. name: string;
  108946. shader: string;
  108947. };
  108948. }
  108949. declare module BABYLON {
  108950. /**
  108951. * @hidden
  108952. */
  108953. export interface IMaterialDetailMapDefines {
  108954. DETAIL: boolean;
  108955. DETAILDIRECTUV: number;
  108956. DETAIL_NORMALBLENDMETHOD: number;
  108957. /** @hidden */
  108958. _areTexturesDirty: boolean;
  108959. }
  108960. /**
  108961. * Define the code related to the detail map parameters of a material
  108962. *
  108963. * Inspired from:
  108964. * 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
  108965. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  108966. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  108967. */
  108968. export class DetailMapConfiguration {
  108969. private _texture;
  108970. /**
  108971. * The detail texture of the material.
  108972. */
  108973. texture: Nullable<BaseTexture>;
  108974. /**
  108975. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  108976. * Bigger values mean stronger blending
  108977. */
  108978. diffuseBlendLevel: number;
  108979. /**
  108980. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  108981. * Bigger values mean stronger blending. Only used with PBR materials
  108982. */
  108983. roughnessBlendLevel: number;
  108984. /**
  108985. * Defines how strong the bump effect from the detail map is
  108986. * Bigger values mean stronger effect
  108987. */
  108988. bumpLevel: number;
  108989. private _normalBlendMethod;
  108990. /**
  108991. * The method used to blend the bump and detail normals together
  108992. */
  108993. normalBlendMethod: number;
  108994. private _isEnabled;
  108995. /**
  108996. * Enable or disable the detail map on this material
  108997. */
  108998. isEnabled: boolean;
  108999. /** @hidden */
  109000. private _internalMarkAllSubMeshesAsTexturesDirty;
  109001. /** @hidden */
  109002. _markAllSubMeshesAsTexturesDirty(): void;
  109003. /**
  109004. * Instantiate a new detail map
  109005. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109006. */
  109007. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109008. /**
  109009. * Gets whether the submesh is ready to be used or not.
  109010. * @param defines the list of "defines" to update.
  109011. * @param scene defines the scene the material belongs to.
  109012. * @returns - boolean indicating that the submesh is ready or not.
  109013. */
  109014. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  109015. /**
  109016. * Update the defines for detail map usage
  109017. * @param defines the list of "defines" to update.
  109018. * @param scene defines the scene the material belongs to.
  109019. */
  109020. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  109021. /**
  109022. * Binds the material data.
  109023. * @param uniformBuffer defines the Uniform buffer to fill in.
  109024. * @param scene defines the scene the material belongs to.
  109025. * @param isFrozen defines whether the material is frozen or not.
  109026. */
  109027. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109028. /**
  109029. * Checks to see if a texture is used in the material.
  109030. * @param texture - Base texture to use.
  109031. * @returns - Boolean specifying if a texture is used in the material.
  109032. */
  109033. hasTexture(texture: BaseTexture): boolean;
  109034. /**
  109035. * Returns an array of the actively used textures.
  109036. * @param activeTextures Array of BaseTextures
  109037. */
  109038. getActiveTextures(activeTextures: BaseTexture[]): void;
  109039. /**
  109040. * Returns the animatable textures.
  109041. * @param animatables Array of animatable textures.
  109042. */
  109043. getAnimatables(animatables: IAnimatable[]): void;
  109044. /**
  109045. * Disposes the resources of the material.
  109046. * @param forceDisposeTextures - Forces the disposal of all textures.
  109047. */
  109048. dispose(forceDisposeTextures?: boolean): void;
  109049. /**
  109050. * Get the current class name useful for serialization or dynamic coding.
  109051. * @returns "DetailMap"
  109052. */
  109053. getClassName(): string;
  109054. /**
  109055. * Add the required uniforms to the current list.
  109056. * @param uniforms defines the current uniform list.
  109057. */
  109058. static AddUniforms(uniforms: string[]): void;
  109059. /**
  109060. * Add the required samplers to the current list.
  109061. * @param samplers defines the current sampler list.
  109062. */
  109063. static AddSamplers(samplers: string[]): void;
  109064. /**
  109065. * Add the required uniforms to the current buffer.
  109066. * @param uniformBuffer defines the current uniform buffer.
  109067. */
  109068. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109069. /**
  109070. * Makes a duplicate of the current instance into another one.
  109071. * @param detailMap define the instance where to copy the info
  109072. */
  109073. copyTo(detailMap: DetailMapConfiguration): void;
  109074. /**
  109075. * Serializes this detail map instance
  109076. * @returns - An object with the serialized instance.
  109077. */
  109078. serialize(): any;
  109079. /**
  109080. * Parses a detail map setting from a serialized object.
  109081. * @param source - Serialized object.
  109082. * @param scene Defines the scene we are parsing for
  109083. * @param rootUrl Defines the rootUrl to load from
  109084. */
  109085. parse(source: any, scene: Scene, rootUrl: string): void;
  109086. }
  109087. }
  109088. declare module BABYLON {
  109089. /** @hidden */
  109090. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  109091. MAINUV1: boolean;
  109092. MAINUV2: boolean;
  109093. DIFFUSE: boolean;
  109094. DIFFUSEDIRECTUV: number;
  109095. DETAIL: boolean;
  109096. DETAILDIRECTUV: number;
  109097. DETAIL_NORMALBLENDMETHOD: number;
  109098. AMBIENT: boolean;
  109099. AMBIENTDIRECTUV: number;
  109100. OPACITY: boolean;
  109101. OPACITYDIRECTUV: number;
  109102. OPACITYRGB: boolean;
  109103. REFLECTION: boolean;
  109104. EMISSIVE: boolean;
  109105. EMISSIVEDIRECTUV: number;
  109106. SPECULAR: boolean;
  109107. SPECULARDIRECTUV: number;
  109108. BUMP: boolean;
  109109. BUMPDIRECTUV: number;
  109110. PARALLAX: boolean;
  109111. PARALLAXOCCLUSION: boolean;
  109112. SPECULAROVERALPHA: boolean;
  109113. CLIPPLANE: boolean;
  109114. CLIPPLANE2: boolean;
  109115. CLIPPLANE3: boolean;
  109116. CLIPPLANE4: boolean;
  109117. CLIPPLANE5: boolean;
  109118. CLIPPLANE6: boolean;
  109119. ALPHATEST: boolean;
  109120. DEPTHPREPASS: boolean;
  109121. ALPHAFROMDIFFUSE: boolean;
  109122. POINTSIZE: boolean;
  109123. FOG: boolean;
  109124. SPECULARTERM: boolean;
  109125. DIFFUSEFRESNEL: boolean;
  109126. OPACITYFRESNEL: boolean;
  109127. REFLECTIONFRESNEL: boolean;
  109128. REFRACTIONFRESNEL: boolean;
  109129. EMISSIVEFRESNEL: boolean;
  109130. FRESNEL: boolean;
  109131. NORMAL: boolean;
  109132. UV1: boolean;
  109133. UV2: boolean;
  109134. VERTEXCOLOR: boolean;
  109135. VERTEXALPHA: boolean;
  109136. NUM_BONE_INFLUENCERS: number;
  109137. BonesPerMesh: number;
  109138. BONETEXTURE: boolean;
  109139. INSTANCES: boolean;
  109140. THIN_INSTANCES: boolean;
  109141. GLOSSINESS: boolean;
  109142. ROUGHNESS: boolean;
  109143. EMISSIVEASILLUMINATION: boolean;
  109144. LINKEMISSIVEWITHDIFFUSE: boolean;
  109145. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109146. LIGHTMAP: boolean;
  109147. LIGHTMAPDIRECTUV: number;
  109148. OBJECTSPACE_NORMALMAP: boolean;
  109149. USELIGHTMAPASSHADOWMAP: boolean;
  109150. REFLECTIONMAP_3D: boolean;
  109151. REFLECTIONMAP_SPHERICAL: boolean;
  109152. REFLECTIONMAP_PLANAR: boolean;
  109153. REFLECTIONMAP_CUBIC: boolean;
  109154. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109155. REFLECTIONMAP_PROJECTION: boolean;
  109156. REFLECTIONMAP_SKYBOX: boolean;
  109157. REFLECTIONMAP_EXPLICIT: boolean;
  109158. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109159. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109160. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109161. INVERTCUBICMAP: boolean;
  109162. LOGARITHMICDEPTH: boolean;
  109163. REFRACTION: boolean;
  109164. REFRACTIONMAP_3D: boolean;
  109165. REFLECTIONOVERALPHA: boolean;
  109166. TWOSIDEDLIGHTING: boolean;
  109167. SHADOWFLOAT: boolean;
  109168. MORPHTARGETS: boolean;
  109169. MORPHTARGETS_NORMAL: boolean;
  109170. MORPHTARGETS_TANGENT: boolean;
  109171. MORPHTARGETS_UV: boolean;
  109172. NUM_MORPH_INFLUENCERS: number;
  109173. NONUNIFORMSCALING: boolean;
  109174. PREMULTIPLYALPHA: boolean;
  109175. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  109176. ALPHABLEND: boolean;
  109177. PREPASS: boolean;
  109178. SCENE_MRT_COUNT: number;
  109179. RGBDLIGHTMAP: boolean;
  109180. RGBDREFLECTION: boolean;
  109181. RGBDREFRACTION: boolean;
  109182. IMAGEPROCESSING: boolean;
  109183. VIGNETTE: boolean;
  109184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109185. VIGNETTEBLENDMODEOPAQUE: boolean;
  109186. TONEMAPPING: boolean;
  109187. TONEMAPPING_ACES: boolean;
  109188. CONTRAST: boolean;
  109189. COLORCURVES: boolean;
  109190. COLORGRADING: boolean;
  109191. COLORGRADING3D: boolean;
  109192. SAMPLER3DGREENDEPTH: boolean;
  109193. SAMPLER3DBGRMAP: boolean;
  109194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109195. MULTIVIEW: boolean;
  109196. /**
  109197. * If the reflection texture on this material is in linear color space
  109198. * @hidden
  109199. */
  109200. IS_REFLECTION_LINEAR: boolean;
  109201. /**
  109202. * If the refraction texture on this material is in linear color space
  109203. * @hidden
  109204. */
  109205. IS_REFRACTION_LINEAR: boolean;
  109206. EXPOSURE: boolean;
  109207. constructor();
  109208. setReflectionMode(modeToEnable: string): void;
  109209. }
  109210. /**
  109211. * This is the default material used in Babylon. It is the best trade off between quality
  109212. * and performances.
  109213. * @see https://doc.babylonjs.com/babylon101/materials
  109214. */
  109215. export class StandardMaterial extends PushMaterial {
  109216. private _diffuseTexture;
  109217. /**
  109218. * The basic texture of the material as viewed under a light.
  109219. */
  109220. diffuseTexture: Nullable<BaseTexture>;
  109221. private _ambientTexture;
  109222. /**
  109223. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109224. */
  109225. ambientTexture: Nullable<BaseTexture>;
  109226. private _opacityTexture;
  109227. /**
  109228. * Define the transparency of the material from a texture.
  109229. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109230. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109231. */
  109232. opacityTexture: Nullable<BaseTexture>;
  109233. private _reflectionTexture;
  109234. /**
  109235. * Define the texture used to display the reflection.
  109236. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109237. */
  109238. reflectionTexture: Nullable<BaseTexture>;
  109239. private _emissiveTexture;
  109240. /**
  109241. * Define texture of the material as if self lit.
  109242. * This will be mixed in the final result even in the absence of light.
  109243. */
  109244. emissiveTexture: Nullable<BaseTexture>;
  109245. private _specularTexture;
  109246. /**
  109247. * Define how the color and intensity of the highlight given by the light in the material.
  109248. */
  109249. specularTexture: Nullable<BaseTexture>;
  109250. private _bumpTexture;
  109251. /**
  109252. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109253. * 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.
  109254. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  109255. */
  109256. bumpTexture: Nullable<BaseTexture>;
  109257. private _lightmapTexture;
  109258. /**
  109259. * Complex lighting can be computationally expensive to compute at runtime.
  109260. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109261. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  109262. */
  109263. lightmapTexture: Nullable<BaseTexture>;
  109264. private _refractionTexture;
  109265. /**
  109266. * Define the texture used to display the refraction.
  109267. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109268. */
  109269. refractionTexture: Nullable<BaseTexture>;
  109270. /**
  109271. * The color of the material lit by the environmental background lighting.
  109272. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109273. */
  109274. ambientColor: Color3;
  109275. /**
  109276. * The basic color of the material as viewed under a light.
  109277. */
  109278. diffuseColor: Color3;
  109279. /**
  109280. * Define how the color and intensity of the highlight given by the light in the material.
  109281. */
  109282. specularColor: Color3;
  109283. /**
  109284. * Define the color of the material as if self lit.
  109285. * This will be mixed in the final result even in the absence of light.
  109286. */
  109287. emissiveColor: Color3;
  109288. /**
  109289. * Defines how sharp are the highlights in the material.
  109290. * The bigger the value the sharper giving a more glossy feeling to the result.
  109291. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109292. */
  109293. specularPower: number;
  109294. private _useAlphaFromDiffuseTexture;
  109295. /**
  109296. * Does the transparency come from the diffuse texture alpha channel.
  109297. */
  109298. useAlphaFromDiffuseTexture: boolean;
  109299. private _useEmissiveAsIllumination;
  109300. /**
  109301. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109302. */
  109303. useEmissiveAsIllumination: boolean;
  109304. private _linkEmissiveWithDiffuse;
  109305. /**
  109306. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109307. * the emissive level when the final color is close to one.
  109308. */
  109309. linkEmissiveWithDiffuse: boolean;
  109310. private _useSpecularOverAlpha;
  109311. /**
  109312. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109313. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109314. */
  109315. useSpecularOverAlpha: boolean;
  109316. private _useReflectionOverAlpha;
  109317. /**
  109318. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109319. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109320. */
  109321. useReflectionOverAlpha: boolean;
  109322. private _disableLighting;
  109323. /**
  109324. * Does lights from the scene impacts this material.
  109325. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109326. */
  109327. disableLighting: boolean;
  109328. private _useObjectSpaceNormalMap;
  109329. /**
  109330. * Allows using an object space normal map (instead of tangent space).
  109331. */
  109332. useObjectSpaceNormalMap: boolean;
  109333. private _useParallax;
  109334. /**
  109335. * Is parallax enabled or not.
  109336. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109337. */
  109338. useParallax: boolean;
  109339. private _useParallaxOcclusion;
  109340. /**
  109341. * Is parallax occlusion enabled or not.
  109342. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109343. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109344. */
  109345. useParallaxOcclusion: boolean;
  109346. /**
  109347. * 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.
  109348. */
  109349. parallaxScaleBias: number;
  109350. private _roughness;
  109351. /**
  109352. * Helps to define how blurry the reflections should appears in the material.
  109353. */
  109354. roughness: number;
  109355. /**
  109356. * In case of refraction, define the value of the index of refraction.
  109357. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109358. */
  109359. indexOfRefraction: number;
  109360. /**
  109361. * Invert the refraction texture alongside the y axis.
  109362. * It can be useful with procedural textures or probe for instance.
  109363. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109364. */
  109365. invertRefractionY: boolean;
  109366. /**
  109367. * Defines the alpha limits in alpha test mode.
  109368. */
  109369. alphaCutOff: number;
  109370. private _useLightmapAsShadowmap;
  109371. /**
  109372. * In case of light mapping, define whether the map contains light or shadow informations.
  109373. */
  109374. useLightmapAsShadowmap: boolean;
  109375. private _diffuseFresnelParameters;
  109376. /**
  109377. * Define the diffuse fresnel parameters of the material.
  109378. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109379. */
  109380. diffuseFresnelParameters: FresnelParameters;
  109381. private _opacityFresnelParameters;
  109382. /**
  109383. * Define the opacity fresnel parameters of the material.
  109384. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109385. */
  109386. opacityFresnelParameters: FresnelParameters;
  109387. private _reflectionFresnelParameters;
  109388. /**
  109389. * Define the reflection fresnel parameters of the material.
  109390. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109391. */
  109392. reflectionFresnelParameters: FresnelParameters;
  109393. private _refractionFresnelParameters;
  109394. /**
  109395. * Define the refraction fresnel parameters of the material.
  109396. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109397. */
  109398. refractionFresnelParameters: FresnelParameters;
  109399. private _emissiveFresnelParameters;
  109400. /**
  109401. * Define the emissive fresnel parameters of the material.
  109402. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109403. */
  109404. emissiveFresnelParameters: FresnelParameters;
  109405. private _useReflectionFresnelFromSpecular;
  109406. /**
  109407. * If true automatically deducts the fresnels values from the material specularity.
  109408. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109409. */
  109410. useReflectionFresnelFromSpecular: boolean;
  109411. private _useGlossinessFromSpecularMapAlpha;
  109412. /**
  109413. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109414. */
  109415. useGlossinessFromSpecularMapAlpha: boolean;
  109416. private _maxSimultaneousLights;
  109417. /**
  109418. * Defines the maximum number of lights that can be used in the material
  109419. */
  109420. maxSimultaneousLights: number;
  109421. private _invertNormalMapX;
  109422. /**
  109423. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109424. */
  109425. invertNormalMapX: boolean;
  109426. private _invertNormalMapY;
  109427. /**
  109428. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109429. */
  109430. invertNormalMapY: boolean;
  109431. private _twoSidedLighting;
  109432. /**
  109433. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109434. */
  109435. twoSidedLighting: boolean;
  109436. /**
  109437. * Default configuration related to image processing available in the standard Material.
  109438. */
  109439. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109440. /**
  109441. * Gets the image processing configuration used either in this material.
  109442. */
  109443. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109444. /**
  109445. * Sets the Default image processing configuration used either in the this material.
  109446. *
  109447. * If sets to null, the scene one is in use.
  109448. */
  109449. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  109450. /**
  109451. * Keep track of the image processing observer to allow dispose and replace.
  109452. */
  109453. private _imageProcessingObserver;
  109454. /**
  109455. * Attaches a new image processing configuration to the Standard Material.
  109456. * @param configuration
  109457. */
  109458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109459. /**
  109460. * Gets wether the color curves effect is enabled.
  109461. */
  109462. get cameraColorCurvesEnabled(): boolean;
  109463. /**
  109464. * Sets wether the color curves effect is enabled.
  109465. */
  109466. set cameraColorCurvesEnabled(value: boolean);
  109467. /**
  109468. * Gets wether the color grading effect is enabled.
  109469. */
  109470. get cameraColorGradingEnabled(): boolean;
  109471. /**
  109472. * Gets wether the color grading effect is enabled.
  109473. */
  109474. set cameraColorGradingEnabled(value: boolean);
  109475. /**
  109476. * Gets wether tonemapping is enabled or not.
  109477. */
  109478. get cameraToneMappingEnabled(): boolean;
  109479. /**
  109480. * Sets wether tonemapping is enabled or not
  109481. */
  109482. set cameraToneMappingEnabled(value: boolean);
  109483. /**
  109484. * The camera exposure used on this material.
  109485. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109486. * This corresponds to a photographic exposure.
  109487. */
  109488. get cameraExposure(): number;
  109489. /**
  109490. * The camera exposure used on this material.
  109491. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109492. * This corresponds to a photographic exposure.
  109493. */
  109494. set cameraExposure(value: number);
  109495. /**
  109496. * Gets The camera contrast used on this material.
  109497. */
  109498. get cameraContrast(): number;
  109499. /**
  109500. * Sets The camera contrast used on this material.
  109501. */
  109502. set cameraContrast(value: number);
  109503. /**
  109504. * Gets the Color Grading 2D Lookup Texture.
  109505. */
  109506. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  109507. /**
  109508. * Sets the Color Grading 2D Lookup Texture.
  109509. */
  109510. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  109511. /**
  109512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109514. * 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;
  109515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109516. */
  109517. get cameraColorCurves(): Nullable<ColorCurves>;
  109518. /**
  109519. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109520. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109521. * 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;
  109522. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109523. */
  109524. set cameraColorCurves(value: Nullable<ColorCurves>);
  109525. /**
  109526. * Can this material render to several textures at once
  109527. */
  109528. get canRenderToMRT(): boolean;
  109529. /**
  109530. * Defines the detail map parameters for the material.
  109531. */
  109532. readonly detailMap: DetailMapConfiguration;
  109533. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109534. protected _worldViewProjectionMatrix: Matrix;
  109535. protected _globalAmbientColor: Color3;
  109536. protected _useLogarithmicDepth: boolean;
  109537. protected _rebuildInParallel: boolean;
  109538. /**
  109539. * Instantiates a new standard material.
  109540. * This is the default material used in Babylon. It is the best trade off between quality
  109541. * and performances.
  109542. * @see https://doc.babylonjs.com/babylon101/materials
  109543. * @param name Define the name of the material in the scene
  109544. * @param scene Define the scene the material belong to
  109545. */
  109546. constructor(name: string, scene: Scene);
  109547. /**
  109548. * Gets a boolean indicating that current material needs to register RTT
  109549. */
  109550. get hasRenderTargetTextures(): boolean;
  109551. /**
  109552. * Gets the current class name of the material e.g. "StandardMaterial"
  109553. * Mainly use in serialization.
  109554. * @returns the class name
  109555. */
  109556. getClassName(): string;
  109557. /**
  109558. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109559. * You can try switching to logarithmic depth.
  109560. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109561. */
  109562. get useLogarithmicDepth(): boolean;
  109563. set useLogarithmicDepth(value: boolean);
  109564. /**
  109565. * Specifies if the material will require alpha blending
  109566. * @returns a boolean specifying if alpha blending is needed
  109567. */
  109568. needAlphaBlending(): boolean;
  109569. /**
  109570. * Specifies if this material should be rendered in alpha test mode
  109571. * @returns a boolean specifying if an alpha test is needed.
  109572. */
  109573. needAlphaTesting(): boolean;
  109574. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109575. /**
  109576. * Get the texture used for alpha test purpose.
  109577. * @returns the diffuse texture in case of the standard material.
  109578. */
  109579. getAlphaTestTexture(): Nullable<BaseTexture>;
  109580. /**
  109581. * Get if the submesh is ready to be used and all its information available.
  109582. * Child classes can use it to update shaders
  109583. * @param mesh defines the mesh to check
  109584. * @param subMesh defines which submesh to check
  109585. * @param useInstances specifies that instances should be used
  109586. * @returns a boolean indicating that the submesh is ready or not
  109587. */
  109588. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109589. /**
  109590. * Builds the material UBO layouts.
  109591. * Used internally during the effect preparation.
  109592. */
  109593. buildUniformLayout(): void;
  109594. /**
  109595. * Unbinds the material from the mesh
  109596. */
  109597. unbind(): void;
  109598. /**
  109599. * Binds the submesh to this material by preparing the effect and shader to draw
  109600. * @param world defines the world transformation matrix
  109601. * @param mesh defines the mesh containing the submesh
  109602. * @param subMesh defines the submesh to bind the material to
  109603. */
  109604. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109605. /**
  109606. * Get the list of animatables in the material.
  109607. * @returns the list of animatables object used in the material
  109608. */
  109609. getAnimatables(): IAnimatable[];
  109610. /**
  109611. * Gets the active textures from the material
  109612. * @returns an array of textures
  109613. */
  109614. getActiveTextures(): BaseTexture[];
  109615. /**
  109616. * Specifies if the material uses a texture
  109617. * @param texture defines the texture to check against the material
  109618. * @returns a boolean specifying if the material uses the texture
  109619. */
  109620. hasTexture(texture: BaseTexture): boolean;
  109621. /**
  109622. * Disposes the material
  109623. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109624. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109625. */
  109626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109627. /**
  109628. * Makes a duplicate of the material, and gives it a new name
  109629. * @param name defines the new name for the duplicated material
  109630. * @returns the cloned material
  109631. */
  109632. clone(name: string): StandardMaterial;
  109633. /**
  109634. * Serializes this material in a JSON representation
  109635. * @returns the serialized material object
  109636. */
  109637. serialize(): any;
  109638. /**
  109639. * Creates a standard material from parsed material data
  109640. * @param source defines the JSON representation of the material
  109641. * @param scene defines the hosting scene
  109642. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109643. * @returns a new standard material
  109644. */
  109645. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109646. /**
  109647. * Are diffuse textures enabled in the application.
  109648. */
  109649. static get DiffuseTextureEnabled(): boolean;
  109650. static set DiffuseTextureEnabled(value: boolean);
  109651. /**
  109652. * Are detail textures enabled in the application.
  109653. */
  109654. static get DetailTextureEnabled(): boolean;
  109655. static set DetailTextureEnabled(value: boolean);
  109656. /**
  109657. * Are ambient textures enabled in the application.
  109658. */
  109659. static get AmbientTextureEnabled(): boolean;
  109660. static set AmbientTextureEnabled(value: boolean);
  109661. /**
  109662. * Are opacity textures enabled in the application.
  109663. */
  109664. static get OpacityTextureEnabled(): boolean;
  109665. static set OpacityTextureEnabled(value: boolean);
  109666. /**
  109667. * Are reflection textures enabled in the application.
  109668. */
  109669. static get ReflectionTextureEnabled(): boolean;
  109670. static set ReflectionTextureEnabled(value: boolean);
  109671. /**
  109672. * Are emissive textures enabled in the application.
  109673. */
  109674. static get EmissiveTextureEnabled(): boolean;
  109675. static set EmissiveTextureEnabled(value: boolean);
  109676. /**
  109677. * Are specular textures enabled in the application.
  109678. */
  109679. static get SpecularTextureEnabled(): boolean;
  109680. static set SpecularTextureEnabled(value: boolean);
  109681. /**
  109682. * Are bump textures enabled in the application.
  109683. */
  109684. static get BumpTextureEnabled(): boolean;
  109685. static set BumpTextureEnabled(value: boolean);
  109686. /**
  109687. * Are lightmap textures enabled in the application.
  109688. */
  109689. static get LightmapTextureEnabled(): boolean;
  109690. static set LightmapTextureEnabled(value: boolean);
  109691. /**
  109692. * Are refraction textures enabled in the application.
  109693. */
  109694. static get RefractionTextureEnabled(): boolean;
  109695. static set RefractionTextureEnabled(value: boolean);
  109696. /**
  109697. * Are color grading textures enabled in the application.
  109698. */
  109699. static get ColorGradingTextureEnabled(): boolean;
  109700. static set ColorGradingTextureEnabled(value: boolean);
  109701. /**
  109702. * Are fresnels enabled in the application.
  109703. */
  109704. static get FresnelEnabled(): boolean;
  109705. static set FresnelEnabled(value: boolean);
  109706. }
  109707. }
  109708. declare module BABYLON {
  109709. /**
  109710. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109711. *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.
  109712. * The SPS is also a particle system. It provides some methods to manage the particles.
  109713. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109714. *
  109715. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  109716. */
  109717. export class SolidParticleSystem implements IDisposable {
  109718. /**
  109719. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109720. * Example : var p = SPS.particles[i];
  109721. */
  109722. particles: SolidParticle[];
  109723. /**
  109724. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109725. */
  109726. nbParticles: number;
  109727. /**
  109728. * If the particles must ever face the camera (default false). Useful for planar particles.
  109729. */
  109730. billboard: boolean;
  109731. /**
  109732. * Recompute normals when adding a shape
  109733. */
  109734. recomputeNormals: boolean;
  109735. /**
  109736. * This a counter ofr your own usage. It's not set by any SPS functions.
  109737. */
  109738. counter: number;
  109739. /**
  109740. * The SPS name. This name is also given to the underlying mesh.
  109741. */
  109742. name: string;
  109743. /**
  109744. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  109745. */
  109746. mesh: Mesh;
  109747. /**
  109748. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  109749. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  109750. */
  109751. vars: any;
  109752. /**
  109753. * This array is populated when the SPS is set as 'pickable'.
  109754. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  109755. * Each element of this array is an object `{idx: int, faceId: int}`.
  109756. * `idx` is the picked particle index in the `SPS.particles` array
  109757. * `faceId` is the picked face index counted within this particle.
  109758. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  109759. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  109760. * Use the method SPS.pickedParticle(pickingInfo) instead.
  109761. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109762. */
  109763. pickedParticles: {
  109764. idx: number;
  109765. faceId: number;
  109766. }[];
  109767. /**
  109768. * This array is populated when the SPS is set as 'pickable'
  109769. * Each key of this array is a submesh index.
  109770. * Each element of this array is a second array defined like this :
  109771. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  109772. * Each element of this second array is an object `{idx: int, faceId: int}`.
  109773. * `idx` is the picked particle index in the `SPS.particles` array
  109774. * `faceId` is the picked face index counted within this particle.
  109775. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  109776. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109777. */
  109778. pickedBySubMesh: {
  109779. idx: number;
  109780. faceId: number;
  109781. }[][];
  109782. /**
  109783. * This array is populated when `enableDepthSort` is set to true.
  109784. * Each element of this array is an instance of the class DepthSortedParticle.
  109785. */
  109786. depthSortedParticles: DepthSortedParticle[];
  109787. /**
  109788. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  109789. * @hidden
  109790. */
  109791. _bSphereOnly: boolean;
  109792. /**
  109793. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  109794. * @hidden
  109795. */
  109796. _bSphereRadiusFactor: number;
  109797. private _scene;
  109798. private _positions;
  109799. private _indices;
  109800. private _normals;
  109801. private _colors;
  109802. private _uvs;
  109803. private _indices32;
  109804. private _positions32;
  109805. private _normals32;
  109806. private _fixedNormal32;
  109807. private _colors32;
  109808. private _uvs32;
  109809. private _index;
  109810. private _updatable;
  109811. private _pickable;
  109812. private _isVisibilityBoxLocked;
  109813. private _alwaysVisible;
  109814. private _depthSort;
  109815. private _expandable;
  109816. private _shapeCounter;
  109817. private _copy;
  109818. private _color;
  109819. private _computeParticleColor;
  109820. private _computeParticleTexture;
  109821. private _computeParticleRotation;
  109822. private _computeParticleVertex;
  109823. private _computeBoundingBox;
  109824. private _depthSortParticles;
  109825. private _camera;
  109826. private _mustUnrotateFixedNormals;
  109827. private _particlesIntersect;
  109828. private _needs32Bits;
  109829. private _isNotBuilt;
  109830. private _lastParticleId;
  109831. private _idxOfId;
  109832. private _multimaterialEnabled;
  109833. private _useModelMaterial;
  109834. private _indicesByMaterial;
  109835. private _materialIndexes;
  109836. private _depthSortFunction;
  109837. private _materialSortFunction;
  109838. private _materials;
  109839. private _multimaterial;
  109840. private _materialIndexesById;
  109841. private _defaultMaterial;
  109842. private _autoUpdateSubMeshes;
  109843. private _tmpVertex;
  109844. /**
  109845. * Creates a SPS (Solid Particle System) object.
  109846. * @param name (String) is the SPS name, this will be the underlying mesh name.
  109847. * @param scene (Scene) is the scene in which the SPS is added.
  109848. * @param options defines the options of the sps e.g.
  109849. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  109850. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  109851. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  109852. * * 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.
  109853. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  109854. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  109855. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  109856. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  109857. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  109858. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  109859. */
  109860. constructor(name: string, scene: Scene, options?: {
  109861. updatable?: boolean;
  109862. isPickable?: boolean;
  109863. enableDepthSort?: boolean;
  109864. particleIntersection?: boolean;
  109865. boundingSphereOnly?: boolean;
  109866. bSphereRadiusFactor?: number;
  109867. expandable?: boolean;
  109868. useModelMaterial?: boolean;
  109869. enableMultiMaterial?: boolean;
  109870. });
  109871. /**
  109872. * Builds the SPS underlying mesh. Returns a standard Mesh.
  109873. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  109874. * @returns the created mesh
  109875. */
  109876. buildMesh(): Mesh;
  109877. /**
  109878. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  109879. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  109880. * Thus the particles generated from `digest()` have their property `position` set yet.
  109881. * @param mesh ( Mesh ) is the mesh to be digested
  109882. * @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
  109883. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  109884. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  109885. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109886. * @returns the current SPS
  109887. */
  109888. digest(mesh: Mesh, options?: {
  109889. facetNb?: number;
  109890. number?: number;
  109891. delta?: number;
  109892. storage?: [];
  109893. }): SolidParticleSystem;
  109894. /**
  109895. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  109896. * @hidden
  109897. */
  109898. private _unrotateFixedNormals;
  109899. /**
  109900. * Resets the temporary working copy particle
  109901. * @hidden
  109902. */
  109903. private _resetCopy;
  109904. /**
  109905. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  109906. * @param p the current index in the positions array to be updated
  109907. * @param ind the current index in the indices array
  109908. * @param shape a Vector3 array, the shape geometry
  109909. * @param positions the positions array to be updated
  109910. * @param meshInd the shape indices array
  109911. * @param indices the indices array to be updated
  109912. * @param meshUV the shape uv array
  109913. * @param uvs the uv array to be updated
  109914. * @param meshCol the shape color array
  109915. * @param colors the color array to be updated
  109916. * @param meshNor the shape normals array
  109917. * @param normals the normals array to be updated
  109918. * @param idx the particle index
  109919. * @param idxInShape the particle index in its shape
  109920. * @param options the addShape() method passed options
  109921. * @model the particle model
  109922. * @hidden
  109923. */
  109924. private _meshBuilder;
  109925. /**
  109926. * Returns a shape Vector3 array from positions float array
  109927. * @param positions float array
  109928. * @returns a vector3 array
  109929. * @hidden
  109930. */
  109931. private _posToShape;
  109932. /**
  109933. * Returns a shapeUV array from a float uvs (array deep copy)
  109934. * @param uvs as a float array
  109935. * @returns a shapeUV array
  109936. * @hidden
  109937. */
  109938. private _uvsToShapeUV;
  109939. /**
  109940. * Adds a new particle object in the particles array
  109941. * @param idx particle index in particles array
  109942. * @param id particle id
  109943. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  109944. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  109945. * @param model particle ModelShape object
  109946. * @param shapeId model shape identifier
  109947. * @param idxInShape index of the particle in the current model
  109948. * @param bInfo model bounding info object
  109949. * @param storage target storage array, if any
  109950. * @hidden
  109951. */
  109952. private _addParticle;
  109953. /**
  109954. * Adds some particles to the SPS from the model shape. Returns the shape id.
  109955. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  109956. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  109957. * @param nb (positive integer) the number of particles to be created from this model
  109958. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  109959. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  109960. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109961. * @returns the number of shapes in the system
  109962. */
  109963. addShape(mesh: Mesh, nb: number, options?: {
  109964. positionFunction?: any;
  109965. vertexFunction?: any;
  109966. storage?: [];
  109967. }): number;
  109968. /**
  109969. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  109970. * @hidden
  109971. */
  109972. private _rebuildParticle;
  109973. /**
  109974. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  109975. * @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.
  109976. * @returns the SPS.
  109977. */
  109978. rebuildMesh(reset?: boolean): SolidParticleSystem;
  109979. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  109980. * Returns an array with the removed particles.
  109981. * 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.
  109982. * The SPS can't be empty so at least one particle needs to remain in place.
  109983. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  109984. * @param start index of the first particle to remove
  109985. * @param end index of the last particle to remove (included)
  109986. * @returns an array populated with the removed particles
  109987. */
  109988. removeParticles(start: number, end: number): SolidParticle[];
  109989. /**
  109990. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  109991. * @param solidParticleArray an array populated with Solid Particles objects
  109992. * @returns the SPS
  109993. */
  109994. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  109995. /**
  109996. * Creates a new particle and modifies the SPS mesh geometry :
  109997. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  109998. * - calls _addParticle() to populate the particle array
  109999. * factorized code from addShape() and insertParticlesFromArray()
  110000. * @param idx particle index in the particles array
  110001. * @param i particle index in its shape
  110002. * @param modelShape particle ModelShape object
  110003. * @param shape shape vertex array
  110004. * @param meshInd shape indices array
  110005. * @param meshUV shape uv array
  110006. * @param meshCol shape color array
  110007. * @param meshNor shape normals array
  110008. * @param bbInfo shape bounding info
  110009. * @param storage target particle storage
  110010. * @options addShape() passed options
  110011. * @hidden
  110012. */
  110013. private _insertNewParticle;
  110014. /**
  110015. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  110016. * This method calls `updateParticle()` for each particle of the SPS.
  110017. * For an animated SPS, it is usually called within the render loop.
  110018. * 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.
  110019. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  110020. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  110021. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  110022. * @returns the SPS.
  110023. */
  110024. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  110025. /**
  110026. * Disposes the SPS.
  110027. */
  110028. dispose(): void;
  110029. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  110030. * idx is the particle index in the SPS
  110031. * faceId is the picked face index counted within this particle.
  110032. * Returns null if the pickInfo can't identify a picked particle.
  110033. * @param pickingInfo (PickingInfo object)
  110034. * @returns {idx: number, faceId: number} or null
  110035. */
  110036. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  110037. idx: number;
  110038. faceId: number;
  110039. }>;
  110040. /**
  110041. * Returns a SolidParticle object from its identifier : particle.id
  110042. * @param id (integer) the particle Id
  110043. * @returns the searched particle or null if not found in the SPS.
  110044. */
  110045. getParticleById(id: number): Nullable<SolidParticle>;
  110046. /**
  110047. * Returns a new array populated with the particles having the passed shapeId.
  110048. * @param shapeId (integer) the shape identifier
  110049. * @returns a new solid particle array
  110050. */
  110051. getParticlesByShapeId(shapeId: number): SolidParticle[];
  110052. /**
  110053. * Populates the passed array "ref" with the particles having the passed shapeId.
  110054. * @param shapeId the shape identifier
  110055. * @returns the SPS
  110056. * @param ref
  110057. */
  110058. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  110059. /**
  110060. * Computes the required SubMeshes according the materials assigned to the particles.
  110061. * @returns the solid particle system.
  110062. * Does nothing if called before the SPS mesh is built.
  110063. */
  110064. computeSubMeshes(): SolidParticleSystem;
  110065. /**
  110066. * Sorts the solid particles by material when MultiMaterial is enabled.
  110067. * Updates the indices32 array.
  110068. * Updates the indicesByMaterial array.
  110069. * Updates the mesh indices array.
  110070. * @returns the SPS
  110071. * @hidden
  110072. */
  110073. private _sortParticlesByMaterial;
  110074. /**
  110075. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  110076. * @hidden
  110077. */
  110078. private _setMaterialIndexesById;
  110079. /**
  110080. * Returns an array with unique values of Materials from the passed array
  110081. * @param array the material array to be checked and filtered
  110082. * @hidden
  110083. */
  110084. private _filterUniqueMaterialId;
  110085. /**
  110086. * Sets a new Standard Material as _defaultMaterial if not already set.
  110087. * @hidden
  110088. */
  110089. private _setDefaultMaterial;
  110090. /**
  110091. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110092. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110093. * @returns the SPS.
  110094. */
  110095. refreshVisibleSize(): SolidParticleSystem;
  110096. /**
  110097. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110098. * @param size the size (float) of the visibility box
  110099. * note : this doesn't lock the SPS mesh bounding box.
  110100. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110101. */
  110102. setVisibilityBox(size: number): void;
  110103. /**
  110104. * Gets whether the SPS as always visible or not
  110105. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110106. */
  110107. get isAlwaysVisible(): boolean;
  110108. /**
  110109. * Sets the SPS as always visible or not
  110110. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110111. */
  110112. set isAlwaysVisible(val: boolean);
  110113. /**
  110114. * Sets 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. set isVisibilityBoxLocked(val: boolean);
  110118. /**
  110119. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110120. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110121. */
  110122. get isVisibilityBoxLocked(): boolean;
  110123. /**
  110124. * Tells to `setParticles()` to compute the particle rotations or not.
  110125. * Default value : true. The SPS is faster when it's set to false.
  110126. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110127. */
  110128. set computeParticleRotation(val: boolean);
  110129. /**
  110130. * Tells to `setParticles()` to compute the particle colors or not.
  110131. * Default value : true. The SPS is faster when it's set to false.
  110132. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110133. */
  110134. set computeParticleColor(val: boolean);
  110135. set computeParticleTexture(val: boolean);
  110136. /**
  110137. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110138. * Default value : false. The SPS is faster when it's set to false.
  110139. * Note : the particle custom vertex positions aren't stored values.
  110140. */
  110141. set computeParticleVertex(val: boolean);
  110142. /**
  110143. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110144. */
  110145. set computeBoundingBox(val: boolean);
  110146. /**
  110147. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110148. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110149. * Default : `true`
  110150. */
  110151. set depthSortParticles(val: boolean);
  110152. /**
  110153. * Gets if `setParticles()` computes the particle rotations or not.
  110154. * Default value : true. The SPS is faster when it's set to false.
  110155. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110156. */
  110157. get computeParticleRotation(): boolean;
  110158. /**
  110159. * Gets if `setParticles()` computes the particle colors or not.
  110160. * Default value : true. The SPS is faster when it's set to false.
  110161. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110162. */
  110163. get computeParticleColor(): boolean;
  110164. /**
  110165. * Gets if `setParticles()` computes the particle textures or not.
  110166. * Default value : true. The SPS is faster when it's set to false.
  110167. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110168. */
  110169. get computeParticleTexture(): boolean;
  110170. /**
  110171. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110172. * Default value : false. The SPS is faster when it's set to false.
  110173. * Note : the particle custom vertex positions aren't stored values.
  110174. */
  110175. get computeParticleVertex(): boolean;
  110176. /**
  110177. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110178. */
  110179. get computeBoundingBox(): boolean;
  110180. /**
  110181. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110182. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110183. * Default : `true`
  110184. */
  110185. get depthSortParticles(): boolean;
  110186. /**
  110187. * Gets if the SPS is created as expandable at construction time.
  110188. * Default : `false`
  110189. */
  110190. get expandable(): boolean;
  110191. /**
  110192. * Gets if the SPS supports the Multi Materials
  110193. */
  110194. get multimaterialEnabled(): boolean;
  110195. /**
  110196. * Gets if the SPS uses the model materials for its own multimaterial.
  110197. */
  110198. get useModelMaterial(): boolean;
  110199. /**
  110200. * The SPS used material array.
  110201. */
  110202. get materials(): Material[];
  110203. /**
  110204. * Sets the SPS MultiMaterial from the passed materials.
  110205. * Note : the passed array is internally copied and not used then by reference.
  110206. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  110207. */
  110208. setMultiMaterial(materials: Material[]): void;
  110209. /**
  110210. * The SPS computed multimaterial object
  110211. */
  110212. get multimaterial(): MultiMaterial;
  110213. set multimaterial(mm: MultiMaterial);
  110214. /**
  110215. * If the subMeshes must be updated on the next call to setParticles()
  110216. */
  110217. get autoUpdateSubMeshes(): boolean;
  110218. set autoUpdateSubMeshes(val: boolean);
  110219. /**
  110220. * This function does nothing. It may be overwritten to set all the particle first values.
  110221. * The SPS doesn't call this function, you may have to call it by your own.
  110222. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110223. */
  110224. initParticles(): void;
  110225. /**
  110226. * This function does nothing. It may be overwritten to recycle a particle.
  110227. * The SPS doesn't call this function, you may have to call it by your own.
  110228. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110229. * @param particle The particle to recycle
  110230. * @returns the recycled particle
  110231. */
  110232. recycleParticle(particle: SolidParticle): SolidParticle;
  110233. /**
  110234. * Updates a particle : this function should be overwritten by the user.
  110235. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110236. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110237. * @example : just set a particle position or velocity and recycle conditions
  110238. * @param particle The particle to update
  110239. * @returns the updated particle
  110240. */
  110241. updateParticle(particle: SolidParticle): SolidParticle;
  110242. /**
  110243. * Updates a vertex of a particle : it can be overwritten by the user.
  110244. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110245. * @param particle the current particle
  110246. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  110247. * @param pt the index of the current vertex in the particle shape
  110248. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  110249. * @example : just set a vertex particle position or color
  110250. * @returns the sps
  110251. */
  110252. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  110253. /**
  110254. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110255. * This does nothing and may be overwritten by the user.
  110256. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110257. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110258. * @param update the boolean update value actually passed to setParticles()
  110259. */
  110260. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110261. /**
  110262. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110263. * This will be passed three parameters.
  110264. * This does nothing and may be overwritten by the user.
  110265. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110266. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110267. * @param update the boolean update value actually passed to setParticles()
  110268. */
  110269. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110270. }
  110271. }
  110272. declare module BABYLON {
  110273. /**
  110274. * Represents one particle of a solid particle system.
  110275. */
  110276. export class SolidParticle {
  110277. /**
  110278. * particle global index
  110279. */
  110280. idx: number;
  110281. /**
  110282. * particle identifier
  110283. */
  110284. id: number;
  110285. /**
  110286. * The color of the particle
  110287. */
  110288. color: Nullable<Color4>;
  110289. /**
  110290. * The world space position of the particle.
  110291. */
  110292. position: Vector3;
  110293. /**
  110294. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110295. */
  110296. rotation: Vector3;
  110297. /**
  110298. * The world space rotation quaternion of the particle.
  110299. */
  110300. rotationQuaternion: Nullable<Quaternion>;
  110301. /**
  110302. * The scaling of the particle.
  110303. */
  110304. scaling: Vector3;
  110305. /**
  110306. * The uvs of the particle.
  110307. */
  110308. uvs: Vector4;
  110309. /**
  110310. * The current speed of the particle.
  110311. */
  110312. velocity: Vector3;
  110313. /**
  110314. * The pivot point in the particle local space.
  110315. */
  110316. pivot: Vector3;
  110317. /**
  110318. * Must the particle be translated from its pivot point in its local space ?
  110319. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110320. * Default : false
  110321. */
  110322. translateFromPivot: boolean;
  110323. /**
  110324. * Is the particle active or not ?
  110325. */
  110326. alive: boolean;
  110327. /**
  110328. * Is the particle visible or not ?
  110329. */
  110330. isVisible: boolean;
  110331. /**
  110332. * Index of this particle in the global "positions" array (Internal use)
  110333. * @hidden
  110334. */
  110335. _pos: number;
  110336. /**
  110337. * @hidden Index of this particle in the global "indices" array (Internal use)
  110338. */
  110339. _ind: number;
  110340. /**
  110341. * @hidden ModelShape of this particle (Internal use)
  110342. */
  110343. _model: ModelShape;
  110344. /**
  110345. * ModelShape id of this particle
  110346. */
  110347. shapeId: number;
  110348. /**
  110349. * Index of the particle in its shape id
  110350. */
  110351. idxInShape: number;
  110352. /**
  110353. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  110354. */
  110355. _modelBoundingInfo: BoundingInfo;
  110356. /**
  110357. * @hidden Particle BoundingInfo object (Internal use)
  110358. */
  110359. _boundingInfo: BoundingInfo;
  110360. /**
  110361. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  110362. */
  110363. _sps: SolidParticleSystem;
  110364. /**
  110365. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110366. */
  110367. _stillInvisible: boolean;
  110368. /**
  110369. * @hidden Last computed particle rotation matrix
  110370. */
  110371. _rotationMatrix: number[];
  110372. /**
  110373. * Parent particle Id, if any.
  110374. * Default null.
  110375. */
  110376. parentId: Nullable<number>;
  110377. /**
  110378. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110379. */
  110380. materialIndex: Nullable<number>;
  110381. /**
  110382. * Custom object or properties.
  110383. */
  110384. props: Nullable<any>;
  110385. /**
  110386. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110387. * The possible values are :
  110388. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110389. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110390. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110391. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110392. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110393. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110394. * */
  110395. cullingStrategy: number;
  110396. /**
  110397. * @hidden Internal global position in the SPS.
  110398. */
  110399. _globalPosition: Vector3;
  110400. /**
  110401. * Creates a Solid Particle object.
  110402. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110403. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110404. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110405. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110406. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110407. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110408. * @param shapeId (integer) is the model shape identifier in the SPS.
  110409. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110410. * @param sps defines the sps it is associated to
  110411. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110412. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110413. */
  110414. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  110415. /**
  110416. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  110417. * @param target the particle target
  110418. * @returns the current particle
  110419. */
  110420. copyToRef(target: SolidParticle): SolidParticle;
  110421. /**
  110422. * Legacy support, changed scale to scaling
  110423. */
  110424. get scale(): Vector3;
  110425. /**
  110426. * Legacy support, changed scale to scaling
  110427. */
  110428. set scale(scale: Vector3);
  110429. /**
  110430. * Legacy support, changed quaternion to rotationQuaternion
  110431. */
  110432. get quaternion(): Nullable<Quaternion>;
  110433. /**
  110434. * Legacy support, changed quaternion to rotationQuaternion
  110435. */
  110436. set quaternion(q: Nullable<Quaternion>);
  110437. /**
  110438. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110439. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110440. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110441. * @returns true if it intersects
  110442. */
  110443. intersectsMesh(target: Mesh | SolidParticle): boolean;
  110444. /**
  110445. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  110446. * A particle is in the frustum if its bounding box intersects the frustum
  110447. * @param frustumPlanes defines the frustum to test
  110448. * @returns true if the particle is in the frustum planes
  110449. */
  110450. isInFrustum(frustumPlanes: Plane[]): boolean;
  110451. /**
  110452. * get the rotation matrix of the particle
  110453. * @hidden
  110454. */
  110455. getRotationMatrix(m: Matrix): void;
  110456. }
  110457. /**
  110458. * Represents the shape of the model used by one particle of a solid particle system.
  110459. * SPS internal tool, don't use it manually.
  110460. */
  110461. export class ModelShape {
  110462. /**
  110463. * The shape id
  110464. * @hidden
  110465. */
  110466. shapeID: number;
  110467. /**
  110468. * flat array of model positions (internal use)
  110469. * @hidden
  110470. */
  110471. _shape: Vector3[];
  110472. /**
  110473. * flat array of model UVs (internal use)
  110474. * @hidden
  110475. */
  110476. _shapeUV: number[];
  110477. /**
  110478. * color array of the model
  110479. * @hidden
  110480. */
  110481. _shapeColors: number[];
  110482. /**
  110483. * indices array of the model
  110484. * @hidden
  110485. */
  110486. _indices: number[];
  110487. /**
  110488. * normals array of the model
  110489. * @hidden
  110490. */
  110491. _normals: number[];
  110492. /**
  110493. * length of the shape in the model indices array (internal use)
  110494. * @hidden
  110495. */
  110496. _indicesLength: number;
  110497. /**
  110498. * Custom position function (internal use)
  110499. * @hidden
  110500. */
  110501. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  110502. /**
  110503. * Custom vertex function (internal use)
  110504. * @hidden
  110505. */
  110506. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  110507. /**
  110508. * Model material (internal use)
  110509. * @hidden
  110510. */
  110511. _material: Nullable<Material>;
  110512. /**
  110513. * 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.
  110514. * SPS internal tool, don't use it manually.
  110515. * @hidden
  110516. */
  110517. 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>);
  110518. }
  110519. /**
  110520. * Represents a Depth Sorted Particle in the solid particle system.
  110521. * @hidden
  110522. */
  110523. export class DepthSortedParticle {
  110524. /**
  110525. * Particle index
  110526. */
  110527. idx: number;
  110528. /**
  110529. * Index of the particle in the "indices" array
  110530. */
  110531. ind: number;
  110532. /**
  110533. * Length of the particle shape in the "indices" array
  110534. */
  110535. indicesLength: number;
  110536. /**
  110537. * Squared distance from the particle to the camera
  110538. */
  110539. sqDistance: number;
  110540. /**
  110541. * Material index when used with MultiMaterials
  110542. */
  110543. materialIndex: number;
  110544. /**
  110545. * Creates a new sorted particle
  110546. * @param materialIndex
  110547. */
  110548. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  110549. }
  110550. /**
  110551. * Represents a solid particle vertex
  110552. */
  110553. export class SolidParticleVertex {
  110554. /**
  110555. * Vertex position
  110556. */
  110557. position: Vector3;
  110558. /**
  110559. * Vertex color
  110560. */
  110561. color: Color4;
  110562. /**
  110563. * Vertex UV
  110564. */
  110565. uv: Vector2;
  110566. /**
  110567. * Creates a new solid particle vertex
  110568. */
  110569. constructor();
  110570. /** Vertex x coordinate */
  110571. get x(): number;
  110572. set x(val: number);
  110573. /** Vertex y coordinate */
  110574. get y(): number;
  110575. set y(val: number);
  110576. /** Vertex z coordinate */
  110577. get z(): number;
  110578. set z(val: number);
  110579. }
  110580. }
  110581. declare module BABYLON {
  110582. /**
  110583. * @hidden
  110584. */
  110585. export class _MeshCollisionData {
  110586. _checkCollisions: boolean;
  110587. _collisionMask: number;
  110588. _collisionGroup: number;
  110589. _surroundingMeshes: Nullable<AbstractMesh[]>;
  110590. _collider: Nullable<Collider>;
  110591. _oldPositionForCollisions: Vector3;
  110592. _diffPositionForCollisions: Vector3;
  110593. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  110594. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  110595. }
  110596. }
  110597. declare module BABYLON {
  110598. /** @hidden */
  110599. class _FacetDataStorage {
  110600. facetPositions: Vector3[];
  110601. facetNormals: Vector3[];
  110602. facetPartitioning: number[][];
  110603. facetNb: number;
  110604. partitioningSubdivisions: number;
  110605. partitioningBBoxRatio: number;
  110606. facetDataEnabled: boolean;
  110607. facetParameters: any;
  110608. bbSize: Vector3;
  110609. subDiv: {
  110610. max: number;
  110611. X: number;
  110612. Y: number;
  110613. Z: number;
  110614. };
  110615. facetDepthSort: boolean;
  110616. facetDepthSortEnabled: boolean;
  110617. depthSortedIndices: IndicesArray;
  110618. depthSortedFacets: {
  110619. ind: number;
  110620. sqDistance: number;
  110621. }[];
  110622. facetDepthSortFunction: (f1: {
  110623. ind: number;
  110624. sqDistance: number;
  110625. }, f2: {
  110626. ind: number;
  110627. sqDistance: number;
  110628. }) => number;
  110629. facetDepthSortFrom: Vector3;
  110630. facetDepthSortOrigin: Vector3;
  110631. invertedMatrix: Matrix;
  110632. }
  110633. /**
  110634. * @hidden
  110635. **/
  110636. class _InternalAbstractMeshDataInfo {
  110637. _hasVertexAlpha: boolean;
  110638. _useVertexColors: boolean;
  110639. _numBoneInfluencers: number;
  110640. _applyFog: boolean;
  110641. _receiveShadows: boolean;
  110642. _facetData: _FacetDataStorage;
  110643. _visibility: number;
  110644. _skeleton: Nullable<Skeleton>;
  110645. _layerMask: number;
  110646. _computeBonesUsingShaders: boolean;
  110647. _isActive: boolean;
  110648. _onlyForInstances: boolean;
  110649. _isActiveIntermediate: boolean;
  110650. _onlyForInstancesIntermediate: boolean;
  110651. _actAsRegularMesh: boolean;
  110652. }
  110653. /**
  110654. * Class used to store all common mesh properties
  110655. */
  110656. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  110657. /** No occlusion */
  110658. static OCCLUSION_TYPE_NONE: number;
  110659. /** Occlusion set to optimisitic */
  110660. static OCCLUSION_TYPE_OPTIMISTIC: number;
  110661. /** Occlusion set to strict */
  110662. static OCCLUSION_TYPE_STRICT: number;
  110663. /** Use an accurante occlusion algorithm */
  110664. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  110665. /** Use a conservative occlusion algorithm */
  110666. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  110667. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  110668. * Test order :
  110669. * Is the bounding sphere outside the frustum ?
  110670. * If not, are the bounding box vertices outside the frustum ?
  110671. * It not, then the cullable object is in the frustum.
  110672. */
  110673. static readonly CULLINGSTRATEGY_STANDARD: number;
  110674. /** Culling strategy : Bounding Sphere Only.
  110675. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  110676. * It's also less accurate than the standard because some not visible objects can still be selected.
  110677. * Test : is the bounding sphere outside the frustum ?
  110678. * If not, then the cullable object is in the frustum.
  110679. */
  110680. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  110681. /** Culling strategy : Optimistic Inclusion.
  110682. * This in an inclusion test first, then the standard exclusion test.
  110683. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  110684. * 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.
  110685. * Anyway, it's as accurate as the standard strategy.
  110686. * Test :
  110687. * Is the cullable object bounding sphere center in the frustum ?
  110688. * If not, apply the default culling strategy.
  110689. */
  110690. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  110691. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  110692. * This in an inclusion test first, then the bounding sphere only exclusion test.
  110693. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  110694. * 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.
  110695. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  110696. * Test :
  110697. * Is the cullable object bounding sphere center in the frustum ?
  110698. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  110699. */
  110700. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  110701. /**
  110702. * No billboard
  110703. */
  110704. static get BILLBOARDMODE_NONE(): number;
  110705. /** Billboard on X axis */
  110706. static get BILLBOARDMODE_X(): number;
  110707. /** Billboard on Y axis */
  110708. static get BILLBOARDMODE_Y(): number;
  110709. /** Billboard on Z axis */
  110710. static get BILLBOARDMODE_Z(): number;
  110711. /** Billboard on all axes */
  110712. static get BILLBOARDMODE_ALL(): number;
  110713. /** Billboard on using position instead of orientation */
  110714. static get BILLBOARDMODE_USE_POSITION(): number;
  110715. /** @hidden */
  110716. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  110717. /**
  110718. * The culling strategy to use to check whether the mesh must be rendered or not.
  110719. * This value can be changed at any time and will be used on the next render mesh selection.
  110720. * The possible values are :
  110721. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110722. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110723. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110724. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110725. * Please read each static variable documentation to get details about the culling process.
  110726. * */
  110727. cullingStrategy: number;
  110728. /**
  110729. * Gets the number of facets in the mesh
  110730. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110731. */
  110732. get facetNb(): number;
  110733. /**
  110734. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  110735. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110736. */
  110737. get partitioningSubdivisions(): number;
  110738. set partitioningSubdivisions(nb: number);
  110739. /**
  110740. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  110741. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  110742. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110743. */
  110744. get partitioningBBoxRatio(): number;
  110745. set partitioningBBoxRatio(ratio: number);
  110746. /**
  110747. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  110748. * Works only for updatable meshes.
  110749. * Doesn't work with multi-materials
  110750. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110751. */
  110752. get mustDepthSortFacets(): boolean;
  110753. set mustDepthSortFacets(sort: boolean);
  110754. /**
  110755. * The location (Vector3) where the facet depth sort must be computed from.
  110756. * By default, the active camera position.
  110757. * Used only when facet depth sort is enabled
  110758. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110759. */
  110760. get facetDepthSortFrom(): Vector3;
  110761. set facetDepthSortFrom(location: Vector3);
  110762. /**
  110763. * gets a boolean indicating if facetData is enabled
  110764. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110765. */
  110766. get isFacetDataEnabled(): boolean;
  110767. /** @hidden */
  110768. _updateNonUniformScalingState(value: boolean): boolean;
  110769. /**
  110770. * An event triggered when this mesh collides with another one
  110771. */
  110772. onCollideObservable: Observable<AbstractMesh>;
  110773. /** Set a function to call when this mesh collides with another one */
  110774. set onCollide(callback: () => void);
  110775. /**
  110776. * An event triggered when the collision's position changes
  110777. */
  110778. onCollisionPositionChangeObservable: Observable<Vector3>;
  110779. /** Set a function to call when the collision's position changes */
  110780. set onCollisionPositionChange(callback: () => void);
  110781. /**
  110782. * An event triggered when material is changed
  110783. */
  110784. onMaterialChangedObservable: Observable<AbstractMesh>;
  110785. /**
  110786. * Gets or sets the orientation for POV movement & rotation
  110787. */
  110788. definedFacingForward: boolean;
  110789. /** @hidden */
  110790. _occlusionQuery: Nullable<WebGLQuery>;
  110791. /** @hidden */
  110792. _renderingGroup: Nullable<RenderingGroup>;
  110793. /**
  110794. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110795. */
  110796. get visibility(): number;
  110797. /**
  110798. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110799. */
  110800. set visibility(value: number);
  110801. /** Gets or sets the alpha index used to sort transparent meshes
  110802. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  110803. */
  110804. alphaIndex: number;
  110805. /**
  110806. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  110807. */
  110808. isVisible: boolean;
  110809. /**
  110810. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  110811. */
  110812. isPickable: boolean;
  110813. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  110814. showSubMeshesBoundingBox: boolean;
  110815. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  110816. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110817. */
  110818. isBlocker: boolean;
  110819. /**
  110820. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  110821. */
  110822. enablePointerMoveEvents: boolean;
  110823. /**
  110824. * Specifies the rendering group id for this mesh (0 by default)
  110825. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  110826. */
  110827. renderingGroupId: number;
  110828. private _material;
  110829. /** Gets or sets current material */
  110830. get material(): Nullable<Material>;
  110831. set material(value: Nullable<Material>);
  110832. /**
  110833. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  110834. * @see https://doc.babylonjs.com/babylon101/shadows
  110835. */
  110836. get receiveShadows(): boolean;
  110837. set receiveShadows(value: boolean);
  110838. /** Defines color to use when rendering outline */
  110839. outlineColor: Color3;
  110840. /** Define width to use when rendering outline */
  110841. outlineWidth: number;
  110842. /** Defines color to use when rendering overlay */
  110843. overlayColor: Color3;
  110844. /** Defines alpha to use when rendering overlay */
  110845. overlayAlpha: number;
  110846. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  110847. get hasVertexAlpha(): boolean;
  110848. set hasVertexAlpha(value: boolean);
  110849. /** 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) */
  110850. get useVertexColors(): boolean;
  110851. set useVertexColors(value: boolean);
  110852. /**
  110853. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  110854. */
  110855. get computeBonesUsingShaders(): boolean;
  110856. set computeBonesUsingShaders(value: boolean);
  110857. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  110858. get numBoneInfluencers(): number;
  110859. set numBoneInfluencers(value: number);
  110860. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  110861. get applyFog(): boolean;
  110862. set applyFog(value: boolean);
  110863. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  110864. useOctreeForRenderingSelection: boolean;
  110865. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  110866. useOctreeForPicking: boolean;
  110867. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  110868. useOctreeForCollisions: boolean;
  110869. /**
  110870. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  110871. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  110872. */
  110873. get layerMask(): number;
  110874. set layerMask(value: number);
  110875. /**
  110876. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  110877. */
  110878. alwaysSelectAsActiveMesh: boolean;
  110879. /**
  110880. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  110881. */
  110882. doNotSyncBoundingInfo: boolean;
  110883. /**
  110884. * Gets or sets the current action manager
  110885. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110886. */
  110887. actionManager: Nullable<AbstractActionManager>;
  110888. private _meshCollisionData;
  110889. /**
  110890. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  110891. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110892. */
  110893. ellipsoid: Vector3;
  110894. /**
  110895. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  110896. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110897. */
  110898. ellipsoidOffset: Vector3;
  110899. /**
  110900. * Gets or sets a collision mask used to mask collisions (default is -1).
  110901. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110902. */
  110903. get collisionMask(): number;
  110904. set collisionMask(mask: number);
  110905. /**
  110906. * Gets or sets the current collision group mask (-1 by default).
  110907. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110908. */
  110909. get collisionGroup(): number;
  110910. set collisionGroup(mask: number);
  110911. /**
  110912. * Gets or sets current surrounding meshes (null by default).
  110913. *
  110914. * By default collision detection is tested against every mesh in the scene.
  110915. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  110916. * meshes will be tested for the collision.
  110917. *
  110918. * Note: if set to an empty array no collision will happen when this mesh is moved.
  110919. */
  110920. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  110921. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  110922. /**
  110923. * Defines edge width used when edgesRenderer is enabled
  110924. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110925. */
  110926. edgesWidth: number;
  110927. /**
  110928. * Defines edge color used when edgesRenderer is enabled
  110929. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110930. */
  110931. edgesColor: Color4;
  110932. /** @hidden */
  110933. _edgesRenderer: Nullable<IEdgesRenderer>;
  110934. /** @hidden */
  110935. _masterMesh: Nullable<AbstractMesh>;
  110936. /** @hidden */
  110937. _boundingInfo: Nullable<BoundingInfo>;
  110938. /** @hidden */
  110939. _renderId: number;
  110940. /**
  110941. * Gets or sets the list of subMeshes
  110942. * @see https://doc.babylonjs.com/how_to/multi_materials
  110943. */
  110944. subMeshes: SubMesh[];
  110945. /** @hidden */
  110946. _intersectionsInProgress: AbstractMesh[];
  110947. /** @hidden */
  110948. _unIndexed: boolean;
  110949. /** @hidden */
  110950. _lightSources: Light[];
  110951. /** Gets the list of lights affecting that mesh */
  110952. get lightSources(): Light[];
  110953. /** @hidden */
  110954. get _positions(): Nullable<Vector3[]>;
  110955. /** @hidden */
  110956. _waitingData: {
  110957. lods: Nullable<any>;
  110958. actions: Nullable<any>;
  110959. freezeWorldMatrix: Nullable<boolean>;
  110960. };
  110961. /** @hidden */
  110962. _bonesTransformMatrices: Nullable<Float32Array>;
  110963. /** @hidden */
  110964. _transformMatrixTexture: Nullable<RawTexture>;
  110965. /**
  110966. * Gets or sets a skeleton to apply skining transformations
  110967. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110968. */
  110969. set skeleton(value: Nullable<Skeleton>);
  110970. get skeleton(): Nullable<Skeleton>;
  110971. /**
  110972. * An event triggered when the mesh is rebuilt.
  110973. */
  110974. onRebuildObservable: Observable<AbstractMesh>;
  110975. /**
  110976. * Creates a new AbstractMesh
  110977. * @param name defines the name of the mesh
  110978. * @param scene defines the hosting scene
  110979. */
  110980. constructor(name: string, scene?: Nullable<Scene>);
  110981. /**
  110982. * Returns the string "AbstractMesh"
  110983. * @returns "AbstractMesh"
  110984. */
  110985. getClassName(): string;
  110986. /**
  110987. * Gets a string representation of the current mesh
  110988. * @param fullDetails defines a boolean indicating if full details must be included
  110989. * @returns a string representation of the current mesh
  110990. */
  110991. toString(fullDetails?: boolean): string;
  110992. /**
  110993. * @hidden
  110994. */
  110995. protected _getEffectiveParent(): Nullable<Node>;
  110996. /** @hidden */
  110997. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110998. /** @hidden */
  110999. _rebuild(): void;
  111000. /** @hidden */
  111001. _resyncLightSources(): void;
  111002. /** @hidden */
  111003. _resyncLightSource(light: Light): void;
  111004. /** @hidden */
  111005. _unBindEffect(): void;
  111006. /** @hidden */
  111007. _removeLightSource(light: Light, dispose: boolean): void;
  111008. private _markSubMeshesAsDirty;
  111009. /** @hidden */
  111010. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  111011. /** @hidden */
  111012. _markSubMeshesAsAttributesDirty(): void;
  111013. /** @hidden */
  111014. _markSubMeshesAsMiscDirty(): void;
  111015. /**
  111016. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  111017. */
  111018. get scaling(): Vector3;
  111019. set scaling(newScaling: Vector3);
  111020. /**
  111021. * Returns true if the mesh is blocked. Implemented by child classes
  111022. */
  111023. get isBlocked(): boolean;
  111024. /**
  111025. * Returns the mesh itself by default. Implemented by child classes
  111026. * @param camera defines the camera to use to pick the right LOD level
  111027. * @returns the currentAbstractMesh
  111028. */
  111029. getLOD(camera: Camera): Nullable<AbstractMesh>;
  111030. /**
  111031. * Returns 0 by default. Implemented by child classes
  111032. * @returns an integer
  111033. */
  111034. getTotalVertices(): number;
  111035. /**
  111036. * Returns a positive integer : the total number of indices in this mesh geometry.
  111037. * @returns the numner of indices or zero if the mesh has no geometry.
  111038. */
  111039. getTotalIndices(): number;
  111040. /**
  111041. * Returns null by default. Implemented by child classes
  111042. * @returns null
  111043. */
  111044. getIndices(): Nullable<IndicesArray>;
  111045. /**
  111046. * Returns the array of the requested vertex data kind. Implemented by child classes
  111047. * @param kind defines the vertex data kind to use
  111048. * @returns null
  111049. */
  111050. getVerticesData(kind: string): Nullable<FloatArray>;
  111051. /**
  111052. * Sets the vertex data of the mesh geometry for the requested `kind`.
  111053. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  111054. * Note that a new underlying VertexBuffer object is created each call.
  111055. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  111056. * @param kind defines vertex data kind:
  111057. * * VertexBuffer.PositionKind
  111058. * * VertexBuffer.UVKind
  111059. * * VertexBuffer.UV2Kind
  111060. * * VertexBuffer.UV3Kind
  111061. * * VertexBuffer.UV4Kind
  111062. * * VertexBuffer.UV5Kind
  111063. * * VertexBuffer.UV6Kind
  111064. * * VertexBuffer.ColorKind
  111065. * * VertexBuffer.MatricesIndicesKind
  111066. * * VertexBuffer.MatricesIndicesExtraKind
  111067. * * VertexBuffer.MatricesWeightsKind
  111068. * * VertexBuffer.MatricesWeightsExtraKind
  111069. * @param data defines the data source
  111070. * @param updatable defines if the data must be flagged as updatable (or static)
  111071. * @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
  111072. * @returns the current mesh
  111073. */
  111074. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  111075. /**
  111076. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  111077. * If the mesh has no geometry, it is simply returned as it is.
  111078. * @param kind defines vertex data kind:
  111079. * * VertexBuffer.PositionKind
  111080. * * VertexBuffer.UVKind
  111081. * * VertexBuffer.UV2Kind
  111082. * * VertexBuffer.UV3Kind
  111083. * * VertexBuffer.UV4Kind
  111084. * * VertexBuffer.UV5Kind
  111085. * * VertexBuffer.UV6Kind
  111086. * * VertexBuffer.ColorKind
  111087. * * VertexBuffer.MatricesIndicesKind
  111088. * * VertexBuffer.MatricesIndicesExtraKind
  111089. * * VertexBuffer.MatricesWeightsKind
  111090. * * VertexBuffer.MatricesWeightsExtraKind
  111091. * @param data defines the data source
  111092. * @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
  111093. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  111094. * @returns the current mesh
  111095. */
  111096. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  111097. /**
  111098. * Sets the mesh indices,
  111099. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  111100. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  111101. * @param totalVertices Defines the total number of vertices
  111102. * @returns the current mesh
  111103. */
  111104. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  111105. /**
  111106. * Gets a boolean indicating if specific vertex data is present
  111107. * @param kind defines the vertex data kind to use
  111108. * @returns true is data kind is present
  111109. */
  111110. isVerticesDataPresent(kind: string): boolean;
  111111. /**
  111112. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  111113. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  111114. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  111115. * @returns a BoundingInfo
  111116. */
  111117. getBoundingInfo(): BoundingInfo;
  111118. /**
  111119. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111120. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111121. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111122. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111123. * @returns the current mesh
  111124. */
  111125. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  111126. /**
  111127. * Overwrite the current bounding info
  111128. * @param boundingInfo defines the new bounding info
  111129. * @returns the current mesh
  111130. */
  111131. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  111132. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  111133. get useBones(): boolean;
  111134. /** @hidden */
  111135. _preActivate(): void;
  111136. /** @hidden */
  111137. _preActivateForIntermediateRendering(renderId: number): void;
  111138. /** @hidden */
  111139. _activate(renderId: number, intermediateRendering: boolean): boolean;
  111140. /** @hidden */
  111141. _postActivate(): void;
  111142. /** @hidden */
  111143. _freeze(): void;
  111144. /** @hidden */
  111145. _unFreeze(): void;
  111146. /**
  111147. * Gets the current world matrix
  111148. * @returns a Matrix
  111149. */
  111150. getWorldMatrix(): Matrix;
  111151. /** @hidden */
  111152. _getWorldMatrixDeterminant(): number;
  111153. /**
  111154. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  111155. */
  111156. get isAnInstance(): boolean;
  111157. /**
  111158. * Gets a boolean indicating if this mesh has instances
  111159. */
  111160. get hasInstances(): boolean;
  111161. /**
  111162. * Gets a boolean indicating if this mesh has thin instances
  111163. */
  111164. get hasThinInstances(): boolean;
  111165. /**
  111166. * Perform relative position change from the point of view of behind the front of the mesh.
  111167. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111168. * Supports definition of mesh facing forward or backward
  111169. * @param amountRight defines the distance on the right axis
  111170. * @param amountUp defines the distance on the up axis
  111171. * @param amountForward defines the distance on the forward axis
  111172. * @returns the current mesh
  111173. */
  111174. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  111175. /**
  111176. * Calculate relative position change from the point of view of behind the front of the mesh.
  111177. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111178. * Supports definition of mesh facing forward or backward
  111179. * @param amountRight defines the distance on the right axis
  111180. * @param amountUp defines the distance on the up axis
  111181. * @param amountForward defines the distance on the forward axis
  111182. * @returns the new displacement vector
  111183. */
  111184. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  111185. /**
  111186. * Perform relative rotation change from the point of view of behind the front of the mesh.
  111187. * Supports definition of mesh facing forward or backward
  111188. * @param flipBack defines the flip
  111189. * @param twirlClockwise defines the twirl
  111190. * @param tiltRight defines the tilt
  111191. * @returns the current mesh
  111192. */
  111193. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  111194. /**
  111195. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  111196. * Supports definition of mesh facing forward or backward.
  111197. * @param flipBack defines the flip
  111198. * @param twirlClockwise defines the twirl
  111199. * @param tiltRight defines the tilt
  111200. * @returns the new rotation vector
  111201. */
  111202. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  111203. /**
  111204. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  111205. * This means the mesh underlying bounding box and sphere are recomputed.
  111206. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  111207. * @returns the current mesh
  111208. */
  111209. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  111210. /** @hidden */
  111211. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  111212. /** @hidden */
  111213. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  111214. /** @hidden */
  111215. _updateBoundingInfo(): AbstractMesh;
  111216. /** @hidden */
  111217. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  111218. /** @hidden */
  111219. protected _afterComputeWorldMatrix(): void;
  111220. /** @hidden */
  111221. get _effectiveMesh(): AbstractMesh;
  111222. /**
  111223. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  111224. * A mesh is in the frustum if its bounding box intersects the frustum
  111225. * @param frustumPlanes defines the frustum to test
  111226. * @returns true if the mesh is in the frustum planes
  111227. */
  111228. isInFrustum(frustumPlanes: Plane[]): boolean;
  111229. /**
  111230. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  111231. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  111232. * @param frustumPlanes defines the frustum to test
  111233. * @returns true if the mesh is completely in the frustum planes
  111234. */
  111235. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111236. /**
  111237. * True if the mesh intersects another mesh or a SolidParticle object
  111238. * @param mesh defines a target mesh or SolidParticle to test
  111239. * @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)
  111240. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  111241. * @returns true if there is an intersection
  111242. */
  111243. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  111244. /**
  111245. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  111246. * @param point defines the point to test
  111247. * @returns true if there is an intersection
  111248. */
  111249. intersectsPoint(point: Vector3): boolean;
  111250. /**
  111251. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  111252. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111253. */
  111254. get checkCollisions(): boolean;
  111255. set checkCollisions(collisionEnabled: boolean);
  111256. /**
  111257. * Gets Collider object used to compute collisions (not physics)
  111258. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111259. */
  111260. get collider(): Nullable<Collider>;
  111261. /**
  111262. * Move the mesh using collision engine
  111263. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111264. * @param displacement defines the requested displacement vector
  111265. * @returns the current mesh
  111266. */
  111267. moveWithCollisions(displacement: Vector3): AbstractMesh;
  111268. private _onCollisionPositionChange;
  111269. /** @hidden */
  111270. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  111271. /** @hidden */
  111272. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  111273. /** @hidden */
  111274. _checkCollision(collider: Collider): AbstractMesh;
  111275. /** @hidden */
  111276. _generatePointsArray(): boolean;
  111277. /**
  111278. * Checks if the passed Ray intersects with the mesh
  111279. * @param ray defines the ray to use
  111280. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  111281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111282. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  111283. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  111284. * @returns the picking info
  111285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  111286. */
  111287. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  111288. /**
  111289. * Clones the current mesh
  111290. * @param name defines the mesh name
  111291. * @param newParent defines the new mesh parent
  111292. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  111293. * @returns the new mesh
  111294. */
  111295. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  111296. /**
  111297. * Disposes all the submeshes of the current meshnp
  111298. * @returns the current mesh
  111299. */
  111300. releaseSubMeshes(): AbstractMesh;
  111301. /**
  111302. * Releases resources associated with this abstract mesh.
  111303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111305. */
  111306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111307. /**
  111308. * Adds the passed mesh as a child to the current mesh
  111309. * @param mesh defines the child mesh
  111310. * @returns the current mesh
  111311. */
  111312. addChild(mesh: AbstractMesh): AbstractMesh;
  111313. /**
  111314. * Removes the passed mesh from the current mesh children list
  111315. * @param mesh defines the child mesh
  111316. * @returns the current mesh
  111317. */
  111318. removeChild(mesh: AbstractMesh): AbstractMesh;
  111319. /** @hidden */
  111320. private _initFacetData;
  111321. /**
  111322. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  111323. * This method can be called within the render loop.
  111324. * 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
  111325. * @returns the current mesh
  111326. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111327. */
  111328. updateFacetData(): AbstractMesh;
  111329. /**
  111330. * Returns the facetLocalNormals array.
  111331. * The normals are expressed in the mesh local spac
  111332. * @returns an array of Vector3
  111333. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111334. */
  111335. getFacetLocalNormals(): Vector3[];
  111336. /**
  111337. * Returns the facetLocalPositions array.
  111338. * The facet positions are expressed in the mesh local space
  111339. * @returns an array of Vector3
  111340. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111341. */
  111342. getFacetLocalPositions(): Vector3[];
  111343. /**
  111344. * Returns the facetLocalPartioning array
  111345. * @returns an array of array of numbers
  111346. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111347. */
  111348. getFacetLocalPartitioning(): number[][];
  111349. /**
  111350. * Returns the i-th facet position in the world system.
  111351. * This method allocates a new Vector3 per call
  111352. * @param i defines the facet index
  111353. * @returns a new Vector3
  111354. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111355. */
  111356. getFacetPosition(i: number): Vector3;
  111357. /**
  111358. * Sets the reference Vector3 with the i-th facet position in the world system
  111359. * @param i defines the facet index
  111360. * @param ref defines the target vector
  111361. * @returns the current mesh
  111362. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111363. */
  111364. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  111365. /**
  111366. * Returns the i-th facet normal in the world system.
  111367. * This method allocates a new Vector3 per call
  111368. * @param i defines the facet index
  111369. * @returns a new Vector3
  111370. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111371. */
  111372. getFacetNormal(i: number): Vector3;
  111373. /**
  111374. * Sets the reference Vector3 with the i-th facet normal in the world system
  111375. * @param i defines the facet index
  111376. * @param ref defines the target vector
  111377. * @returns the current mesh
  111378. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111379. */
  111380. getFacetNormalToRef(i: number, ref: Vector3): this;
  111381. /**
  111382. * 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)
  111383. * @param x defines x coordinate
  111384. * @param y defines y coordinate
  111385. * @param z defines z coordinate
  111386. * @returns the array of facet indexes
  111387. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111388. */
  111389. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111390. /**
  111391. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111392. * @param projected sets as the (x,y,z) world projection on the facet
  111393. * @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
  111394. * @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
  111395. * @param x defines x coordinate
  111396. * @param y defines y coordinate
  111397. * @param z defines z coordinate
  111398. * @returns the face index if found (or null instead)
  111399. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111400. */
  111401. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111402. /**
  111403. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111404. * @param projected sets as the (x,y,z) local projection on the facet
  111405. * @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
  111406. * @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
  111407. * @param x defines x coordinate
  111408. * @param y defines y coordinate
  111409. * @param z defines z coordinate
  111410. * @returns the face index if found (or null instead)
  111411. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111412. */
  111413. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111414. /**
  111415. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  111416. * @returns the parameters
  111417. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111418. */
  111419. getFacetDataParameters(): any;
  111420. /**
  111421. * Disables the feature FacetData and frees the related memory
  111422. * @returns the current mesh
  111423. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111424. */
  111425. disableFacetData(): AbstractMesh;
  111426. /**
  111427. * Updates the AbstractMesh indices array
  111428. * @param indices defines the data source
  111429. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  111430. * @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)
  111431. * @returns the current mesh
  111432. */
  111433. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  111434. /**
  111435. * Creates new normals data for the mesh
  111436. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  111437. * @returns the current mesh
  111438. */
  111439. createNormals(updatable: boolean): AbstractMesh;
  111440. /**
  111441. * Align the mesh with a normal
  111442. * @param normal defines the normal to use
  111443. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  111444. * @returns the current mesh
  111445. */
  111446. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  111447. /** @hidden */
  111448. _checkOcclusionQuery(): boolean;
  111449. /**
  111450. * Disables the mesh edge rendering mode
  111451. * @returns the currentAbstractMesh
  111452. */
  111453. disableEdgesRendering(): AbstractMesh;
  111454. /**
  111455. * Enables the edge rendering mode on the mesh.
  111456. * This mode makes the mesh edges visible
  111457. * @param epsilon defines the maximal distance between two angles to detect a face
  111458. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  111459. * @returns the currentAbstractMesh
  111460. * @see https://www.babylonjs-playground.com/#19O9TU#0
  111461. */
  111462. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  111463. /**
  111464. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  111465. * @returns an array of particle systems in the scene that use the mesh as an emitter
  111466. */
  111467. getConnectedParticleSystems(): IParticleSystem[];
  111468. }
  111469. }
  111470. declare module BABYLON {
  111471. /**
  111472. * Interface used to define ActionEvent
  111473. */
  111474. export interface IActionEvent {
  111475. /** The mesh or sprite that triggered the action */
  111476. source: any;
  111477. /** The X mouse cursor position at the time of the event */
  111478. pointerX: number;
  111479. /** The Y mouse cursor position at the time of the event */
  111480. pointerY: number;
  111481. /** The mesh that is currently pointed at (can be null) */
  111482. meshUnderPointer: Nullable<AbstractMesh>;
  111483. /** the original (browser) event that triggered the ActionEvent */
  111484. sourceEvent?: any;
  111485. /** additional data for the event */
  111486. additionalData?: any;
  111487. }
  111488. /**
  111489. * ActionEvent is the event being sent when an action is triggered.
  111490. */
  111491. export class ActionEvent implements IActionEvent {
  111492. /** The mesh or sprite that triggered the action */
  111493. source: any;
  111494. /** The X mouse cursor position at the time of the event */
  111495. pointerX: number;
  111496. /** The Y mouse cursor position at the time of the event */
  111497. pointerY: number;
  111498. /** The mesh that is currently pointed at (can be null) */
  111499. meshUnderPointer: Nullable<AbstractMesh>;
  111500. /** the original (browser) event that triggered the ActionEvent */
  111501. sourceEvent?: any;
  111502. /** additional data for the event */
  111503. additionalData?: any;
  111504. /**
  111505. * Creates a new ActionEvent
  111506. * @param source The mesh or sprite that triggered the action
  111507. * @param pointerX The X mouse cursor position at the time of the event
  111508. * @param pointerY The Y mouse cursor position at the time of the event
  111509. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  111510. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  111511. * @param additionalData additional data for the event
  111512. */
  111513. constructor(
  111514. /** The mesh or sprite that triggered the action */
  111515. source: any,
  111516. /** The X mouse cursor position at the time of the event */
  111517. pointerX: number,
  111518. /** The Y mouse cursor position at the time of the event */
  111519. pointerY: number,
  111520. /** The mesh that is currently pointed at (can be null) */
  111521. meshUnderPointer: Nullable<AbstractMesh>,
  111522. /** the original (browser) event that triggered the ActionEvent */
  111523. sourceEvent?: any,
  111524. /** additional data for the event */
  111525. additionalData?: any);
  111526. /**
  111527. * Helper function to auto-create an ActionEvent from a source mesh.
  111528. * @param source The source mesh that triggered the event
  111529. * @param evt The original (browser) event
  111530. * @param additionalData additional data for the event
  111531. * @returns the new ActionEvent
  111532. */
  111533. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  111534. /**
  111535. * Helper function to auto-create an ActionEvent from a source sprite
  111536. * @param source The source sprite that triggered the event
  111537. * @param scene Scene associated with the sprite
  111538. * @param evt The original (browser) event
  111539. * @param additionalData additional data for the event
  111540. * @returns the new ActionEvent
  111541. */
  111542. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  111543. /**
  111544. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  111545. * @param scene the scene where the event occurred
  111546. * @param evt The original (browser) event
  111547. * @returns the new ActionEvent
  111548. */
  111549. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  111550. /**
  111551. * Helper function to auto-create an ActionEvent from a primitive
  111552. * @param prim defines the target primitive
  111553. * @param pointerPos defines the pointer position
  111554. * @param evt The original (browser) event
  111555. * @param additionalData additional data for the event
  111556. * @returns the new ActionEvent
  111557. */
  111558. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  111559. }
  111560. }
  111561. declare module BABYLON {
  111562. /**
  111563. * Abstract class used to decouple action Manager from scene and meshes.
  111564. * Do not instantiate.
  111565. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111566. */
  111567. export abstract class AbstractActionManager implements IDisposable {
  111568. /** Gets the list of active triggers */
  111569. static Triggers: {
  111570. [key: string]: number;
  111571. };
  111572. /** Gets the cursor to use when hovering items */
  111573. hoverCursor: string;
  111574. /** Gets the list of actions */
  111575. actions: IAction[];
  111576. /**
  111577. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  111578. */
  111579. isRecursive: boolean;
  111580. /**
  111581. * Releases all associated resources
  111582. */
  111583. abstract dispose(): void;
  111584. /**
  111585. * Does this action manager has pointer triggers
  111586. */
  111587. abstract get hasPointerTriggers(): boolean;
  111588. /**
  111589. * Does this action manager has pick triggers
  111590. */
  111591. abstract get hasPickTriggers(): boolean;
  111592. /**
  111593. * Process a specific trigger
  111594. * @param trigger defines the trigger to process
  111595. * @param evt defines the event details to be processed
  111596. */
  111597. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  111598. /**
  111599. * Does this action manager handles actions of any of the given triggers
  111600. * @param triggers defines the triggers to be tested
  111601. * @return a boolean indicating whether one (or more) of the triggers is handled
  111602. */
  111603. abstract hasSpecificTriggers(triggers: number[]): boolean;
  111604. /**
  111605. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  111606. * speed.
  111607. * @param triggerA defines the trigger to be tested
  111608. * @param triggerB defines the trigger to be tested
  111609. * @return a boolean indicating whether one (or more) of the triggers is handled
  111610. */
  111611. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  111612. /**
  111613. * Does this action manager handles actions of a given trigger
  111614. * @param trigger defines the trigger to be tested
  111615. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  111616. * @return whether the trigger is handled
  111617. */
  111618. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  111619. /**
  111620. * Serialize this manager to a JSON object
  111621. * @param name defines the property name to store this manager
  111622. * @returns a JSON representation of this manager
  111623. */
  111624. abstract serialize(name: string): any;
  111625. /**
  111626. * Registers an action to this action manager
  111627. * @param action defines the action to be registered
  111628. * @return the action amended (prepared) after registration
  111629. */
  111630. abstract registerAction(action: IAction): Nullable<IAction>;
  111631. /**
  111632. * Unregisters an action to this action manager
  111633. * @param action defines the action to be unregistered
  111634. * @return a boolean indicating whether the action has been unregistered
  111635. */
  111636. abstract unregisterAction(action: IAction): Boolean;
  111637. /**
  111638. * Does exist one action manager with at least one trigger
  111639. **/
  111640. static get HasTriggers(): boolean;
  111641. /**
  111642. * Does exist one action manager with at least one pick trigger
  111643. **/
  111644. static get HasPickTriggers(): boolean;
  111645. /**
  111646. * Does exist one action manager that handles actions of a given trigger
  111647. * @param trigger defines the trigger to be tested
  111648. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  111649. **/
  111650. static HasSpecificTrigger(trigger: number): boolean;
  111651. }
  111652. }
  111653. declare module BABYLON {
  111654. /**
  111655. * Defines how a node can be built from a string name.
  111656. */
  111657. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  111658. /**
  111659. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  111660. */
  111661. export class Node implements IBehaviorAware<Node> {
  111662. /** @hidden */
  111663. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  111664. private static _NodeConstructors;
  111665. /**
  111666. * Add a new node constructor
  111667. * @param type defines the type name of the node to construct
  111668. * @param constructorFunc defines the constructor function
  111669. */
  111670. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  111671. /**
  111672. * Returns a node constructor based on type name
  111673. * @param type defines the type name
  111674. * @param name defines the new node name
  111675. * @param scene defines the hosting scene
  111676. * @param options defines optional options to transmit to constructors
  111677. * @returns the new constructor or null
  111678. */
  111679. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  111680. /**
  111681. * Gets or sets the name of the node
  111682. */
  111683. name: string;
  111684. /**
  111685. * Gets or sets the id of the node
  111686. */
  111687. id: string;
  111688. /**
  111689. * Gets or sets the unique id of the node
  111690. */
  111691. uniqueId: number;
  111692. /**
  111693. * Gets or sets a string used to store user defined state for the node
  111694. */
  111695. state: string;
  111696. /**
  111697. * Gets or sets an object used to store user defined information for the node
  111698. */
  111699. metadata: any;
  111700. /**
  111701. * For internal use only. Please do not use.
  111702. */
  111703. reservedDataStore: any;
  111704. /**
  111705. * List of inspectable custom properties (used by the Inspector)
  111706. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111707. */
  111708. inspectableCustomProperties: IInspectable[];
  111709. private _doNotSerialize;
  111710. /**
  111711. * Gets or sets a boolean used to define if the node must be serialized
  111712. */
  111713. get doNotSerialize(): boolean;
  111714. set doNotSerialize(value: boolean);
  111715. /** @hidden */
  111716. _isDisposed: boolean;
  111717. /**
  111718. * Gets a list of Animations associated with the node
  111719. */
  111720. animations: Animation[];
  111721. protected _ranges: {
  111722. [name: string]: Nullable<AnimationRange>;
  111723. };
  111724. /**
  111725. * Callback raised when the node is ready to be used
  111726. */
  111727. onReady: Nullable<(node: Node) => void>;
  111728. private _isEnabled;
  111729. private _isParentEnabled;
  111730. private _isReady;
  111731. /** @hidden */
  111732. _currentRenderId: number;
  111733. private _parentUpdateId;
  111734. /** @hidden */
  111735. _childUpdateId: number;
  111736. /** @hidden */
  111737. _waitingParentId: Nullable<string>;
  111738. /** @hidden */
  111739. _scene: Scene;
  111740. /** @hidden */
  111741. _cache: any;
  111742. private _parentNode;
  111743. private _children;
  111744. /** @hidden */
  111745. _worldMatrix: Matrix;
  111746. /** @hidden */
  111747. _worldMatrixDeterminant: number;
  111748. /** @hidden */
  111749. _worldMatrixDeterminantIsDirty: boolean;
  111750. /** @hidden */
  111751. private _sceneRootNodesIndex;
  111752. /**
  111753. * Gets a boolean indicating if the node has been disposed
  111754. * @returns true if the node was disposed
  111755. */
  111756. isDisposed(): boolean;
  111757. /**
  111758. * Gets or sets the parent of the node (without keeping the current position in the scene)
  111759. * @see https://doc.babylonjs.com/how_to/parenting
  111760. */
  111761. set parent(parent: Nullable<Node>);
  111762. get parent(): Nullable<Node>;
  111763. /** @hidden */
  111764. _addToSceneRootNodes(): void;
  111765. /** @hidden */
  111766. _removeFromSceneRootNodes(): void;
  111767. private _animationPropertiesOverride;
  111768. /**
  111769. * Gets or sets the animation properties override
  111770. */
  111771. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111772. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111773. /**
  111774. * Gets a string idenfifying the name of the class
  111775. * @returns "Node" string
  111776. */
  111777. getClassName(): string;
  111778. /** @hidden */
  111779. readonly _isNode: boolean;
  111780. /**
  111781. * An event triggered when the mesh is disposed
  111782. */
  111783. onDisposeObservable: Observable<Node>;
  111784. private _onDisposeObserver;
  111785. /**
  111786. * Sets a callback that will be raised when the node will be disposed
  111787. */
  111788. set onDispose(callback: () => void);
  111789. /**
  111790. * Creates a new Node
  111791. * @param name the name and id to be given to this node
  111792. * @param scene the scene this node will be added to
  111793. */
  111794. constructor(name: string, scene?: Nullable<Scene>);
  111795. /**
  111796. * Gets the scene of the node
  111797. * @returns a scene
  111798. */
  111799. getScene(): Scene;
  111800. /**
  111801. * Gets the engine of the node
  111802. * @returns a Engine
  111803. */
  111804. getEngine(): Engine;
  111805. private _behaviors;
  111806. /**
  111807. * Attach a behavior to the node
  111808. * @see https://doc.babylonjs.com/features/behaviour
  111809. * @param behavior defines the behavior to attach
  111810. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  111811. * @returns the current Node
  111812. */
  111813. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  111814. /**
  111815. * Remove an attached behavior
  111816. * @see https://doc.babylonjs.com/features/behaviour
  111817. * @param behavior defines the behavior to attach
  111818. * @returns the current Node
  111819. */
  111820. removeBehavior(behavior: Behavior<Node>): Node;
  111821. /**
  111822. * Gets the list of attached behaviors
  111823. * @see https://doc.babylonjs.com/features/behaviour
  111824. */
  111825. get behaviors(): Behavior<Node>[];
  111826. /**
  111827. * Gets an attached behavior by name
  111828. * @param name defines the name of the behavior to look for
  111829. * @see https://doc.babylonjs.com/features/behaviour
  111830. * @returns null if behavior was not found else the requested behavior
  111831. */
  111832. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  111833. /**
  111834. * Returns the latest update of the World matrix
  111835. * @returns a Matrix
  111836. */
  111837. getWorldMatrix(): Matrix;
  111838. /** @hidden */
  111839. _getWorldMatrixDeterminant(): number;
  111840. /**
  111841. * Returns directly the latest state of the mesh World matrix.
  111842. * A Matrix is returned.
  111843. */
  111844. get worldMatrixFromCache(): Matrix;
  111845. /** @hidden */
  111846. _initCache(): void;
  111847. /** @hidden */
  111848. updateCache(force?: boolean): void;
  111849. /** @hidden */
  111850. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111851. /** @hidden */
  111852. _updateCache(ignoreParentClass?: boolean): void;
  111853. /** @hidden */
  111854. _isSynchronized(): boolean;
  111855. /** @hidden */
  111856. _markSyncedWithParent(): void;
  111857. /** @hidden */
  111858. isSynchronizedWithParent(): boolean;
  111859. /** @hidden */
  111860. isSynchronized(): boolean;
  111861. /**
  111862. * Is this node ready to be used/rendered
  111863. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  111864. * @return true if the node is ready
  111865. */
  111866. isReady(completeCheck?: boolean): boolean;
  111867. /**
  111868. * Is this node enabled?
  111869. * 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
  111870. * @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
  111871. * @return whether this node (and its parent) is enabled
  111872. */
  111873. isEnabled(checkAncestors?: boolean): boolean;
  111874. /** @hidden */
  111875. protected _syncParentEnabledState(): void;
  111876. /**
  111877. * Set the enabled state of this node
  111878. * @param value defines the new enabled state
  111879. */
  111880. setEnabled(value: boolean): void;
  111881. /**
  111882. * Is this node a descendant of the given node?
  111883. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  111884. * @param ancestor defines the parent node to inspect
  111885. * @returns a boolean indicating if this node is a descendant of the given node
  111886. */
  111887. isDescendantOf(ancestor: Node): boolean;
  111888. /** @hidden */
  111889. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  111890. /**
  111891. * Will return all nodes that have this node as ascendant
  111892. * @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
  111893. * @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
  111894. * @return all children nodes of all types
  111895. */
  111896. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  111897. /**
  111898. * Get all child-meshes of this node
  111899. * @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)
  111900. * @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
  111901. * @returns an array of AbstractMesh
  111902. */
  111903. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  111904. /**
  111905. * Get all direct children of this node
  111906. * @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
  111907. * @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)
  111908. * @returns an array of Node
  111909. */
  111910. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  111911. /** @hidden */
  111912. _setReady(state: boolean): void;
  111913. /**
  111914. * Get an animation by name
  111915. * @param name defines the name of the animation to look for
  111916. * @returns null if not found else the requested animation
  111917. */
  111918. getAnimationByName(name: string): Nullable<Animation>;
  111919. /**
  111920. * Creates an animation range for this node
  111921. * @param name defines the name of the range
  111922. * @param from defines the starting key
  111923. * @param to defines the end key
  111924. */
  111925. createAnimationRange(name: string, from: number, to: number): void;
  111926. /**
  111927. * Delete a specific animation range
  111928. * @param name defines the name of the range to delete
  111929. * @param deleteFrames defines if animation frames from the range must be deleted as well
  111930. */
  111931. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  111932. /**
  111933. * Get an animation range by name
  111934. * @param name defines the name of the animation range to look for
  111935. * @returns null if not found else the requested animation range
  111936. */
  111937. getAnimationRange(name: string): Nullable<AnimationRange>;
  111938. /**
  111939. * Gets the list of all animation ranges defined on this node
  111940. * @returns an array
  111941. */
  111942. getAnimationRanges(): Nullable<AnimationRange>[];
  111943. /**
  111944. * Will start the animation sequence
  111945. * @param name defines the range frames for animation sequence
  111946. * @param loop defines if the animation should loop (false by default)
  111947. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  111948. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  111949. * @returns the object created for this animation. If range does not exist, it will return null
  111950. */
  111951. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  111952. /**
  111953. * Serialize animation ranges into a JSON compatible object
  111954. * @returns serialization object
  111955. */
  111956. serializeAnimationRanges(): any;
  111957. /**
  111958. * Computes the world matrix of the node
  111959. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111960. * @returns the world matrix
  111961. */
  111962. computeWorldMatrix(force?: boolean): Matrix;
  111963. /**
  111964. * Releases resources associated with this node.
  111965. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111966. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111967. */
  111968. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111969. /**
  111970. * Parse animation range data from a serialization object and store them into a given node
  111971. * @param node defines where to store the animation ranges
  111972. * @param parsedNode defines the serialization object to read data from
  111973. * @param scene defines the hosting scene
  111974. */
  111975. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  111976. /**
  111977. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  111978. * @param includeDescendants Include bounding info from descendants as well (true by default)
  111979. * @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
  111980. * @returns the new bounding vectors
  111981. */
  111982. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  111983. min: Vector3;
  111984. max: Vector3;
  111985. };
  111986. }
  111987. }
  111988. declare module BABYLON {
  111989. /**
  111990. * @hidden
  111991. */
  111992. export class _IAnimationState {
  111993. key: number;
  111994. repeatCount: number;
  111995. workValue?: any;
  111996. loopMode?: number;
  111997. offsetValue?: any;
  111998. highLimitValue?: any;
  111999. }
  112000. /**
  112001. * Class used to store any kind of animation
  112002. */
  112003. export class Animation {
  112004. /**Name of the animation */
  112005. name: string;
  112006. /**Property to animate */
  112007. targetProperty: string;
  112008. /**The frames per second of the animation */
  112009. framePerSecond: number;
  112010. /**The data type of the animation */
  112011. dataType: number;
  112012. /**The loop mode of the animation */
  112013. loopMode?: number | undefined;
  112014. /**Specifies if blending should be enabled */
  112015. enableBlending?: boolean | undefined;
  112016. /**
  112017. * Use matrix interpolation instead of using direct key value when animating matrices
  112018. */
  112019. static AllowMatricesInterpolation: boolean;
  112020. /**
  112021. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  112022. */
  112023. static AllowMatrixDecomposeForInterpolation: boolean;
  112024. /** Define the Url to load snippets */
  112025. static SnippetUrl: string;
  112026. /** Snippet ID if the animation was created from the snippet server */
  112027. snippetId: string;
  112028. /**
  112029. * Stores the key frames of the animation
  112030. */
  112031. private _keys;
  112032. /**
  112033. * Stores the easing function of the animation
  112034. */
  112035. private _easingFunction;
  112036. /**
  112037. * @hidden Internal use only
  112038. */
  112039. _runtimeAnimations: RuntimeAnimation[];
  112040. /**
  112041. * The set of event that will be linked to this animation
  112042. */
  112043. private _events;
  112044. /**
  112045. * Stores an array of target property paths
  112046. */
  112047. targetPropertyPath: string[];
  112048. /**
  112049. * Stores the blending speed of the animation
  112050. */
  112051. blendingSpeed: number;
  112052. /**
  112053. * Stores the animation ranges for the animation
  112054. */
  112055. private _ranges;
  112056. /**
  112057. * @hidden Internal use
  112058. */
  112059. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  112060. /**
  112061. * Sets up an animation
  112062. * @param property The property to animate
  112063. * @param animationType The animation type to apply
  112064. * @param framePerSecond The frames per second of the animation
  112065. * @param easingFunction The easing function used in the animation
  112066. * @returns The created animation
  112067. */
  112068. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  112069. /**
  112070. * Create and start an animation on a node
  112071. * @param name defines the name of the global animation that will be run on all nodes
  112072. * @param node defines the root node where the animation will take place
  112073. * @param targetProperty defines property to animate
  112074. * @param framePerSecond defines the number of frame per second yo use
  112075. * @param totalFrame defines the number of frames in total
  112076. * @param from defines the initial value
  112077. * @param to defines the final value
  112078. * @param loopMode defines which loop mode you want to use (off by default)
  112079. * @param easingFunction defines the easing function to use (linear by default)
  112080. * @param onAnimationEnd defines the callback to call when animation end
  112081. * @returns the animatable created for this animation
  112082. */
  112083. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112084. /**
  112085. * Create and start an animation on a node and its descendants
  112086. * @param name defines the name of the global animation that will be run on all nodes
  112087. * @param node defines the root node where the animation will take place
  112088. * @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
  112089. * @param targetProperty defines property to animate
  112090. * @param framePerSecond defines the number of frame per second to use
  112091. * @param totalFrame defines the number of frames in total
  112092. * @param from defines the initial value
  112093. * @param to defines the final value
  112094. * @param loopMode defines which loop mode you want to use (off by default)
  112095. * @param easingFunction defines the easing function to use (linear by default)
  112096. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  112097. * @returns the list of animatables created for all nodes
  112098. * @example https://www.babylonjs-playground.com/#MH0VLI
  112099. */
  112100. 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[]>;
  112101. /**
  112102. * Creates a new animation, merges it with the existing animations and starts it
  112103. * @param name Name of the animation
  112104. * @param node Node which contains the scene that begins the animations
  112105. * @param targetProperty Specifies which property to animate
  112106. * @param framePerSecond The frames per second of the animation
  112107. * @param totalFrame The total number of frames
  112108. * @param from The frame at the beginning of the animation
  112109. * @param to The frame at the end of the animation
  112110. * @param loopMode Specifies the loop mode of the animation
  112111. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  112112. * @param onAnimationEnd Callback to run once the animation is complete
  112113. * @returns Nullable animation
  112114. */
  112115. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112116. /**
  112117. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  112118. * @param sourceAnimation defines the Animation containing keyframes to convert
  112119. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  112120. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  112121. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  112122. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  112123. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  112124. */
  112125. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  112126. /**
  112127. * Transition property of an host to the target Value
  112128. * @param property The property to transition
  112129. * @param targetValue The target Value of the property
  112130. * @param host The object where the property to animate belongs
  112131. * @param scene Scene used to run the animation
  112132. * @param frameRate Framerate (in frame/s) to use
  112133. * @param transition The transition type we want to use
  112134. * @param duration The duration of the animation, in milliseconds
  112135. * @param onAnimationEnd Callback trigger at the end of the animation
  112136. * @returns Nullable animation
  112137. */
  112138. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  112139. /**
  112140. * Return the array of runtime animations currently using this animation
  112141. */
  112142. get runtimeAnimations(): RuntimeAnimation[];
  112143. /**
  112144. * Specifies if any of the runtime animations are currently running
  112145. */
  112146. get hasRunningRuntimeAnimations(): boolean;
  112147. /**
  112148. * Initializes the animation
  112149. * @param name Name of the animation
  112150. * @param targetProperty Property to animate
  112151. * @param framePerSecond The frames per second of the animation
  112152. * @param dataType The data type of the animation
  112153. * @param loopMode The loop mode of the animation
  112154. * @param enableBlending Specifies if blending should be enabled
  112155. */
  112156. constructor(
  112157. /**Name of the animation */
  112158. name: string,
  112159. /**Property to animate */
  112160. targetProperty: string,
  112161. /**The frames per second of the animation */
  112162. framePerSecond: number,
  112163. /**The data type of the animation */
  112164. dataType: number,
  112165. /**The loop mode of the animation */
  112166. loopMode?: number | undefined,
  112167. /**Specifies if blending should be enabled */
  112168. enableBlending?: boolean | undefined);
  112169. /**
  112170. * Converts the animation to a string
  112171. * @param fullDetails support for multiple levels of logging within scene loading
  112172. * @returns String form of the animation
  112173. */
  112174. toString(fullDetails?: boolean): string;
  112175. /**
  112176. * Add an event to this animation
  112177. * @param event Event to add
  112178. */
  112179. addEvent(event: AnimationEvent): void;
  112180. /**
  112181. * Remove all events found at the given frame
  112182. * @param frame The frame to remove events from
  112183. */
  112184. removeEvents(frame: number): void;
  112185. /**
  112186. * Retrieves all the events from the animation
  112187. * @returns Events from the animation
  112188. */
  112189. getEvents(): AnimationEvent[];
  112190. /**
  112191. * Creates an animation range
  112192. * @param name Name of the animation range
  112193. * @param from Starting frame of the animation range
  112194. * @param to Ending frame of the animation
  112195. */
  112196. createRange(name: string, from: number, to: number): void;
  112197. /**
  112198. * Deletes an animation range by name
  112199. * @param name Name of the animation range to delete
  112200. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  112201. */
  112202. deleteRange(name: string, deleteFrames?: boolean): void;
  112203. /**
  112204. * Gets the animation range by name, or null if not defined
  112205. * @param name Name of the animation range
  112206. * @returns Nullable animation range
  112207. */
  112208. getRange(name: string): Nullable<AnimationRange>;
  112209. /**
  112210. * Gets the key frames from the animation
  112211. * @returns The key frames of the animation
  112212. */
  112213. getKeys(): Array<IAnimationKey>;
  112214. /**
  112215. * Gets the highest frame rate of the animation
  112216. * @returns Highest frame rate of the animation
  112217. */
  112218. getHighestFrame(): number;
  112219. /**
  112220. * Gets the easing function of the animation
  112221. * @returns Easing function of the animation
  112222. */
  112223. getEasingFunction(): IEasingFunction;
  112224. /**
  112225. * Sets the easing function of the animation
  112226. * @param easingFunction A custom mathematical formula for animation
  112227. */
  112228. setEasingFunction(easingFunction: EasingFunction): void;
  112229. /**
  112230. * Interpolates a scalar linearly
  112231. * @param startValue Start value of the animation curve
  112232. * @param endValue End value of the animation curve
  112233. * @param gradient Scalar amount to interpolate
  112234. * @returns Interpolated scalar value
  112235. */
  112236. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  112237. /**
  112238. * Interpolates a scalar cubically
  112239. * @param startValue Start value of the animation curve
  112240. * @param outTangent End tangent of the animation
  112241. * @param endValue End value of the animation curve
  112242. * @param inTangent Start tangent of the animation curve
  112243. * @param gradient Scalar amount to interpolate
  112244. * @returns Interpolated scalar value
  112245. */
  112246. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  112247. /**
  112248. * Interpolates a quaternion using a spherical linear interpolation
  112249. * @param startValue Start value of the animation curve
  112250. * @param endValue End value of the animation curve
  112251. * @param gradient Scalar amount to interpolate
  112252. * @returns Interpolated quaternion value
  112253. */
  112254. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  112255. /**
  112256. * Interpolates a quaternion cubically
  112257. * @param startValue Start value of the animation curve
  112258. * @param outTangent End tangent of the animation curve
  112259. * @param endValue End value of the animation curve
  112260. * @param inTangent Start tangent of the animation curve
  112261. * @param gradient Scalar amount to interpolate
  112262. * @returns Interpolated quaternion value
  112263. */
  112264. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  112265. /**
  112266. * Interpolates a Vector3 linearl
  112267. * @param startValue Start value of the animation curve
  112268. * @param endValue End value of the animation curve
  112269. * @param gradient Scalar amount to interpolate
  112270. * @returns Interpolated scalar value
  112271. */
  112272. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  112273. /**
  112274. * Interpolates a Vector3 cubically
  112275. * @param startValue Start value of the animation curve
  112276. * @param outTangent End tangent of the animation
  112277. * @param endValue End value of the animation curve
  112278. * @param inTangent Start tangent of the animation curve
  112279. * @param gradient Scalar amount to interpolate
  112280. * @returns InterpolatedVector3 value
  112281. */
  112282. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  112283. /**
  112284. * Interpolates a Vector2 linearly
  112285. * @param startValue Start value of the animation curve
  112286. * @param endValue End value of the animation curve
  112287. * @param gradient Scalar amount to interpolate
  112288. * @returns Interpolated Vector2 value
  112289. */
  112290. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  112291. /**
  112292. * Interpolates a Vector2 cubically
  112293. * @param startValue Start value of the animation curve
  112294. * @param outTangent End tangent of the animation
  112295. * @param endValue End value of the animation curve
  112296. * @param inTangent Start tangent of the animation curve
  112297. * @param gradient Scalar amount to interpolate
  112298. * @returns Interpolated Vector2 value
  112299. */
  112300. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  112301. /**
  112302. * Interpolates a size linearly
  112303. * @param startValue Start value of the animation curve
  112304. * @param endValue End value of the animation curve
  112305. * @param gradient Scalar amount to interpolate
  112306. * @returns Interpolated Size value
  112307. */
  112308. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  112309. /**
  112310. * Interpolates a Color3 linearly
  112311. * @param startValue Start value of the animation curve
  112312. * @param endValue End value of the animation curve
  112313. * @param gradient Scalar amount to interpolate
  112314. * @returns Interpolated Color3 value
  112315. */
  112316. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  112317. /**
  112318. * Interpolates a Color4 linearly
  112319. * @param startValue Start value of the animation curve
  112320. * @param endValue End value of the animation curve
  112321. * @param gradient Scalar amount to interpolate
  112322. * @returns Interpolated Color3 value
  112323. */
  112324. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  112325. /**
  112326. * @hidden Internal use only
  112327. */
  112328. _getKeyValue(value: any): any;
  112329. /**
  112330. * @hidden Internal use only
  112331. */
  112332. _interpolate(currentFrame: number, state: _IAnimationState): any;
  112333. /**
  112334. * Defines the function to use to interpolate matrices
  112335. * @param startValue defines the start matrix
  112336. * @param endValue defines the end matrix
  112337. * @param gradient defines the gradient between both matrices
  112338. * @param result defines an optional target matrix where to store the interpolation
  112339. * @returns the interpolated matrix
  112340. */
  112341. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  112342. /**
  112343. * Makes a copy of the animation
  112344. * @returns Cloned animation
  112345. */
  112346. clone(): Animation;
  112347. /**
  112348. * Sets the key frames of the animation
  112349. * @param values The animation key frames to set
  112350. */
  112351. setKeys(values: Array<IAnimationKey>): void;
  112352. /**
  112353. * Serializes the animation to an object
  112354. * @returns Serialized object
  112355. */
  112356. serialize(): any;
  112357. /**
  112358. * Float animation type
  112359. */
  112360. static readonly ANIMATIONTYPE_FLOAT: number;
  112361. /**
  112362. * Vector3 animation type
  112363. */
  112364. static readonly ANIMATIONTYPE_VECTOR3: number;
  112365. /**
  112366. * Quaternion animation type
  112367. */
  112368. static readonly ANIMATIONTYPE_QUATERNION: number;
  112369. /**
  112370. * Matrix animation type
  112371. */
  112372. static readonly ANIMATIONTYPE_MATRIX: number;
  112373. /**
  112374. * Color3 animation type
  112375. */
  112376. static readonly ANIMATIONTYPE_COLOR3: number;
  112377. /**
  112378. * Color3 animation type
  112379. */
  112380. static readonly ANIMATIONTYPE_COLOR4: number;
  112381. /**
  112382. * Vector2 animation type
  112383. */
  112384. static readonly ANIMATIONTYPE_VECTOR2: number;
  112385. /**
  112386. * Size animation type
  112387. */
  112388. static readonly ANIMATIONTYPE_SIZE: number;
  112389. /**
  112390. * Relative Loop Mode
  112391. */
  112392. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112393. /**
  112394. * Cycle Loop Mode
  112395. */
  112396. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112397. /**
  112398. * Constant Loop Mode
  112399. */
  112400. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112401. /** @hidden */
  112402. static _UniversalLerp(left: any, right: any, amount: number): any;
  112403. /**
  112404. * Parses an animation object and creates an animation
  112405. * @param parsedAnimation Parsed animation object
  112406. * @returns Animation object
  112407. */
  112408. static Parse(parsedAnimation: any): Animation;
  112409. /**
  112410. * Appends the serialized animations from the source animations
  112411. * @param source Source containing the animations
  112412. * @param destination Target to store the animations
  112413. */
  112414. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112415. /**
  112416. * Creates a new animation or an array of animations from a snippet saved in a remote file
  112417. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  112418. * @param url defines the url to load from
  112419. * @returns a promise that will resolve to the new animation or an array of animations
  112420. */
  112421. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  112422. /**
  112423. * Creates an animation or an array of animations from a snippet saved by the Inspector
  112424. * @param snippetId defines the snippet to load
  112425. * @returns a promise that will resolve to the new animation or a new array of animations
  112426. */
  112427. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  112428. }
  112429. }
  112430. declare module BABYLON {
  112431. /**
  112432. * Interface containing an array of animations
  112433. */
  112434. export interface IAnimatable {
  112435. /**
  112436. * Array of animations
  112437. */
  112438. animations: Nullable<Array<Animation>>;
  112439. }
  112440. }
  112441. declare module BABYLON {
  112442. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  112443. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112444. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112445. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112446. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112447. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112448. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112449. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112450. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112451. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112452. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112453. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112454. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112455. /**
  112456. * Decorator used to define property that can be serialized as reference to a camera
  112457. * @param sourceName defines the name of the property to decorate
  112458. */
  112459. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112460. /**
  112461. * Class used to help serialization objects
  112462. */
  112463. export class SerializationHelper {
  112464. /** @hidden */
  112465. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  112466. /** @hidden */
  112467. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  112468. /** @hidden */
  112469. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  112470. /** @hidden */
  112471. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  112472. /**
  112473. * Appends the serialized animations from the source animations
  112474. * @param source Source containing the animations
  112475. * @param destination Target to store the animations
  112476. */
  112477. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112478. /**
  112479. * Static function used to serialized a specific entity
  112480. * @param entity defines the entity to serialize
  112481. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  112482. * @returns a JSON compatible object representing the serialization of the entity
  112483. */
  112484. static Serialize<T>(entity: T, serializationObject?: any): any;
  112485. /**
  112486. * Creates a new entity from a serialization data object
  112487. * @param creationFunction defines a function used to instanciated the new entity
  112488. * @param source defines the source serialization data
  112489. * @param scene defines the hosting scene
  112490. * @param rootUrl defines the root url for resources
  112491. * @returns a new entity
  112492. */
  112493. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  112494. /**
  112495. * Clones an object
  112496. * @param creationFunction defines the function used to instanciate the new object
  112497. * @param source defines the source object
  112498. * @returns the cloned object
  112499. */
  112500. static Clone<T>(creationFunction: () => T, source: T): T;
  112501. /**
  112502. * Instanciates a new object based on a source one (some data will be shared between both object)
  112503. * @param creationFunction defines the function used to instanciate the new object
  112504. * @param source defines the source object
  112505. * @returns the new object
  112506. */
  112507. static Instanciate<T>(creationFunction: () => T, source: T): T;
  112508. }
  112509. }
  112510. declare module BABYLON {
  112511. /**
  112512. * Base class of all the textures in babylon.
  112513. * It groups all the common properties the materials, post process, lights... might need
  112514. * in order to make a correct use of the texture.
  112515. */
  112516. export class BaseTexture implements IAnimatable {
  112517. /**
  112518. * Default anisotropic filtering level for the application.
  112519. * It is set to 4 as a good tradeoff between perf and quality.
  112520. */
  112521. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  112522. /**
  112523. * Gets or sets the unique id of the texture
  112524. */
  112525. uniqueId: number;
  112526. /**
  112527. * Define the name of the texture.
  112528. */
  112529. name: string;
  112530. /**
  112531. * Gets or sets an object used to store user defined information.
  112532. */
  112533. metadata: any;
  112534. /**
  112535. * For internal use only. Please do not use.
  112536. */
  112537. reservedDataStore: any;
  112538. private _hasAlpha;
  112539. /**
  112540. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  112541. */
  112542. set hasAlpha(value: boolean);
  112543. get hasAlpha(): boolean;
  112544. /**
  112545. * Defines if the alpha value should be determined via the rgb values.
  112546. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  112547. */
  112548. getAlphaFromRGB: boolean;
  112549. /**
  112550. * Intensity or strength of the texture.
  112551. * It is commonly used by materials to fine tune the intensity of the texture
  112552. */
  112553. level: number;
  112554. /**
  112555. * Define the UV chanel to use starting from 0 and defaulting to 0.
  112556. * This is part of the texture as textures usually maps to one uv set.
  112557. */
  112558. coordinatesIndex: number;
  112559. private _coordinatesMode;
  112560. /**
  112561. * How a texture is mapped.
  112562. *
  112563. * | Value | Type | Description |
  112564. * | ----- | ----------------------------------- | ----------- |
  112565. * | 0 | EXPLICIT_MODE | |
  112566. * | 1 | SPHERICAL_MODE | |
  112567. * | 2 | PLANAR_MODE | |
  112568. * | 3 | CUBIC_MODE | |
  112569. * | 4 | PROJECTION_MODE | |
  112570. * | 5 | SKYBOX_MODE | |
  112571. * | 6 | INVCUBIC_MODE | |
  112572. * | 7 | EQUIRECTANGULAR_MODE | |
  112573. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  112574. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  112575. */
  112576. set coordinatesMode(value: number);
  112577. get coordinatesMode(): number;
  112578. /**
  112579. * | Value | Type | Description |
  112580. * | ----- | ------------------ | ----------- |
  112581. * | 0 | CLAMP_ADDRESSMODE | |
  112582. * | 1 | WRAP_ADDRESSMODE | |
  112583. * | 2 | MIRROR_ADDRESSMODE | |
  112584. */
  112585. wrapU: number;
  112586. /**
  112587. * | Value | Type | Description |
  112588. * | ----- | ------------------ | ----------- |
  112589. * | 0 | CLAMP_ADDRESSMODE | |
  112590. * | 1 | WRAP_ADDRESSMODE | |
  112591. * | 2 | MIRROR_ADDRESSMODE | |
  112592. */
  112593. wrapV: number;
  112594. /**
  112595. * | Value | Type | Description |
  112596. * | ----- | ------------------ | ----------- |
  112597. * | 0 | CLAMP_ADDRESSMODE | |
  112598. * | 1 | WRAP_ADDRESSMODE | |
  112599. * | 2 | MIRROR_ADDRESSMODE | |
  112600. */
  112601. wrapR: number;
  112602. /**
  112603. * With compliant hardware and browser (supporting anisotropic filtering)
  112604. * this defines the level of anisotropic filtering in the texture.
  112605. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  112606. */
  112607. anisotropicFilteringLevel: number;
  112608. /**
  112609. * Define if the texture is a cube texture or if false a 2d texture.
  112610. */
  112611. get isCube(): boolean;
  112612. set isCube(value: boolean);
  112613. /**
  112614. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  112615. */
  112616. get is3D(): boolean;
  112617. set is3D(value: boolean);
  112618. /**
  112619. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  112620. */
  112621. get is2DArray(): boolean;
  112622. set is2DArray(value: boolean);
  112623. /**
  112624. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  112625. * HDR texture are usually stored in linear space.
  112626. * This only impacts the PBR and Background materials
  112627. */
  112628. gammaSpace: boolean;
  112629. /**
  112630. * Gets or sets whether or not the texture contains RGBD data.
  112631. */
  112632. get isRGBD(): boolean;
  112633. set isRGBD(value: boolean);
  112634. /**
  112635. * Is Z inverted in the texture (useful in a cube texture).
  112636. */
  112637. invertZ: boolean;
  112638. /**
  112639. * Are mip maps generated for this texture or not.
  112640. */
  112641. get noMipmap(): boolean;
  112642. /**
  112643. * @hidden
  112644. */
  112645. lodLevelInAlpha: boolean;
  112646. /**
  112647. * With prefiltered texture, defined the offset used during the prefiltering steps.
  112648. */
  112649. get lodGenerationOffset(): number;
  112650. set lodGenerationOffset(value: number);
  112651. /**
  112652. * With prefiltered texture, defined the scale used during the prefiltering steps.
  112653. */
  112654. get lodGenerationScale(): number;
  112655. set lodGenerationScale(value: number);
  112656. /**
  112657. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  112658. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  112659. * average roughness values.
  112660. */
  112661. get linearSpecularLOD(): boolean;
  112662. set linearSpecularLOD(value: boolean);
  112663. /**
  112664. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  112665. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  112666. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  112667. */
  112668. get irradianceTexture(): Nullable<BaseTexture>;
  112669. set irradianceTexture(value: Nullable<BaseTexture>);
  112670. /**
  112671. * Define if the texture is a render target.
  112672. */
  112673. isRenderTarget: boolean;
  112674. /**
  112675. * Define the unique id of the texture in the scene.
  112676. */
  112677. get uid(): string;
  112678. /** @hidden */
  112679. _prefiltered: boolean;
  112680. /**
  112681. * Return a string representation of the texture.
  112682. * @returns the texture as a string
  112683. */
  112684. toString(): string;
  112685. /**
  112686. * Get the class name of the texture.
  112687. * @returns "BaseTexture"
  112688. */
  112689. getClassName(): string;
  112690. /**
  112691. * Define the list of animation attached to the texture.
  112692. */
  112693. animations: Animation[];
  112694. /**
  112695. * An event triggered when the texture is disposed.
  112696. */
  112697. onDisposeObservable: Observable<BaseTexture>;
  112698. private _onDisposeObserver;
  112699. /**
  112700. * Callback triggered when the texture has been disposed.
  112701. * Kept for back compatibility, you can use the onDisposeObservable instead.
  112702. */
  112703. set onDispose(callback: () => void);
  112704. /**
  112705. * Define the current state of the loading sequence when in delayed load mode.
  112706. */
  112707. delayLoadState: number;
  112708. private _scene;
  112709. private _engine;
  112710. /** @hidden */
  112711. _texture: Nullable<InternalTexture>;
  112712. private _uid;
  112713. /**
  112714. * Define if the texture is preventinga material to render or not.
  112715. * If not and the texture is not ready, the engine will use a default black texture instead.
  112716. */
  112717. get isBlocking(): boolean;
  112718. /**
  112719. * Instantiates a new BaseTexture.
  112720. * Base class of all the textures in babylon.
  112721. * It groups all the common properties the materials, post process, lights... might need
  112722. * in order to make a correct use of the texture.
  112723. * @param sceneOrEngine Define the scene or engine the texture blongs to
  112724. */
  112725. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  112726. /**
  112727. * Get the scene the texture belongs to.
  112728. * @returns the scene or null if undefined
  112729. */
  112730. getScene(): Nullable<Scene>;
  112731. /** @hidden */
  112732. protected _getEngine(): Nullable<ThinEngine>;
  112733. /**
  112734. * Get the texture transform matrix used to offset tile the texture for istance.
  112735. * @returns the transformation matrix
  112736. */
  112737. getTextureMatrix(): Matrix;
  112738. /**
  112739. * Get the texture reflection matrix used to rotate/transform the reflection.
  112740. * @returns the reflection matrix
  112741. */
  112742. getReflectionTextureMatrix(): Matrix;
  112743. /**
  112744. * Get the underlying lower level texture from Babylon.
  112745. * @returns the insternal texture
  112746. */
  112747. getInternalTexture(): Nullable<InternalTexture>;
  112748. /**
  112749. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  112750. * @returns true if ready or not blocking
  112751. */
  112752. isReadyOrNotBlocking(): boolean;
  112753. /**
  112754. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  112755. * @returns true if fully ready
  112756. */
  112757. isReady(): boolean;
  112758. private _cachedSize;
  112759. /**
  112760. * Get the size of the texture.
  112761. * @returns the texture size.
  112762. */
  112763. getSize(): ISize;
  112764. /**
  112765. * Get the base size of the texture.
  112766. * It can be different from the size if the texture has been resized for POT for instance
  112767. * @returns the base size
  112768. */
  112769. getBaseSize(): ISize;
  112770. /**
  112771. * Update the sampling mode of the texture.
  112772. * Default is Trilinear mode.
  112773. *
  112774. * | Value | Type | Description |
  112775. * | ----- | ------------------ | ----------- |
  112776. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  112777. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  112778. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  112779. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  112780. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  112781. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  112782. * | 7 | NEAREST_LINEAR | |
  112783. * | 8 | NEAREST_NEAREST | |
  112784. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  112785. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  112786. * | 11 | LINEAR_LINEAR | |
  112787. * | 12 | LINEAR_NEAREST | |
  112788. *
  112789. * > _mag_: magnification filter (close to the viewer)
  112790. * > _min_: minification filter (far from the viewer)
  112791. * > _mip_: filter used between mip map levels
  112792. *@param samplingMode Define the new sampling mode of the texture
  112793. */
  112794. updateSamplingMode(samplingMode: number): void;
  112795. /**
  112796. * Scales the texture if is `canRescale()`
  112797. * @param ratio the resize factor we want to use to rescale
  112798. */
  112799. scale(ratio: number): void;
  112800. /**
  112801. * Get if the texture can rescale.
  112802. */
  112803. get canRescale(): boolean;
  112804. /** @hidden */
  112805. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  112806. /** @hidden */
  112807. _rebuild(): void;
  112808. /**
  112809. * Triggers the load sequence in delayed load mode.
  112810. */
  112811. delayLoad(): void;
  112812. /**
  112813. * Clones the texture.
  112814. * @returns the cloned texture
  112815. */
  112816. clone(): Nullable<BaseTexture>;
  112817. /**
  112818. * Get the texture underlying type (INT, FLOAT...)
  112819. */
  112820. get textureType(): number;
  112821. /**
  112822. * Get the texture underlying format (RGB, RGBA...)
  112823. */
  112824. get textureFormat(): number;
  112825. /**
  112826. * Indicates that textures need to be re-calculated for all materials
  112827. */
  112828. protected _markAllSubMeshesAsTexturesDirty(): void;
  112829. /**
  112830. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  112831. * This will returns an RGBA array buffer containing either in values (0-255) or
  112832. * float values (0-1) depending of the underlying buffer type.
  112833. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  112834. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  112835. * @param buffer defines a user defined buffer to fill with data (can be null)
  112836. * @returns The Array buffer containing the pixels data.
  112837. */
  112838. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  112839. /**
  112840. * Release and destroy the underlying lower level texture aka internalTexture.
  112841. */
  112842. releaseInternalTexture(): void;
  112843. /** @hidden */
  112844. get _lodTextureHigh(): Nullable<BaseTexture>;
  112845. /** @hidden */
  112846. get _lodTextureMid(): Nullable<BaseTexture>;
  112847. /** @hidden */
  112848. get _lodTextureLow(): Nullable<BaseTexture>;
  112849. /**
  112850. * Dispose the texture and release its associated resources.
  112851. */
  112852. dispose(): void;
  112853. /**
  112854. * Serialize the texture into a JSON representation that can be parsed later on.
  112855. * @returns the JSON representation of the texture
  112856. */
  112857. serialize(): any;
  112858. /**
  112859. * Helper function to be called back once a list of texture contains only ready textures.
  112860. * @param textures Define the list of textures to wait for
  112861. * @param callback Define the callback triggered once the entire list will be ready
  112862. */
  112863. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  112864. private static _isScene;
  112865. }
  112866. }
  112867. declare module BABYLON {
  112868. /**
  112869. * Options to be used when creating an effect.
  112870. */
  112871. export interface IEffectCreationOptions {
  112872. /**
  112873. * Atrributes that will be used in the shader.
  112874. */
  112875. attributes: string[];
  112876. /**
  112877. * Uniform varible names that will be set in the shader.
  112878. */
  112879. uniformsNames: string[];
  112880. /**
  112881. * Uniform buffer variable names that will be set in the shader.
  112882. */
  112883. uniformBuffersNames: string[];
  112884. /**
  112885. * Sampler texture variable names that will be set in the shader.
  112886. */
  112887. samplers: string[];
  112888. /**
  112889. * Define statements that will be set in the shader.
  112890. */
  112891. defines: any;
  112892. /**
  112893. * Possible fallbacks for this effect to improve performance when needed.
  112894. */
  112895. fallbacks: Nullable<IEffectFallbacks>;
  112896. /**
  112897. * Callback that will be called when the shader is compiled.
  112898. */
  112899. onCompiled: Nullable<(effect: Effect) => void>;
  112900. /**
  112901. * Callback that will be called if an error occurs during shader compilation.
  112902. */
  112903. onError: Nullable<(effect: Effect, errors: string) => void>;
  112904. /**
  112905. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  112906. */
  112907. indexParameters?: any;
  112908. /**
  112909. * Max number of lights that can be used in the shader.
  112910. */
  112911. maxSimultaneousLights?: number;
  112912. /**
  112913. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  112914. */
  112915. transformFeedbackVaryings?: Nullable<string[]>;
  112916. /**
  112917. * 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
  112918. */
  112919. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  112920. /**
  112921. * Is this effect rendering to several color attachments ?
  112922. */
  112923. multiTarget?: boolean;
  112924. }
  112925. /**
  112926. * Effect containing vertex and fragment shader that can be executed on an object.
  112927. */
  112928. export class Effect implements IDisposable {
  112929. /**
  112930. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112931. */
  112932. static ShadersRepository: string;
  112933. /**
  112934. * Enable logging of the shader code when a compilation error occurs
  112935. */
  112936. static LogShaderCodeOnCompilationError: boolean;
  112937. /**
  112938. * Name of the effect.
  112939. */
  112940. name: any;
  112941. /**
  112942. * String container all the define statements that should be set on the shader.
  112943. */
  112944. defines: string;
  112945. /**
  112946. * Callback that will be called when the shader is compiled.
  112947. */
  112948. onCompiled: Nullable<(effect: Effect) => void>;
  112949. /**
  112950. * Callback that will be called if an error occurs during shader compilation.
  112951. */
  112952. onError: Nullable<(effect: Effect, errors: string) => void>;
  112953. /**
  112954. * Callback that will be called when effect is bound.
  112955. */
  112956. onBind: Nullable<(effect: Effect) => void>;
  112957. /**
  112958. * Unique ID of the effect.
  112959. */
  112960. uniqueId: number;
  112961. /**
  112962. * Observable that will be called when the shader is compiled.
  112963. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  112964. */
  112965. onCompileObservable: Observable<Effect>;
  112966. /**
  112967. * Observable that will be called if an error occurs during shader compilation.
  112968. */
  112969. onErrorObservable: Observable<Effect>;
  112970. /** @hidden */
  112971. _onBindObservable: Nullable<Observable<Effect>>;
  112972. /**
  112973. * @hidden
  112974. * Specifies if the effect was previously ready
  112975. */
  112976. _wasPreviouslyReady: boolean;
  112977. /**
  112978. * Observable that will be called when effect is bound.
  112979. */
  112980. get onBindObservable(): Observable<Effect>;
  112981. /** @hidden */
  112982. _bonesComputationForcedToCPU: boolean;
  112983. /** @hidden */
  112984. _multiTarget: boolean;
  112985. private static _uniqueIdSeed;
  112986. private _engine;
  112987. private _uniformBuffersNames;
  112988. private _uniformBuffersNamesList;
  112989. private _uniformsNames;
  112990. private _samplerList;
  112991. private _samplers;
  112992. private _isReady;
  112993. private _compilationError;
  112994. private _allFallbacksProcessed;
  112995. private _attributesNames;
  112996. private _attributes;
  112997. private _attributeLocationByName;
  112998. private _uniforms;
  112999. /**
  113000. * Key for the effect.
  113001. * @hidden
  113002. */
  113003. _key: string;
  113004. private _indexParameters;
  113005. private _fallbacks;
  113006. private _vertexSourceCode;
  113007. private _fragmentSourceCode;
  113008. private _vertexSourceCodeOverride;
  113009. private _fragmentSourceCodeOverride;
  113010. private _transformFeedbackVaryings;
  113011. /**
  113012. * Compiled shader to webGL program.
  113013. * @hidden
  113014. */
  113015. _pipelineContext: Nullable<IPipelineContext>;
  113016. private _valueCache;
  113017. private static _baseCache;
  113018. /**
  113019. * Instantiates an effect.
  113020. * An effect can be used to create/manage/execute vertex and fragment shaders.
  113021. * @param baseName Name of the effect.
  113022. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  113023. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  113024. * @param samplers List of sampler variables that will be passed to the shader.
  113025. * @param engine Engine to be used to render the effect
  113026. * @param defines Define statements to be added to the shader.
  113027. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  113028. * @param onCompiled Callback that will be called when the shader is compiled.
  113029. * @param onError Callback that will be called if an error occurs during shader compilation.
  113030. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113031. */
  113032. 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);
  113033. private _useFinalCode;
  113034. /**
  113035. * Unique key for this effect
  113036. */
  113037. get key(): string;
  113038. /**
  113039. * If the effect has been compiled and prepared.
  113040. * @returns if the effect is compiled and prepared.
  113041. */
  113042. isReady(): boolean;
  113043. private _isReadyInternal;
  113044. /**
  113045. * The engine the effect was initialized with.
  113046. * @returns the engine.
  113047. */
  113048. getEngine(): Engine;
  113049. /**
  113050. * The pipeline context for this effect
  113051. * @returns the associated pipeline context
  113052. */
  113053. getPipelineContext(): Nullable<IPipelineContext>;
  113054. /**
  113055. * The set of names of attribute variables for the shader.
  113056. * @returns An array of attribute names.
  113057. */
  113058. getAttributesNames(): string[];
  113059. /**
  113060. * Returns the attribute at the given index.
  113061. * @param index The index of the attribute.
  113062. * @returns The location of the attribute.
  113063. */
  113064. getAttributeLocation(index: number): number;
  113065. /**
  113066. * Returns the attribute based on the name of the variable.
  113067. * @param name of the attribute to look up.
  113068. * @returns the attribute location.
  113069. */
  113070. getAttributeLocationByName(name: string): number;
  113071. /**
  113072. * The number of attributes.
  113073. * @returns the numnber of attributes.
  113074. */
  113075. getAttributesCount(): number;
  113076. /**
  113077. * Gets the index of a uniform variable.
  113078. * @param uniformName of the uniform to look up.
  113079. * @returns the index.
  113080. */
  113081. getUniformIndex(uniformName: string): number;
  113082. /**
  113083. * Returns the attribute based on the name of the variable.
  113084. * @param uniformName of the uniform to look up.
  113085. * @returns the location of the uniform.
  113086. */
  113087. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  113088. /**
  113089. * Returns an array of sampler variable names
  113090. * @returns The array of sampler variable names.
  113091. */
  113092. getSamplers(): string[];
  113093. /**
  113094. * Returns an array of uniform variable names
  113095. * @returns The array of uniform variable names.
  113096. */
  113097. getUniformNames(): string[];
  113098. /**
  113099. * Returns an array of uniform buffer variable names
  113100. * @returns The array of uniform buffer variable names.
  113101. */
  113102. getUniformBuffersNames(): string[];
  113103. /**
  113104. * Returns the index parameters used to create the effect
  113105. * @returns The index parameters object
  113106. */
  113107. getIndexParameters(): any;
  113108. /**
  113109. * The error from the last compilation.
  113110. * @returns the error string.
  113111. */
  113112. getCompilationError(): string;
  113113. /**
  113114. * Gets a boolean indicating that all fallbacks were used during compilation
  113115. * @returns true if all fallbacks were used
  113116. */
  113117. allFallbacksProcessed(): boolean;
  113118. /**
  113119. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  113120. * @param func The callback to be used.
  113121. */
  113122. executeWhenCompiled(func: (effect: Effect) => void): void;
  113123. private _checkIsReady;
  113124. private _loadShader;
  113125. /**
  113126. * Gets the vertex shader source code of this effect
  113127. */
  113128. get vertexSourceCode(): string;
  113129. /**
  113130. * Gets the fragment shader source code of this effect
  113131. */
  113132. get fragmentSourceCode(): string;
  113133. /**
  113134. * Recompiles the webGL program
  113135. * @param vertexSourceCode The source code for the vertex shader.
  113136. * @param fragmentSourceCode The source code for the fragment shader.
  113137. * @param onCompiled Callback called when completed.
  113138. * @param onError Callback called on error.
  113139. * @hidden
  113140. */
  113141. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  113142. /**
  113143. * Prepares the effect
  113144. * @hidden
  113145. */
  113146. _prepareEffect(): void;
  113147. private _getShaderCodeAndErrorLine;
  113148. private _processCompilationErrors;
  113149. /**
  113150. * Checks if the effect is supported. (Must be called after compilation)
  113151. */
  113152. get isSupported(): boolean;
  113153. /**
  113154. * Binds a texture to the engine to be used as output of the shader.
  113155. * @param channel Name of the output variable.
  113156. * @param texture Texture to bind.
  113157. * @hidden
  113158. */
  113159. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  113160. /**
  113161. * Sets a texture on the engine to be used in the shader.
  113162. * @param channel Name of the sampler variable.
  113163. * @param texture Texture to set.
  113164. */
  113165. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  113166. /**
  113167. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  113168. * @param channel Name of the sampler variable.
  113169. * @param texture Texture to set.
  113170. */
  113171. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  113172. /**
  113173. * Sets an array of textures on the engine to be used in the shader.
  113174. * @param channel Name of the variable.
  113175. * @param textures Textures to set.
  113176. */
  113177. setTextureArray(channel: string, textures: BaseTexture[]): void;
  113178. /**
  113179. * 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)
  113180. * @param channel Name of the sampler variable.
  113181. * @param postProcess Post process to get the input texture from.
  113182. */
  113183. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  113184. /**
  113185. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  113186. * 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)
  113187. * @param channel Name of the sampler variable.
  113188. * @param postProcess Post process to get the output texture from.
  113189. */
  113190. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  113191. /** @hidden */
  113192. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  113193. /** @hidden */
  113194. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  113195. /** @hidden */
  113196. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  113197. /** @hidden */
  113198. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  113199. /**
  113200. * Binds a buffer to a uniform.
  113201. * @param buffer Buffer to bind.
  113202. * @param name Name of the uniform variable to bind to.
  113203. */
  113204. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  113205. /**
  113206. * Binds block to a uniform.
  113207. * @param blockName Name of the block to bind.
  113208. * @param index Index to bind.
  113209. */
  113210. bindUniformBlock(blockName: string, index: number): void;
  113211. /**
  113212. * Sets an interger value on a uniform variable.
  113213. * @param uniformName Name of the variable.
  113214. * @param value Value to be set.
  113215. * @returns this effect.
  113216. */
  113217. setInt(uniformName: string, value: number): Effect;
  113218. /**
  113219. * Sets an int array on a uniform variable.
  113220. * @param uniformName Name of the variable.
  113221. * @param array array to be set.
  113222. * @returns this effect.
  113223. */
  113224. setIntArray(uniformName: string, array: Int32Array): Effect;
  113225. /**
  113226. * 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)
  113227. * @param uniformName Name of the variable.
  113228. * @param array array to be set.
  113229. * @returns this effect.
  113230. */
  113231. setIntArray2(uniformName: string, array: Int32Array): Effect;
  113232. /**
  113233. * 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)
  113234. * @param uniformName Name of the variable.
  113235. * @param array array to be set.
  113236. * @returns this effect.
  113237. */
  113238. setIntArray3(uniformName: string, array: Int32Array): Effect;
  113239. /**
  113240. * 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)
  113241. * @param uniformName Name of the variable.
  113242. * @param array array to be set.
  113243. * @returns this effect.
  113244. */
  113245. setIntArray4(uniformName: string, array: Int32Array): Effect;
  113246. /**
  113247. * Sets an float array on a uniform variable.
  113248. * @param uniformName Name of the variable.
  113249. * @param array array to be set.
  113250. * @returns this effect.
  113251. */
  113252. setFloatArray(uniformName: string, array: Float32Array): Effect;
  113253. /**
  113254. * 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)
  113255. * @param uniformName Name of the variable.
  113256. * @param array array to be set.
  113257. * @returns this effect.
  113258. */
  113259. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  113260. /**
  113261. * 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)
  113262. * @param uniformName Name of the variable.
  113263. * @param array array to be set.
  113264. * @returns this effect.
  113265. */
  113266. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  113267. /**
  113268. * 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)
  113269. * @param uniformName Name of the variable.
  113270. * @param array array to be set.
  113271. * @returns this effect.
  113272. */
  113273. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  113274. /**
  113275. * Sets an array on a uniform variable.
  113276. * @param uniformName Name of the variable.
  113277. * @param array array to be set.
  113278. * @returns this effect.
  113279. */
  113280. setArray(uniformName: string, array: number[]): Effect;
  113281. /**
  113282. * 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)
  113283. * @param uniformName Name of the variable.
  113284. * @param array array to be set.
  113285. * @returns this effect.
  113286. */
  113287. setArray2(uniformName: string, array: number[]): Effect;
  113288. /**
  113289. * 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)
  113290. * @param uniformName Name of the variable.
  113291. * @param array array to be set.
  113292. * @returns this effect.
  113293. */
  113294. setArray3(uniformName: string, array: number[]): Effect;
  113295. /**
  113296. * 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)
  113297. * @param uniformName Name of the variable.
  113298. * @param array array to be set.
  113299. * @returns this effect.
  113300. */
  113301. setArray4(uniformName: string, array: number[]): Effect;
  113302. /**
  113303. * Sets matrices on a uniform variable.
  113304. * @param uniformName Name of the variable.
  113305. * @param matrices matrices to be set.
  113306. * @returns this effect.
  113307. */
  113308. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  113309. /**
  113310. * Sets matrix on a uniform variable.
  113311. * @param uniformName Name of the variable.
  113312. * @param matrix matrix to be set.
  113313. * @returns this effect.
  113314. */
  113315. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  113316. /**
  113317. * 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)
  113318. * @param uniformName Name of the variable.
  113319. * @param matrix matrix to be set.
  113320. * @returns this effect.
  113321. */
  113322. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113323. /**
  113324. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  113325. * @param uniformName Name of the variable.
  113326. * @param matrix matrix to be set.
  113327. * @returns this effect.
  113328. */
  113329. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113330. /**
  113331. * Sets a float on a uniform variable.
  113332. * @param uniformName Name of the variable.
  113333. * @param value value to be set.
  113334. * @returns this effect.
  113335. */
  113336. setFloat(uniformName: string, value: number): Effect;
  113337. /**
  113338. * Sets a boolean on a uniform variable.
  113339. * @param uniformName Name of the variable.
  113340. * @param bool value to be set.
  113341. * @returns this effect.
  113342. */
  113343. setBool(uniformName: string, bool: boolean): Effect;
  113344. /**
  113345. * Sets a Vector2 on a uniform variable.
  113346. * @param uniformName Name of the variable.
  113347. * @param vector2 vector2 to be set.
  113348. * @returns this effect.
  113349. */
  113350. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  113351. /**
  113352. * Sets a float2 on a uniform variable.
  113353. * @param uniformName Name of the variable.
  113354. * @param x First float in float2.
  113355. * @param y Second float in float2.
  113356. * @returns this effect.
  113357. */
  113358. setFloat2(uniformName: string, x: number, y: number): Effect;
  113359. /**
  113360. * Sets a Vector3 on a uniform variable.
  113361. * @param uniformName Name of the variable.
  113362. * @param vector3 Value to be set.
  113363. * @returns this effect.
  113364. */
  113365. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  113366. /**
  113367. * Sets a float3 on a uniform variable.
  113368. * @param uniformName Name of the variable.
  113369. * @param x First float in float3.
  113370. * @param y Second float in float3.
  113371. * @param z Third float in float3.
  113372. * @returns this effect.
  113373. */
  113374. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113375. /**
  113376. * Sets a Vector4 on a uniform variable.
  113377. * @param uniformName Name of the variable.
  113378. * @param vector4 Value to be set.
  113379. * @returns this effect.
  113380. */
  113381. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113382. /**
  113383. * Sets a float4 on a uniform variable.
  113384. * @param uniformName Name of the variable.
  113385. * @param x First float in float4.
  113386. * @param y Second float in float4.
  113387. * @param z Third float in float4.
  113388. * @param w Fourth float in float4.
  113389. * @returns this effect.
  113390. */
  113391. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113392. /**
  113393. * Sets a Color3 on a uniform variable.
  113394. * @param uniformName Name of the variable.
  113395. * @param color3 Value to be set.
  113396. * @returns this effect.
  113397. */
  113398. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113399. /**
  113400. * Sets a Color4 on a uniform variable.
  113401. * @param uniformName Name of the variable.
  113402. * @param color3 Value to be set.
  113403. * @param alpha Alpha value to be set.
  113404. * @returns this effect.
  113405. */
  113406. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113407. /**
  113408. * Sets a Color4 on a uniform variable
  113409. * @param uniformName defines the name of the variable
  113410. * @param color4 defines the value to be set
  113411. * @returns this effect.
  113412. */
  113413. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113414. /** Release all associated resources */
  113415. dispose(): void;
  113416. /**
  113417. * This function will add a new shader to the shader store
  113418. * @param name the name of the shader
  113419. * @param pixelShader optional pixel shader content
  113420. * @param vertexShader optional vertex shader content
  113421. */
  113422. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  113423. /**
  113424. * Store of each shader (The can be looked up using effect.key)
  113425. */
  113426. static ShadersStore: {
  113427. [key: string]: string;
  113428. };
  113429. /**
  113430. * Store of each included file for a shader (The can be looked up using effect.key)
  113431. */
  113432. static IncludesShadersStore: {
  113433. [key: string]: string;
  113434. };
  113435. /**
  113436. * Resets the cache of effects.
  113437. */
  113438. static ResetCache(): void;
  113439. }
  113440. }
  113441. declare module BABYLON {
  113442. /**
  113443. * Interface used to describe the capabilities of the engine relatively to the current browser
  113444. */
  113445. export interface EngineCapabilities {
  113446. /** Maximum textures units per fragment shader */
  113447. maxTexturesImageUnits: number;
  113448. /** Maximum texture units per vertex shader */
  113449. maxVertexTextureImageUnits: number;
  113450. /** Maximum textures units in the entire pipeline */
  113451. maxCombinedTexturesImageUnits: number;
  113452. /** Maximum texture size */
  113453. maxTextureSize: number;
  113454. /** Maximum texture samples */
  113455. maxSamples?: number;
  113456. /** Maximum cube texture size */
  113457. maxCubemapTextureSize: number;
  113458. /** Maximum render texture size */
  113459. maxRenderTextureSize: number;
  113460. /** Maximum number of vertex attributes */
  113461. maxVertexAttribs: number;
  113462. /** Maximum number of varyings */
  113463. maxVaryingVectors: number;
  113464. /** Maximum number of uniforms per vertex shader */
  113465. maxVertexUniformVectors: number;
  113466. /** Maximum number of uniforms per fragment shader */
  113467. maxFragmentUniformVectors: number;
  113468. /** Defines if standard derivates (dx/dy) are supported */
  113469. standardDerivatives: boolean;
  113470. /** Defines if s3tc texture compression is supported */
  113471. s3tc?: WEBGL_compressed_texture_s3tc;
  113472. /** Defines if pvrtc texture compression is supported */
  113473. pvrtc: any;
  113474. /** Defines if etc1 texture compression is supported */
  113475. etc1: any;
  113476. /** Defines if etc2 texture compression is supported */
  113477. etc2: any;
  113478. /** Defines if astc texture compression is supported */
  113479. astc: any;
  113480. /** Defines if float textures are supported */
  113481. textureFloat: boolean;
  113482. /** Defines if vertex array objects are supported */
  113483. vertexArrayObject: boolean;
  113484. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  113485. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  113486. /** Gets the maximum level of anisotropy supported */
  113487. maxAnisotropy: number;
  113488. /** Defines if instancing is supported */
  113489. instancedArrays: boolean;
  113490. /** Defines if 32 bits indices are supported */
  113491. uintIndices: boolean;
  113492. /** Defines if high precision shaders are supported */
  113493. highPrecisionShaderSupported: boolean;
  113494. /** Defines if depth reading in the fragment shader is supported */
  113495. fragmentDepthSupported: boolean;
  113496. /** Defines if float texture linear filtering is supported*/
  113497. textureFloatLinearFiltering: boolean;
  113498. /** Defines if rendering to float textures is supported */
  113499. textureFloatRender: boolean;
  113500. /** Defines if half float textures are supported*/
  113501. textureHalfFloat: boolean;
  113502. /** Defines if half float texture linear filtering is supported*/
  113503. textureHalfFloatLinearFiltering: boolean;
  113504. /** Defines if rendering to half float textures is supported */
  113505. textureHalfFloatRender: boolean;
  113506. /** Defines if textureLOD shader command is supported */
  113507. textureLOD: boolean;
  113508. /** Defines if draw buffers extension is supported */
  113509. drawBuffersExtension: boolean;
  113510. /** Defines if depth textures are supported */
  113511. depthTextureExtension: boolean;
  113512. /** Defines if float color buffer are supported */
  113513. colorBufferFloat: boolean;
  113514. /** Gets disjoint timer query extension (null if not supported) */
  113515. timerQuery?: EXT_disjoint_timer_query;
  113516. /** Defines if timestamp can be used with timer query */
  113517. canUseTimestampForTimerQuery: boolean;
  113518. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  113519. multiview?: any;
  113520. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  113521. oculusMultiview?: any;
  113522. /** Function used to let the system compiles shaders in background */
  113523. parallelShaderCompile?: {
  113524. COMPLETION_STATUS_KHR: number;
  113525. };
  113526. /** Max number of texture samples for MSAA */
  113527. maxMSAASamples: number;
  113528. /** Defines if the blend min max extension is supported */
  113529. blendMinMax: boolean;
  113530. }
  113531. }
  113532. declare module BABYLON {
  113533. /**
  113534. * @hidden
  113535. **/
  113536. export class DepthCullingState {
  113537. private _isDepthTestDirty;
  113538. private _isDepthMaskDirty;
  113539. private _isDepthFuncDirty;
  113540. private _isCullFaceDirty;
  113541. private _isCullDirty;
  113542. private _isZOffsetDirty;
  113543. private _isFrontFaceDirty;
  113544. private _depthTest;
  113545. private _depthMask;
  113546. private _depthFunc;
  113547. private _cull;
  113548. private _cullFace;
  113549. private _zOffset;
  113550. private _frontFace;
  113551. /**
  113552. * Initializes the state.
  113553. */
  113554. constructor();
  113555. get isDirty(): boolean;
  113556. get zOffset(): number;
  113557. set zOffset(value: number);
  113558. get cullFace(): Nullable<number>;
  113559. set cullFace(value: Nullable<number>);
  113560. get cull(): Nullable<boolean>;
  113561. set cull(value: Nullable<boolean>);
  113562. get depthFunc(): Nullable<number>;
  113563. set depthFunc(value: Nullable<number>);
  113564. get depthMask(): boolean;
  113565. set depthMask(value: boolean);
  113566. get depthTest(): boolean;
  113567. set depthTest(value: boolean);
  113568. get frontFace(): Nullable<number>;
  113569. set frontFace(value: Nullable<number>);
  113570. reset(): void;
  113571. apply(gl: WebGLRenderingContext): void;
  113572. }
  113573. }
  113574. declare module BABYLON {
  113575. /**
  113576. * @hidden
  113577. **/
  113578. export class StencilState {
  113579. /** 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 */
  113580. static readonly ALWAYS: number;
  113581. /** Passed to stencilOperation to specify that stencil value must be kept */
  113582. static readonly KEEP: number;
  113583. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113584. static readonly REPLACE: number;
  113585. private _isStencilTestDirty;
  113586. private _isStencilMaskDirty;
  113587. private _isStencilFuncDirty;
  113588. private _isStencilOpDirty;
  113589. private _stencilTest;
  113590. private _stencilMask;
  113591. private _stencilFunc;
  113592. private _stencilFuncRef;
  113593. private _stencilFuncMask;
  113594. private _stencilOpStencilFail;
  113595. private _stencilOpDepthFail;
  113596. private _stencilOpStencilDepthPass;
  113597. get isDirty(): boolean;
  113598. get stencilFunc(): number;
  113599. set stencilFunc(value: number);
  113600. get stencilFuncRef(): number;
  113601. set stencilFuncRef(value: number);
  113602. get stencilFuncMask(): number;
  113603. set stencilFuncMask(value: number);
  113604. get stencilOpStencilFail(): number;
  113605. set stencilOpStencilFail(value: number);
  113606. get stencilOpDepthFail(): number;
  113607. set stencilOpDepthFail(value: number);
  113608. get stencilOpStencilDepthPass(): number;
  113609. set stencilOpStencilDepthPass(value: number);
  113610. get stencilMask(): number;
  113611. set stencilMask(value: number);
  113612. get stencilTest(): boolean;
  113613. set stencilTest(value: boolean);
  113614. constructor();
  113615. reset(): void;
  113616. apply(gl: WebGLRenderingContext): void;
  113617. }
  113618. }
  113619. declare module BABYLON {
  113620. /**
  113621. * @hidden
  113622. **/
  113623. export class AlphaState {
  113624. private _isAlphaBlendDirty;
  113625. private _isBlendFunctionParametersDirty;
  113626. private _isBlendEquationParametersDirty;
  113627. private _isBlendConstantsDirty;
  113628. private _alphaBlend;
  113629. private _blendFunctionParameters;
  113630. private _blendEquationParameters;
  113631. private _blendConstants;
  113632. /**
  113633. * Initializes the state.
  113634. */
  113635. constructor();
  113636. get isDirty(): boolean;
  113637. get alphaBlend(): boolean;
  113638. set alphaBlend(value: boolean);
  113639. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  113640. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  113641. setAlphaEquationParameters(rgb: number, alpha: number): void;
  113642. reset(): void;
  113643. apply(gl: WebGLRenderingContext): void;
  113644. }
  113645. }
  113646. declare module BABYLON {
  113647. /** @hidden */
  113648. export class WebGL2ShaderProcessor implements IShaderProcessor {
  113649. attributeProcessor(attribute: string): string;
  113650. varyingProcessor(varying: string, isFragment: boolean): string;
  113651. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113652. }
  113653. }
  113654. declare module BABYLON {
  113655. /**
  113656. * Interface for attribute information associated with buffer instanciation
  113657. */
  113658. export interface InstancingAttributeInfo {
  113659. /**
  113660. * Name of the GLSL attribute
  113661. * if attribute index is not specified, this is used to retrieve the index from the effect
  113662. */
  113663. attributeName: string;
  113664. /**
  113665. * Index/offset of the attribute in the vertex shader
  113666. * if not specified, this will be computes from the name.
  113667. */
  113668. index?: number;
  113669. /**
  113670. * size of the attribute, 1, 2, 3 or 4
  113671. */
  113672. attributeSize: number;
  113673. /**
  113674. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  113675. */
  113676. offset: number;
  113677. /**
  113678. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  113679. * default to 1
  113680. */
  113681. divisor?: number;
  113682. /**
  113683. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  113684. * default is FLOAT
  113685. */
  113686. attributeType?: number;
  113687. /**
  113688. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  113689. */
  113690. normalized?: boolean;
  113691. }
  113692. }
  113693. declare module BABYLON {
  113694. interface ThinEngine {
  113695. /**
  113696. * Update a video texture
  113697. * @param texture defines the texture to update
  113698. * @param video defines the video element to use
  113699. * @param invertY defines if data must be stored with Y axis inverted
  113700. */
  113701. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  113702. }
  113703. }
  113704. declare module BABYLON {
  113705. interface ThinEngine {
  113706. /**
  113707. * Creates a dynamic texture
  113708. * @param width defines the width of the texture
  113709. * @param height defines the height of the texture
  113710. * @param generateMipMaps defines if the engine should generate the mip levels
  113711. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  113712. * @returns the dynamic texture inside an InternalTexture
  113713. */
  113714. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  113715. /**
  113716. * Update the content of a dynamic texture
  113717. * @param texture defines the texture to update
  113718. * @param canvas defines the canvas containing the source
  113719. * @param invertY defines if data must be stored with Y axis inverted
  113720. * @param premulAlpha defines if alpha is stored as premultiplied
  113721. * @param format defines the format of the data
  113722. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113723. */
  113724. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  113725. }
  113726. }
  113727. declare module BABYLON {
  113728. /**
  113729. * Settings for finer control over video usage
  113730. */
  113731. export interface VideoTextureSettings {
  113732. /**
  113733. * Applies `autoplay` to video, if specified
  113734. */
  113735. autoPlay?: boolean;
  113736. /**
  113737. * Applies `loop` to video, if specified
  113738. */
  113739. loop?: boolean;
  113740. /**
  113741. * Automatically updates internal texture from video at every frame in the render loop
  113742. */
  113743. autoUpdateTexture: boolean;
  113744. /**
  113745. * Image src displayed during the video loading or until the user interacts with the video.
  113746. */
  113747. poster?: string;
  113748. }
  113749. /**
  113750. * If you want to display a video in your scene, this is the special texture for that.
  113751. * This special texture works similar to other textures, with the exception of a few parameters.
  113752. * @see https://doc.babylonjs.com/how_to/video_texture
  113753. */
  113754. export class VideoTexture extends Texture {
  113755. /**
  113756. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  113757. */
  113758. readonly autoUpdateTexture: boolean;
  113759. /**
  113760. * The video instance used by the texture internally
  113761. */
  113762. readonly video: HTMLVideoElement;
  113763. private _onUserActionRequestedObservable;
  113764. /**
  113765. * Event triggerd when a dom action is required by the user to play the video.
  113766. * This happens due to recent changes in browser policies preventing video to auto start.
  113767. */
  113768. get onUserActionRequestedObservable(): Observable<Texture>;
  113769. private _generateMipMaps;
  113770. private _stillImageCaptured;
  113771. private _displayingPosterTexture;
  113772. private _settings;
  113773. private _createInternalTextureOnEvent;
  113774. private _frameId;
  113775. private _currentSrc;
  113776. /**
  113777. * Creates a video texture.
  113778. * If you want to display a video in your scene, this is the special texture for that.
  113779. * This special texture works similar to other textures, with the exception of a few parameters.
  113780. * @see https://doc.babylonjs.com/how_to/video_texture
  113781. * @param name optional name, will detect from video source, if not defined
  113782. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  113783. * @param scene is obviously the current scene.
  113784. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  113785. * @param invertY is false by default but can be used to invert video on Y axis
  113786. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  113787. * @param settings allows finer control over video usage
  113788. */
  113789. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  113790. private _getName;
  113791. private _getVideo;
  113792. private _createInternalTexture;
  113793. private reset;
  113794. /**
  113795. * @hidden Internal method to initiate `update`.
  113796. */
  113797. _rebuild(): void;
  113798. /**
  113799. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  113800. */
  113801. update(): void;
  113802. /**
  113803. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  113804. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  113805. */
  113806. updateTexture(isVisible: boolean): void;
  113807. protected _updateInternalTexture: () => void;
  113808. /**
  113809. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  113810. * @param url New url.
  113811. */
  113812. updateURL(url: string): void;
  113813. /**
  113814. * Clones the texture.
  113815. * @returns the cloned texture
  113816. */
  113817. clone(): VideoTexture;
  113818. /**
  113819. * Dispose the texture and release its associated resources.
  113820. */
  113821. dispose(): void;
  113822. /**
  113823. * Creates a video texture straight from a stream.
  113824. * @param scene Define the scene the texture should be created in
  113825. * @param stream Define the stream the texture should be created from
  113826. * @returns The created video texture as a promise
  113827. */
  113828. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  113829. /**
  113830. * Creates a video texture straight from your WebCam video feed.
  113831. * @param scene Define the scene the texture should be created in
  113832. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113833. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113834. * @returns The created video texture as a promise
  113835. */
  113836. static CreateFromWebCamAsync(scene: Scene, constraints: {
  113837. minWidth: number;
  113838. maxWidth: number;
  113839. minHeight: number;
  113840. maxHeight: number;
  113841. deviceId: string;
  113842. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  113843. /**
  113844. * Creates a video texture straight from your WebCam video feed.
  113845. * @param scene Define the scene the texture should be created in
  113846. * @param onReady Define a callback to triggered once the texture will be ready
  113847. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113848. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113849. */
  113850. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  113851. minWidth: number;
  113852. maxWidth: number;
  113853. minHeight: number;
  113854. maxHeight: number;
  113855. deviceId: string;
  113856. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  113857. }
  113858. }
  113859. declare module BABYLON {
  113860. /**
  113861. * Defines the interface used by objects working like Scene
  113862. * @hidden
  113863. */
  113864. export interface ISceneLike {
  113865. _addPendingData(data: any): void;
  113866. _removePendingData(data: any): void;
  113867. offlineProvider: IOfflineProvider;
  113868. }
  113869. /** Interface defining initialization parameters for Engine class */
  113870. export interface EngineOptions extends WebGLContextAttributes {
  113871. /**
  113872. * Defines if the engine should no exceed a specified device ratio
  113873. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  113874. */
  113875. limitDeviceRatio?: number;
  113876. /**
  113877. * Defines if webvr should be enabled automatically
  113878. * @see https://doc.babylonjs.com/how_to/webvr_camera
  113879. */
  113880. autoEnableWebVR?: boolean;
  113881. /**
  113882. * Defines if webgl2 should be turned off even if supported
  113883. * @see https://doc.babylonjs.com/features/webgl2
  113884. */
  113885. disableWebGL2Support?: boolean;
  113886. /**
  113887. * Defines if webaudio should be initialized as well
  113888. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113889. */
  113890. audioEngine?: boolean;
  113891. /**
  113892. * Defines if animations should run using a deterministic lock step
  113893. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113894. */
  113895. deterministicLockstep?: boolean;
  113896. /** Defines the maximum steps to use with deterministic lock step mode */
  113897. lockstepMaxSteps?: number;
  113898. /** Defines the seconds between each deterministic lock step */
  113899. timeStep?: number;
  113900. /**
  113901. * Defines that engine should ignore context lost events
  113902. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  113903. */
  113904. doNotHandleContextLost?: boolean;
  113905. /**
  113906. * Defines that engine should ignore modifying touch action attribute and style
  113907. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  113908. */
  113909. doNotHandleTouchAction?: boolean;
  113910. /**
  113911. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  113912. */
  113913. useHighPrecisionFloats?: boolean;
  113914. /**
  113915. * Make the canvas XR Compatible for XR sessions
  113916. */
  113917. xrCompatible?: boolean;
  113918. /**
  113919. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  113920. */
  113921. useHighPrecisionMatrix?: boolean;
  113922. }
  113923. /**
  113924. * The base engine class (root of all engines)
  113925. */
  113926. export class ThinEngine {
  113927. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  113928. static ExceptionList: ({
  113929. key: string;
  113930. capture: string;
  113931. captureConstraint: number;
  113932. targets: string[];
  113933. } | {
  113934. key: string;
  113935. capture: null;
  113936. captureConstraint: null;
  113937. targets: string[];
  113938. })[];
  113939. /** @hidden */
  113940. static _TextureLoaders: IInternalTextureLoader[];
  113941. /**
  113942. * Returns the current npm package of the sdk
  113943. */
  113944. static get NpmPackage(): string;
  113945. /**
  113946. * Returns the current version of the framework
  113947. */
  113948. static get Version(): string;
  113949. /**
  113950. * Returns a string describing the current engine
  113951. */
  113952. get description(): string;
  113953. /**
  113954. * Gets or sets the epsilon value used by collision engine
  113955. */
  113956. static CollisionsEpsilon: number;
  113957. /**
  113958. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113959. */
  113960. static get ShadersRepository(): string;
  113961. static set ShadersRepository(value: string);
  113962. /** @hidden */
  113963. _shaderProcessor: IShaderProcessor;
  113964. /**
  113965. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  113966. */
  113967. forcePOTTextures: boolean;
  113968. /**
  113969. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  113970. */
  113971. isFullscreen: boolean;
  113972. /**
  113973. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  113974. */
  113975. cullBackFaces: boolean;
  113976. /**
  113977. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  113978. */
  113979. renderEvenInBackground: boolean;
  113980. /**
  113981. * Gets or sets a boolean indicating that cache can be kept between frames
  113982. */
  113983. preventCacheWipeBetweenFrames: boolean;
  113984. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  113985. validateShaderPrograms: boolean;
  113986. /**
  113987. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  113988. * This can provide greater z depth for distant objects.
  113989. */
  113990. useReverseDepthBuffer: boolean;
  113991. /**
  113992. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  113993. */
  113994. disableUniformBuffers: boolean;
  113995. /** @hidden */
  113996. _uniformBuffers: UniformBuffer[];
  113997. /**
  113998. * Gets a boolean indicating that the engine supports uniform buffers
  113999. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  114000. */
  114001. get supportsUniformBuffers(): boolean;
  114002. /** @hidden */
  114003. _gl: WebGLRenderingContext;
  114004. /** @hidden */
  114005. _webGLVersion: number;
  114006. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  114007. protected _windowIsBackground: boolean;
  114008. protected _creationOptions: EngineOptions;
  114009. protected _highPrecisionShadersAllowed: boolean;
  114010. /** @hidden */
  114011. get _shouldUseHighPrecisionShader(): boolean;
  114012. /**
  114013. * Gets a boolean indicating that only power of 2 textures are supported
  114014. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  114015. */
  114016. get needPOTTextures(): boolean;
  114017. /** @hidden */
  114018. _badOS: boolean;
  114019. /** @hidden */
  114020. _badDesktopOS: boolean;
  114021. private _hardwareScalingLevel;
  114022. /** @hidden */
  114023. _caps: EngineCapabilities;
  114024. private _isStencilEnable;
  114025. private _glVersion;
  114026. private _glRenderer;
  114027. private _glVendor;
  114028. /** @hidden */
  114029. _videoTextureSupported: boolean;
  114030. protected _renderingQueueLaunched: boolean;
  114031. protected _activeRenderLoops: (() => void)[];
  114032. /**
  114033. * Observable signaled when a context lost event is raised
  114034. */
  114035. onContextLostObservable: Observable<ThinEngine>;
  114036. /**
  114037. * Observable signaled when a context restored event is raised
  114038. */
  114039. onContextRestoredObservable: Observable<ThinEngine>;
  114040. private _onContextLost;
  114041. private _onContextRestored;
  114042. protected _contextWasLost: boolean;
  114043. /** @hidden */
  114044. _doNotHandleContextLost: boolean;
  114045. /**
  114046. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  114047. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  114048. */
  114049. get doNotHandleContextLost(): boolean;
  114050. set doNotHandleContextLost(value: boolean);
  114051. /**
  114052. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  114053. */
  114054. disableVertexArrayObjects: boolean;
  114055. /** @hidden */
  114056. protected _colorWrite: boolean;
  114057. /** @hidden */
  114058. protected _colorWriteChanged: boolean;
  114059. /** @hidden */
  114060. protected _depthCullingState: DepthCullingState;
  114061. /** @hidden */
  114062. protected _stencilState: StencilState;
  114063. /** @hidden */
  114064. _alphaState: AlphaState;
  114065. /** @hidden */
  114066. _alphaMode: number;
  114067. /** @hidden */
  114068. _alphaEquation: number;
  114069. /** @hidden */
  114070. _internalTexturesCache: InternalTexture[];
  114071. /** @hidden */
  114072. protected _activeChannel: number;
  114073. private _currentTextureChannel;
  114074. /** @hidden */
  114075. protected _boundTexturesCache: {
  114076. [key: string]: Nullable<InternalTexture>;
  114077. };
  114078. /** @hidden */
  114079. protected _currentEffect: Nullable<Effect>;
  114080. /** @hidden */
  114081. protected _currentProgram: Nullable<WebGLProgram>;
  114082. private _compiledEffects;
  114083. private _vertexAttribArraysEnabled;
  114084. /** @hidden */
  114085. protected _cachedViewport: Nullable<IViewportLike>;
  114086. private _cachedVertexArrayObject;
  114087. /** @hidden */
  114088. protected _cachedVertexBuffers: any;
  114089. /** @hidden */
  114090. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  114091. /** @hidden */
  114092. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  114093. /** @hidden */
  114094. _currentRenderTarget: Nullable<InternalTexture>;
  114095. private _uintIndicesCurrentlySet;
  114096. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  114097. /** @hidden */
  114098. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  114099. /** @hidden */
  114100. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  114101. private _currentBufferPointers;
  114102. private _currentInstanceLocations;
  114103. private _currentInstanceBuffers;
  114104. private _textureUnits;
  114105. /** @hidden */
  114106. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114107. /** @hidden */
  114108. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114109. /** @hidden */
  114110. _boundRenderFunction: any;
  114111. private _vaoRecordInProgress;
  114112. private _mustWipeVertexAttributes;
  114113. private _emptyTexture;
  114114. private _emptyCubeTexture;
  114115. private _emptyTexture3D;
  114116. private _emptyTexture2DArray;
  114117. /** @hidden */
  114118. _frameHandler: number;
  114119. private _nextFreeTextureSlots;
  114120. private _maxSimultaneousTextures;
  114121. private _activeRequests;
  114122. /** @hidden */
  114123. _transformTextureUrl: Nullable<(url: string) => string>;
  114124. protected get _supportsHardwareTextureRescaling(): boolean;
  114125. private _framebufferDimensionsObject;
  114126. /**
  114127. * sets the object from which width and height will be taken from when getting render width and height
  114128. * Will fallback to the gl object
  114129. * @param dimensions the framebuffer width and height that will be used.
  114130. */
  114131. set framebufferDimensionsObject(dimensions: Nullable<{
  114132. framebufferWidth: number;
  114133. framebufferHeight: number;
  114134. }>);
  114135. /**
  114136. * Gets the current viewport
  114137. */
  114138. get currentViewport(): Nullable<IViewportLike>;
  114139. /**
  114140. * Gets the default empty texture
  114141. */
  114142. get emptyTexture(): InternalTexture;
  114143. /**
  114144. * Gets the default empty 3D texture
  114145. */
  114146. get emptyTexture3D(): InternalTexture;
  114147. /**
  114148. * Gets the default empty 2D array texture
  114149. */
  114150. get emptyTexture2DArray(): InternalTexture;
  114151. /**
  114152. * Gets the default empty cube texture
  114153. */
  114154. get emptyCubeTexture(): InternalTexture;
  114155. /**
  114156. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  114157. */
  114158. readonly premultipliedAlpha: boolean;
  114159. /**
  114160. * Observable event triggered before each texture is initialized
  114161. */
  114162. onBeforeTextureInitObservable: Observable<Texture>;
  114163. /**
  114164. * Creates a new engine
  114165. * @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
  114166. * @param antialias defines enable antialiasing (default: false)
  114167. * @param options defines further options to be sent to the getContext() function
  114168. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114169. */
  114170. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114171. private _rebuildInternalTextures;
  114172. private _rebuildEffects;
  114173. /**
  114174. * Gets a boolean indicating if all created effects are ready
  114175. * @returns true if all effects are ready
  114176. */
  114177. areAllEffectsReady(): boolean;
  114178. protected _rebuildBuffers(): void;
  114179. protected _initGLContext(): void;
  114180. /**
  114181. * Gets version of the current webGL context
  114182. */
  114183. get webGLVersion(): number;
  114184. /**
  114185. * Gets a string idenfifying the name of the class
  114186. * @returns "Engine" string
  114187. */
  114188. getClassName(): string;
  114189. /**
  114190. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  114191. */
  114192. get isStencilEnable(): boolean;
  114193. /** @hidden */
  114194. _prepareWorkingCanvas(): void;
  114195. /**
  114196. * Reset the texture cache to empty state
  114197. */
  114198. resetTextureCache(): void;
  114199. /**
  114200. * Gets an object containing information about the current webGL context
  114201. * @returns an object containing the vender, the renderer and the version of the current webGL context
  114202. */
  114203. getGlInfo(): {
  114204. vendor: string;
  114205. renderer: string;
  114206. version: string;
  114207. };
  114208. /**
  114209. * Defines the hardware scaling level.
  114210. * By default the hardware scaling level is computed from the window device ratio.
  114211. * 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.
  114212. * @param level defines the level to use
  114213. */
  114214. setHardwareScalingLevel(level: number): void;
  114215. /**
  114216. * Gets the current hardware scaling level.
  114217. * By default the hardware scaling level is computed from the window device ratio.
  114218. * 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.
  114219. * @returns a number indicating the current hardware scaling level
  114220. */
  114221. getHardwareScalingLevel(): number;
  114222. /**
  114223. * Gets the list of loaded textures
  114224. * @returns an array containing all loaded textures
  114225. */
  114226. getLoadedTexturesCache(): InternalTexture[];
  114227. /**
  114228. * Gets the object containing all engine capabilities
  114229. * @returns the EngineCapabilities object
  114230. */
  114231. getCaps(): EngineCapabilities;
  114232. /**
  114233. * stop executing a render loop function and remove it from the execution array
  114234. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  114235. */
  114236. stopRenderLoop(renderFunction?: () => void): void;
  114237. /** @hidden */
  114238. _renderLoop(): void;
  114239. /**
  114240. * Gets the HTML canvas attached with the current webGL context
  114241. * @returns a HTML canvas
  114242. */
  114243. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  114244. /**
  114245. * Gets host window
  114246. * @returns the host window object
  114247. */
  114248. getHostWindow(): Nullable<Window>;
  114249. /**
  114250. * Gets the current render width
  114251. * @param useScreen defines if screen size must be used (or the current render target if any)
  114252. * @returns a number defining the current render width
  114253. */
  114254. getRenderWidth(useScreen?: boolean): number;
  114255. /**
  114256. * Gets the current render height
  114257. * @param useScreen defines if screen size must be used (or the current render target if any)
  114258. * @returns a number defining the current render height
  114259. */
  114260. getRenderHeight(useScreen?: boolean): number;
  114261. /**
  114262. * Can be used to override the current requestAnimationFrame requester.
  114263. * @hidden
  114264. */
  114265. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114266. /**
  114267. * Register and execute a render loop. The engine can have more than one render function
  114268. * @param renderFunction defines the function to continuously execute
  114269. */
  114270. runRenderLoop(renderFunction: () => void): void;
  114271. /**
  114272. * Clear the current render buffer or the current render target (if any is set up)
  114273. * @param color defines the color to use
  114274. * @param backBuffer defines if the back buffer must be cleared
  114275. * @param depth defines if the depth buffer must be cleared
  114276. * @param stencil defines if the stencil buffer must be cleared
  114277. */
  114278. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114279. private _viewportCached;
  114280. /** @hidden */
  114281. _viewport(x: number, y: number, width: number, height: number): void;
  114282. /**
  114283. * Set the WebGL's viewport
  114284. * @param viewport defines the viewport element to be used
  114285. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114286. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114287. */
  114288. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114289. /**
  114290. * Begin a new frame
  114291. */
  114292. beginFrame(): void;
  114293. /**
  114294. * Enf the current frame
  114295. */
  114296. endFrame(): void;
  114297. /**
  114298. * Resize the view according to the canvas' size
  114299. */
  114300. resize(): void;
  114301. /**
  114302. * Force a specific size of the canvas
  114303. * @param width defines the new canvas' width
  114304. * @param height defines the new canvas' height
  114305. * @returns true if the size was changed
  114306. */
  114307. setSize(width: number, height: number): boolean;
  114308. /**
  114309. * Binds the frame buffer to the specified texture.
  114310. * @param texture The texture to render to or null for the default canvas
  114311. * @param faceIndex The face of the texture to render to in case of cube texture
  114312. * @param requiredWidth The width of the target to render to
  114313. * @param requiredHeight The height of the target to render to
  114314. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114315. * @param lodLevel defines the lod level to bind to the frame buffer
  114316. * @param layer defines the 2d array index to bind to frame buffer to
  114317. */
  114318. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  114319. /** @hidden */
  114320. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114321. /**
  114322. * Unbind the current render target texture from the webGL context
  114323. * @param texture defines the render target texture to unbind
  114324. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114325. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114326. */
  114327. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114328. /**
  114329. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  114330. */
  114331. flushFramebuffer(): void;
  114332. /**
  114333. * Unbind the current render target and bind the default framebuffer
  114334. */
  114335. restoreDefaultFramebuffer(): void;
  114336. /** @hidden */
  114337. protected _resetVertexBufferBinding(): void;
  114338. /**
  114339. * Creates a vertex buffer
  114340. * @param data the data for the vertex buffer
  114341. * @returns the new WebGL static buffer
  114342. */
  114343. createVertexBuffer(data: DataArray): DataBuffer;
  114344. private _createVertexBuffer;
  114345. /**
  114346. * Creates a dynamic vertex buffer
  114347. * @param data the data for the dynamic vertex buffer
  114348. * @returns the new WebGL dynamic buffer
  114349. */
  114350. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114351. protected _resetIndexBufferBinding(): void;
  114352. /**
  114353. * Creates a new index buffer
  114354. * @param indices defines the content of the index buffer
  114355. * @param updatable defines if the index buffer must be updatable
  114356. * @returns a new webGL buffer
  114357. */
  114358. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  114359. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  114360. /**
  114361. * Bind a webGL buffer to the webGL context
  114362. * @param buffer defines the buffer to bind
  114363. */
  114364. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  114365. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  114366. private bindBuffer;
  114367. /**
  114368. * update the bound buffer with the given data
  114369. * @param data defines the data to update
  114370. */
  114371. updateArrayBuffer(data: Float32Array): void;
  114372. private _vertexAttribPointer;
  114373. /** @hidden */
  114374. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114375. private _bindVertexBuffersAttributes;
  114376. /**
  114377. * Records a vertex array object
  114378. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114379. * @param vertexBuffers defines the list of vertex buffers to store
  114380. * @param indexBuffer defines the index buffer to store
  114381. * @param effect defines the effect to store
  114382. * @returns the new vertex array object
  114383. */
  114384. recordVertexArrayObject(vertexBuffers: {
  114385. [key: string]: VertexBuffer;
  114386. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114387. /**
  114388. * Bind a specific vertex array object
  114389. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114390. * @param vertexArrayObject defines the vertex array object to bind
  114391. * @param indexBuffer defines the index buffer to bind
  114392. */
  114393. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114394. /**
  114395. * Bind webGl buffers directly to the webGL context
  114396. * @param vertexBuffer defines the vertex buffer to bind
  114397. * @param indexBuffer defines the index buffer to bind
  114398. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114399. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114400. * @param effect defines the effect associated with the vertex buffer
  114401. */
  114402. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114403. private _unbindVertexArrayObject;
  114404. /**
  114405. * Bind a list of vertex buffers to the webGL context
  114406. * @param vertexBuffers defines the list of vertex buffers to bind
  114407. * @param indexBuffer defines the index buffer to bind
  114408. * @param effect defines the effect associated with the vertex buffers
  114409. */
  114410. bindBuffers(vertexBuffers: {
  114411. [key: string]: Nullable<VertexBuffer>;
  114412. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114413. /**
  114414. * Unbind all instance attributes
  114415. */
  114416. unbindInstanceAttributes(): void;
  114417. /**
  114418. * Release and free the memory of a vertex array object
  114419. * @param vao defines the vertex array object to delete
  114420. */
  114421. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  114422. /** @hidden */
  114423. _releaseBuffer(buffer: DataBuffer): boolean;
  114424. protected _deleteBuffer(buffer: DataBuffer): void;
  114425. /**
  114426. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  114427. * @param instancesBuffer defines the webGL buffer to update and bind
  114428. * @param data defines the data to store in the buffer
  114429. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  114430. */
  114431. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  114432. /**
  114433. * Bind the content of a webGL buffer used with instantiation
  114434. * @param instancesBuffer defines the webGL buffer to bind
  114435. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  114436. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  114437. */
  114438. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  114439. /**
  114440. * Disable the instance attribute corresponding to the name in parameter
  114441. * @param name defines the name of the attribute to disable
  114442. */
  114443. disableInstanceAttributeByName(name: string): void;
  114444. /**
  114445. * Disable the instance attribute corresponding to the location in parameter
  114446. * @param attributeLocation defines the attribute location of the attribute to disable
  114447. */
  114448. disableInstanceAttribute(attributeLocation: number): void;
  114449. /**
  114450. * Disable the attribute corresponding to the location in parameter
  114451. * @param attributeLocation defines the attribute location of the attribute to disable
  114452. */
  114453. disableAttributeByIndex(attributeLocation: number): void;
  114454. /**
  114455. * Send a draw order
  114456. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114457. * @param indexStart defines the starting index
  114458. * @param indexCount defines the number of index to draw
  114459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114460. */
  114461. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114462. /**
  114463. * Draw a list of points
  114464. * @param verticesStart defines the index of first vertex to draw
  114465. * @param verticesCount defines the count of vertices to draw
  114466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114467. */
  114468. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114469. /**
  114470. * Draw a list of unindexed primitives
  114471. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114472. * @param verticesStart defines the index of first vertex to draw
  114473. * @param verticesCount defines the count of vertices to draw
  114474. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114475. */
  114476. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114477. /**
  114478. * Draw a list of indexed primitives
  114479. * @param fillMode defines the primitive to use
  114480. * @param indexStart defines the starting index
  114481. * @param indexCount defines the number of index to draw
  114482. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114483. */
  114484. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114485. /**
  114486. * Draw a list of unindexed primitives
  114487. * @param fillMode defines the primitive to use
  114488. * @param verticesStart defines the index of first vertex to draw
  114489. * @param verticesCount defines the count of vertices to draw
  114490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114491. */
  114492. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114493. private _drawMode;
  114494. /** @hidden */
  114495. protected _reportDrawCall(): void;
  114496. /** @hidden */
  114497. _releaseEffect(effect: Effect): void;
  114498. /** @hidden */
  114499. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114500. /**
  114501. * Create a new effect (used to store vertex/fragment shaders)
  114502. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  114503. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  114504. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  114505. * @param samplers defines an array of string used to represent textures
  114506. * @param defines defines the string containing the defines to use to compile the shaders
  114507. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  114508. * @param onCompiled defines a function to call when the effect creation is successful
  114509. * @param onError defines a function to call when the effect creation has failed
  114510. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  114511. * @returns the new Effect
  114512. */
  114513. 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;
  114514. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  114515. private _compileShader;
  114516. private _compileRawShader;
  114517. /** @hidden */
  114518. _getShaderSource(shader: WebGLShader): Nullable<string>;
  114519. /**
  114520. * Directly creates a webGL program
  114521. * @param pipelineContext defines the pipeline context to attach to
  114522. * @param vertexCode defines the vertex shader code to use
  114523. * @param fragmentCode defines the fragment shader code to use
  114524. * @param context defines the webGL context to use (if not set, the current one will be used)
  114525. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114526. * @returns the new webGL program
  114527. */
  114528. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114529. /**
  114530. * Creates a webGL program
  114531. * @param pipelineContext defines the pipeline context to attach to
  114532. * @param vertexCode defines the vertex shader code to use
  114533. * @param fragmentCode defines the fragment shader code to use
  114534. * @param defines defines the string containing the defines to use to compile the shaders
  114535. * @param context defines the webGL context to use (if not set, the current one will be used)
  114536. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114537. * @returns the new webGL program
  114538. */
  114539. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114540. /**
  114541. * Creates a new pipeline context
  114542. * @returns the new pipeline
  114543. */
  114544. createPipelineContext(): IPipelineContext;
  114545. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114546. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  114547. /** @hidden */
  114548. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114549. /** @hidden */
  114550. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114551. /** @hidden */
  114552. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114553. /**
  114554. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114555. * @param pipelineContext defines the pipeline context to use
  114556. * @param uniformsNames defines the list of uniform names
  114557. * @returns an array of webGL uniform locations
  114558. */
  114559. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114560. /**
  114561. * Gets the lsit of active attributes for a given webGL program
  114562. * @param pipelineContext defines the pipeline context to use
  114563. * @param attributesNames defines the list of attribute names to get
  114564. * @returns an array of indices indicating the offset of each attribute
  114565. */
  114566. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114567. /**
  114568. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114569. * @param effect defines the effect to activate
  114570. */
  114571. enableEffect(effect: Nullable<Effect>): void;
  114572. /**
  114573. * Set the value of an uniform to a number (int)
  114574. * @param uniform defines the webGL uniform location where to store the value
  114575. * @param value defines the int number to store
  114576. */
  114577. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114578. /**
  114579. * Set the value of an uniform to an array of int32
  114580. * @param uniform defines the webGL uniform location where to store the value
  114581. * @param array defines the array of int32 to store
  114582. */
  114583. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114584. /**
  114585. * Set the value of an uniform to an array of int32 (stored as vec2)
  114586. * @param uniform defines the webGL uniform location where to store the value
  114587. * @param array defines the array of int32 to store
  114588. */
  114589. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114590. /**
  114591. * Set the value of an uniform to an array of int32 (stored as vec3)
  114592. * @param uniform defines the webGL uniform location where to store the value
  114593. * @param array defines the array of int32 to store
  114594. */
  114595. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114596. /**
  114597. * Set the value of an uniform to an array of int32 (stored as vec4)
  114598. * @param uniform defines the webGL uniform location where to store the value
  114599. * @param array defines the array of int32 to store
  114600. */
  114601. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114602. /**
  114603. * Set the value of an uniform to an array of number
  114604. * @param uniform defines the webGL uniform location where to store the value
  114605. * @param array defines the array of number to store
  114606. */
  114607. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114608. /**
  114609. * Set the value of an uniform to an array of number (stored as vec2)
  114610. * @param uniform defines the webGL uniform location where to store the value
  114611. * @param array defines the array of number to store
  114612. */
  114613. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114614. /**
  114615. * Set the value of an uniform to an array of number (stored as vec3)
  114616. * @param uniform defines the webGL uniform location where to store the value
  114617. * @param array defines the array of number to store
  114618. */
  114619. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114620. /**
  114621. * Set the value of an uniform to an array of number (stored as vec4)
  114622. * @param uniform defines the webGL uniform location where to store the value
  114623. * @param array defines the array of number to store
  114624. */
  114625. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114626. /**
  114627. * Set the value of an uniform to an array of float32 (stored as matrices)
  114628. * @param uniform defines the webGL uniform location where to store the value
  114629. * @param matrices defines the array of float32 to store
  114630. */
  114631. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  114632. /**
  114633. * Set the value of an uniform to a matrix (3x3)
  114634. * @param uniform defines the webGL uniform location where to store the value
  114635. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114636. */
  114637. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114638. /**
  114639. * Set the value of an uniform to a matrix (2x2)
  114640. * @param uniform defines the webGL uniform location where to store the value
  114641. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114642. */
  114643. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114644. /**
  114645. * Set the value of an uniform to a number (float)
  114646. * @param uniform defines the webGL uniform location where to store the value
  114647. * @param value defines the float number to store
  114648. */
  114649. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114650. /**
  114651. * Set the value of an uniform to a vec2
  114652. * @param uniform defines the webGL uniform location where to store the value
  114653. * @param x defines the 1st component of the value
  114654. * @param y defines the 2nd component of the value
  114655. */
  114656. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  114657. /**
  114658. * Set the value of an uniform to a vec3
  114659. * @param uniform defines the webGL uniform location where to store the value
  114660. * @param x defines the 1st component of the value
  114661. * @param y defines the 2nd component of the value
  114662. * @param z defines the 3rd component of the value
  114663. */
  114664. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  114665. /**
  114666. * Set the value of an uniform to a vec4
  114667. * @param uniform defines the webGL uniform location where to store the value
  114668. * @param x defines the 1st component of the value
  114669. * @param y defines the 2nd component of the value
  114670. * @param z defines the 3rd component of the value
  114671. * @param w defines the 4th component of the value
  114672. */
  114673. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  114674. /**
  114675. * Apply all cached states (depth, culling, stencil and alpha)
  114676. */
  114677. applyStates(): void;
  114678. /**
  114679. * Enable or disable color writing
  114680. * @param enable defines the state to set
  114681. */
  114682. setColorWrite(enable: boolean): void;
  114683. /**
  114684. * Gets a boolean indicating if color writing is enabled
  114685. * @returns the current color writing state
  114686. */
  114687. getColorWrite(): boolean;
  114688. /**
  114689. * Gets the depth culling state manager
  114690. */
  114691. get depthCullingState(): DepthCullingState;
  114692. /**
  114693. * Gets the alpha state manager
  114694. */
  114695. get alphaState(): AlphaState;
  114696. /**
  114697. * Gets the stencil state manager
  114698. */
  114699. get stencilState(): StencilState;
  114700. /**
  114701. * Clears the list of texture accessible through engine.
  114702. * This can help preventing texture load conflict due to name collision.
  114703. */
  114704. clearInternalTexturesCache(): void;
  114705. /**
  114706. * Force the entire cache to be cleared
  114707. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114708. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114709. */
  114710. wipeCaches(bruteForce?: boolean): void;
  114711. /** @hidden */
  114712. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  114713. min: number;
  114714. mag: number;
  114715. };
  114716. /** @hidden */
  114717. _createTexture(): WebGLTexture;
  114718. /**
  114719. * Usually called from Texture.ts.
  114720. * Passed information to create a WebGLTexture
  114721. * @param url defines a value which contains one of the following:
  114722. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114723. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114724. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114725. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114726. * @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)
  114727. * @param scene needed for loading to the correct scene
  114728. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114729. * @param onLoad optional callback to be called upon successful completion
  114730. * @param onError optional callback to be called upon failure
  114731. * @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
  114732. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114733. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114734. * @param forcedExtension defines the extension to use to pick the right loader
  114735. * @param mimeType defines an optional mime type
  114736. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114737. */
  114738. 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;
  114739. /**
  114740. * Loads an image as an HTMLImageElement.
  114741. * @param input url string, ArrayBuffer, or Blob to load
  114742. * @param onLoad callback called when the image successfully loads
  114743. * @param onError callback called when the image fails to load
  114744. * @param offlineProvider offline provider for caching
  114745. * @param mimeType optional mime type
  114746. * @returns the HTMLImageElement of the loaded image
  114747. * @hidden
  114748. */
  114749. 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>;
  114750. /**
  114751. * @hidden
  114752. */
  114753. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114754. private _unpackFlipYCached;
  114755. /**
  114756. * In case you are sharing the context with other applications, it might
  114757. * be interested to not cache the unpack flip y state to ensure a consistent
  114758. * value would be set.
  114759. */
  114760. enableUnpackFlipYCached: boolean;
  114761. /** @hidden */
  114762. _unpackFlipY(value: boolean): void;
  114763. /** @hidden */
  114764. _getUnpackAlignement(): number;
  114765. private _getTextureTarget;
  114766. /**
  114767. * Update the sampling mode of a given texture
  114768. * @param samplingMode defines the required sampling mode
  114769. * @param texture defines the texture to update
  114770. * @param generateMipMaps defines whether to generate mipmaps for the texture
  114771. */
  114772. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  114773. /**
  114774. * Update the sampling mode of a given texture
  114775. * @param texture defines the texture to update
  114776. * @param wrapU defines the texture wrap mode of the u coordinates
  114777. * @param wrapV defines the texture wrap mode of the v coordinates
  114778. * @param wrapR defines the texture wrap mode of the r coordinates
  114779. */
  114780. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  114781. /** @hidden */
  114782. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  114783. width: number;
  114784. height: number;
  114785. layers?: number;
  114786. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  114787. /** @hidden */
  114788. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114789. /** @hidden */
  114790. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  114791. /**
  114792. * Update a portion of an internal texture
  114793. * @param texture defines the texture to update
  114794. * @param imageData defines the data to store into the texture
  114795. * @param xOffset defines the x coordinates of the update rectangle
  114796. * @param yOffset defines the y coordinates of the update rectangle
  114797. * @param width defines the width of the update rectangle
  114798. * @param height defines the height of the update rectangle
  114799. * @param faceIndex defines the face index if texture is a cube (0 by default)
  114800. * @param lod defines the lod level to update (0 by default)
  114801. */
  114802. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  114803. /** @hidden */
  114804. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114805. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  114806. private _prepareWebGLTexture;
  114807. /** @hidden */
  114808. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  114809. private _getDepthStencilBuffer;
  114810. /** @hidden */
  114811. _releaseFramebufferObjects(texture: InternalTexture): void;
  114812. /** @hidden */
  114813. _releaseTexture(texture: InternalTexture): void;
  114814. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114815. protected _setProgram(program: WebGLProgram): void;
  114816. protected _boundUniforms: {
  114817. [key: number]: WebGLUniformLocation;
  114818. };
  114819. /**
  114820. * Binds an effect to the webGL context
  114821. * @param effect defines the effect to bind
  114822. */
  114823. bindSamplers(effect: Effect): void;
  114824. private _activateCurrentTexture;
  114825. /** @hidden */
  114826. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  114827. /** @hidden */
  114828. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  114829. /**
  114830. * Unbind all textures from the webGL context
  114831. */
  114832. unbindAllTextures(): void;
  114833. /**
  114834. * Sets a texture to the according uniform.
  114835. * @param channel The texture channel
  114836. * @param uniform The uniform to set
  114837. * @param texture The texture to apply
  114838. */
  114839. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  114840. private _bindSamplerUniformToChannel;
  114841. private _getTextureWrapMode;
  114842. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114843. /**
  114844. * Sets an array of texture to the webGL context
  114845. * @param channel defines the channel where the texture array must be set
  114846. * @param uniform defines the associated uniform location
  114847. * @param textures defines the array of textures to bind
  114848. */
  114849. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  114850. /** @hidden */
  114851. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  114852. private _setTextureParameterFloat;
  114853. private _setTextureParameterInteger;
  114854. /**
  114855. * Unbind all vertex attributes from the webGL context
  114856. */
  114857. unbindAllAttributes(): void;
  114858. /**
  114859. * 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
  114860. */
  114861. releaseEffects(): void;
  114862. /**
  114863. * Dispose and release all associated resources
  114864. */
  114865. dispose(): void;
  114866. /**
  114867. * Attach a new callback raised when context lost event is fired
  114868. * @param callback defines the callback to call
  114869. */
  114870. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114871. /**
  114872. * Attach a new callback raised when context restored event is fired
  114873. * @param callback defines the callback to call
  114874. */
  114875. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114876. /**
  114877. * Get the current error code of the webGL context
  114878. * @returns the error code
  114879. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  114880. */
  114881. getError(): number;
  114882. private _canRenderToFloatFramebuffer;
  114883. private _canRenderToHalfFloatFramebuffer;
  114884. private _canRenderToFramebuffer;
  114885. /** @hidden */
  114886. _getWebGLTextureType(type: number): number;
  114887. /** @hidden */
  114888. _getInternalFormat(format: number): number;
  114889. /** @hidden */
  114890. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  114891. /** @hidden */
  114892. _getRGBAMultiSampleBufferFormat(type: number): number;
  114893. /** @hidden */
  114894. _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;
  114895. /**
  114896. * Loads a file from a url
  114897. * @param url url to load
  114898. * @param onSuccess callback called when the file successfully loads
  114899. * @param onProgress callback called while file is loading (if the server supports this mode)
  114900. * @param offlineProvider defines the offline provider for caching
  114901. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114902. * @param onError callback called when the file fails to load
  114903. * @returns a file request object
  114904. * @hidden
  114905. */
  114906. 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;
  114907. /**
  114908. * Reads pixels from the current frame buffer. Please note that this function can be slow
  114909. * @param x defines the x coordinate of the rectangle where pixels must be read
  114910. * @param y defines the y coordinate of the rectangle where pixels must be read
  114911. * @param width defines the width of the rectangle where pixels must be read
  114912. * @param height defines the height of the rectangle where pixels must be read
  114913. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  114914. * @returns a Uint8Array containing RGBA colors
  114915. */
  114916. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  114917. private static _isSupported;
  114918. /**
  114919. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  114920. * @returns true if the engine can be created
  114921. * @ignorenaming
  114922. */
  114923. static isSupported(): boolean;
  114924. /**
  114925. * Find the next highest power of two.
  114926. * @param x Number to start search from.
  114927. * @return Next highest power of two.
  114928. */
  114929. static CeilingPOT(x: number): number;
  114930. /**
  114931. * Find the next lowest power of two.
  114932. * @param x Number to start search from.
  114933. * @return Next lowest power of two.
  114934. */
  114935. static FloorPOT(x: number): number;
  114936. /**
  114937. * Find the nearest power of two.
  114938. * @param x Number to start search from.
  114939. * @return Next nearest power of two.
  114940. */
  114941. static NearestPOT(x: number): number;
  114942. /**
  114943. * Get the closest exponent of two
  114944. * @param value defines the value to approximate
  114945. * @param max defines the maximum value to return
  114946. * @param mode defines how to define the closest value
  114947. * @returns closest exponent of two of the given value
  114948. */
  114949. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  114950. /**
  114951. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  114952. * @param func - the function to be called
  114953. * @param requester - the object that will request the next frame. Falls back to window.
  114954. * @returns frame number
  114955. */
  114956. static QueueNewFrame(func: () => void, requester?: any): number;
  114957. /**
  114958. * Gets host document
  114959. * @returns the host document object
  114960. */
  114961. getHostDocument(): Nullable<Document>;
  114962. }
  114963. }
  114964. declare module BABYLON {
  114965. /**
  114966. * Class representing spherical harmonics coefficients to the 3rd degree
  114967. */
  114968. export class SphericalHarmonics {
  114969. /**
  114970. * Defines whether or not the harmonics have been prescaled for rendering.
  114971. */
  114972. preScaled: boolean;
  114973. /**
  114974. * The l0,0 coefficients of the spherical harmonics
  114975. */
  114976. l00: Vector3;
  114977. /**
  114978. * The l1,-1 coefficients of the spherical harmonics
  114979. */
  114980. l1_1: Vector3;
  114981. /**
  114982. * The l1,0 coefficients of the spherical harmonics
  114983. */
  114984. l10: Vector3;
  114985. /**
  114986. * The l1,1 coefficients of the spherical harmonics
  114987. */
  114988. l11: Vector3;
  114989. /**
  114990. * The l2,-2 coefficients of the spherical harmonics
  114991. */
  114992. l2_2: Vector3;
  114993. /**
  114994. * The l2,-1 coefficients of the spherical harmonics
  114995. */
  114996. l2_1: Vector3;
  114997. /**
  114998. * The l2,0 coefficients of the spherical harmonics
  114999. */
  115000. l20: Vector3;
  115001. /**
  115002. * The l2,1 coefficients of the spherical harmonics
  115003. */
  115004. l21: Vector3;
  115005. /**
  115006. * The l2,2 coefficients of the spherical harmonics
  115007. */
  115008. l22: Vector3;
  115009. /**
  115010. * Adds a light to the spherical harmonics
  115011. * @param direction the direction of the light
  115012. * @param color the color of the light
  115013. * @param deltaSolidAngle the delta solid angle of the light
  115014. */
  115015. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  115016. /**
  115017. * Scales the spherical harmonics by the given amount
  115018. * @param scale the amount to scale
  115019. */
  115020. scaleInPlace(scale: number): void;
  115021. /**
  115022. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  115023. *
  115024. * ```
  115025. * E_lm = A_l * L_lm
  115026. * ```
  115027. *
  115028. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  115029. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  115030. * the scaling factors are given in equation 9.
  115031. */
  115032. convertIncidentRadianceToIrradiance(): void;
  115033. /**
  115034. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  115035. *
  115036. * ```
  115037. * L = (1/pi) * E * rho
  115038. * ```
  115039. *
  115040. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  115041. */
  115042. convertIrradianceToLambertianRadiance(): void;
  115043. /**
  115044. * Integrates the reconstruction coefficients directly in to the SH preventing further
  115045. * required operations at run time.
  115046. *
  115047. * This is simply done by scaling back the SH with Ylm constants parameter.
  115048. * The trigonometric part being applied by the shader at run time.
  115049. */
  115050. preScaleForRendering(): void;
  115051. /**
  115052. * Constructs a spherical harmonics from an array.
  115053. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  115054. * @returns the spherical harmonics
  115055. */
  115056. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  115057. /**
  115058. * Gets the spherical harmonics from polynomial
  115059. * @param polynomial the spherical polynomial
  115060. * @returns the spherical harmonics
  115061. */
  115062. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  115063. }
  115064. /**
  115065. * Class representing spherical polynomial coefficients to the 3rd degree
  115066. */
  115067. export class SphericalPolynomial {
  115068. private _harmonics;
  115069. /**
  115070. * The spherical harmonics used to create the polynomials.
  115071. */
  115072. get preScaledHarmonics(): SphericalHarmonics;
  115073. /**
  115074. * The x coefficients of the spherical polynomial
  115075. */
  115076. x: Vector3;
  115077. /**
  115078. * The y coefficients of the spherical polynomial
  115079. */
  115080. y: Vector3;
  115081. /**
  115082. * The z coefficients of the spherical polynomial
  115083. */
  115084. z: Vector3;
  115085. /**
  115086. * The xx coefficients of the spherical polynomial
  115087. */
  115088. xx: Vector3;
  115089. /**
  115090. * The yy coefficients of the spherical polynomial
  115091. */
  115092. yy: Vector3;
  115093. /**
  115094. * The zz coefficients of the spherical polynomial
  115095. */
  115096. zz: Vector3;
  115097. /**
  115098. * The xy coefficients of the spherical polynomial
  115099. */
  115100. xy: Vector3;
  115101. /**
  115102. * The yz coefficients of the spherical polynomial
  115103. */
  115104. yz: Vector3;
  115105. /**
  115106. * The zx coefficients of the spherical polynomial
  115107. */
  115108. zx: Vector3;
  115109. /**
  115110. * Adds an ambient color to the spherical polynomial
  115111. * @param color the color to add
  115112. */
  115113. addAmbient(color: Color3): void;
  115114. /**
  115115. * Scales the spherical polynomial by the given amount
  115116. * @param scale the amount to scale
  115117. */
  115118. scaleInPlace(scale: number): void;
  115119. /**
  115120. * Gets the spherical polynomial from harmonics
  115121. * @param harmonics the spherical harmonics
  115122. * @returns the spherical polynomial
  115123. */
  115124. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  115125. /**
  115126. * Constructs a spherical polynomial from an array.
  115127. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  115128. * @returns the spherical polynomial
  115129. */
  115130. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  115131. }
  115132. }
  115133. declare module BABYLON {
  115134. /**
  115135. * Defines the source of the internal texture
  115136. */
  115137. export enum InternalTextureSource {
  115138. /**
  115139. * The source of the texture data is unknown
  115140. */
  115141. Unknown = 0,
  115142. /**
  115143. * Texture data comes from an URL
  115144. */
  115145. Url = 1,
  115146. /**
  115147. * Texture data is only used for temporary storage
  115148. */
  115149. Temp = 2,
  115150. /**
  115151. * Texture data comes from raw data (ArrayBuffer)
  115152. */
  115153. Raw = 3,
  115154. /**
  115155. * Texture content is dynamic (video or dynamic texture)
  115156. */
  115157. Dynamic = 4,
  115158. /**
  115159. * Texture content is generated by rendering to it
  115160. */
  115161. RenderTarget = 5,
  115162. /**
  115163. * Texture content is part of a multi render target process
  115164. */
  115165. MultiRenderTarget = 6,
  115166. /**
  115167. * Texture data comes from a cube data file
  115168. */
  115169. Cube = 7,
  115170. /**
  115171. * Texture data comes from a raw cube data
  115172. */
  115173. CubeRaw = 8,
  115174. /**
  115175. * Texture data come from a prefiltered cube data file
  115176. */
  115177. CubePrefiltered = 9,
  115178. /**
  115179. * Texture content is raw 3D data
  115180. */
  115181. Raw3D = 10,
  115182. /**
  115183. * Texture content is raw 2D array data
  115184. */
  115185. Raw2DArray = 11,
  115186. /**
  115187. * Texture content is a depth texture
  115188. */
  115189. Depth = 12,
  115190. /**
  115191. * Texture data comes from a raw cube data encoded with RGBD
  115192. */
  115193. CubeRawRGBD = 13
  115194. }
  115195. /**
  115196. * Class used to store data associated with WebGL texture data for the engine
  115197. * This class should not be used directly
  115198. */
  115199. export class InternalTexture {
  115200. /** @hidden */
  115201. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  115202. /**
  115203. * Defines if the texture is ready
  115204. */
  115205. isReady: boolean;
  115206. /**
  115207. * Defines if the texture is a cube texture
  115208. */
  115209. isCube: boolean;
  115210. /**
  115211. * Defines if the texture contains 3D data
  115212. */
  115213. is3D: boolean;
  115214. /**
  115215. * Defines if the texture contains 2D array data
  115216. */
  115217. is2DArray: boolean;
  115218. /**
  115219. * Defines if the texture contains multiview data
  115220. */
  115221. isMultiview: boolean;
  115222. /**
  115223. * Gets the URL used to load this texture
  115224. */
  115225. url: string;
  115226. /**
  115227. * Gets the sampling mode of the texture
  115228. */
  115229. samplingMode: number;
  115230. /**
  115231. * Gets a boolean indicating if the texture needs mipmaps generation
  115232. */
  115233. generateMipMaps: boolean;
  115234. /**
  115235. * Gets the number of samples used by the texture (WebGL2+ only)
  115236. */
  115237. samples: number;
  115238. /**
  115239. * Gets the type of the texture (int, float...)
  115240. */
  115241. type: number;
  115242. /**
  115243. * Gets the format of the texture (RGB, RGBA...)
  115244. */
  115245. format: number;
  115246. /**
  115247. * Observable called when the texture is loaded
  115248. */
  115249. onLoadedObservable: Observable<InternalTexture>;
  115250. /**
  115251. * Gets the width of the texture
  115252. */
  115253. width: number;
  115254. /**
  115255. * Gets the height of the texture
  115256. */
  115257. height: number;
  115258. /**
  115259. * Gets the depth of the texture
  115260. */
  115261. depth: number;
  115262. /**
  115263. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  115264. */
  115265. baseWidth: number;
  115266. /**
  115267. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  115268. */
  115269. baseHeight: number;
  115270. /**
  115271. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  115272. */
  115273. baseDepth: number;
  115274. /**
  115275. * Gets a boolean indicating if the texture is inverted on Y axis
  115276. */
  115277. invertY: boolean;
  115278. /** @hidden */
  115279. _invertVScale: boolean;
  115280. /** @hidden */
  115281. _associatedChannel: number;
  115282. /** @hidden */
  115283. _source: InternalTextureSource;
  115284. /** @hidden */
  115285. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  115286. /** @hidden */
  115287. _bufferView: Nullable<ArrayBufferView>;
  115288. /** @hidden */
  115289. _bufferViewArray: Nullable<ArrayBufferView[]>;
  115290. /** @hidden */
  115291. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  115292. /** @hidden */
  115293. _size: number;
  115294. /** @hidden */
  115295. _extension: string;
  115296. /** @hidden */
  115297. _files: Nullable<string[]>;
  115298. /** @hidden */
  115299. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115300. /** @hidden */
  115301. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115302. /** @hidden */
  115303. _framebuffer: Nullable<WebGLFramebuffer>;
  115304. /** @hidden */
  115305. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  115306. /** @hidden */
  115307. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  115308. /** @hidden */
  115309. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  115310. /** @hidden */
  115311. _attachments: Nullable<number[]>;
  115312. /** @hidden */
  115313. _textureArray: Nullable<InternalTexture[]>;
  115314. /** @hidden */
  115315. _cachedCoordinatesMode: Nullable<number>;
  115316. /** @hidden */
  115317. _cachedWrapU: Nullable<number>;
  115318. /** @hidden */
  115319. _cachedWrapV: Nullable<number>;
  115320. /** @hidden */
  115321. _cachedWrapR: Nullable<number>;
  115322. /** @hidden */
  115323. _cachedAnisotropicFilteringLevel: Nullable<number>;
  115324. /** @hidden */
  115325. _isDisabled: boolean;
  115326. /** @hidden */
  115327. _compression: Nullable<string>;
  115328. /** @hidden */
  115329. _generateStencilBuffer: boolean;
  115330. /** @hidden */
  115331. _generateDepthBuffer: boolean;
  115332. /** @hidden */
  115333. _comparisonFunction: number;
  115334. /** @hidden */
  115335. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  115336. /** @hidden */
  115337. _lodGenerationScale: number;
  115338. /** @hidden */
  115339. _lodGenerationOffset: number;
  115340. /** @hidden */
  115341. _depthStencilTexture: Nullable<InternalTexture>;
  115342. /** @hidden */
  115343. _colorTextureArray: Nullable<WebGLTexture>;
  115344. /** @hidden */
  115345. _depthStencilTextureArray: Nullable<WebGLTexture>;
  115346. /** @hidden */
  115347. _lodTextureHigh: Nullable<BaseTexture>;
  115348. /** @hidden */
  115349. _lodTextureMid: Nullable<BaseTexture>;
  115350. /** @hidden */
  115351. _lodTextureLow: Nullable<BaseTexture>;
  115352. /** @hidden */
  115353. _isRGBD: boolean;
  115354. /** @hidden */
  115355. _linearSpecularLOD: boolean;
  115356. /** @hidden */
  115357. _irradianceTexture: Nullable<BaseTexture>;
  115358. /** @hidden */
  115359. _webGLTexture: Nullable<WebGLTexture>;
  115360. /** @hidden */
  115361. _references: number;
  115362. private _engine;
  115363. /**
  115364. * Gets the Engine the texture belongs to.
  115365. * @returns The babylon engine
  115366. */
  115367. getEngine(): ThinEngine;
  115368. /**
  115369. * Gets the data source type of the texture
  115370. */
  115371. get source(): InternalTextureSource;
  115372. /**
  115373. * Creates a new InternalTexture
  115374. * @param engine defines the engine to use
  115375. * @param source defines the type of data that will be used
  115376. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115377. */
  115378. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115379. /**
  115380. * Increments the number of references (ie. the number of Texture that point to it)
  115381. */
  115382. incrementReferences(): void;
  115383. /**
  115384. * Change the size of the texture (not the size of the content)
  115385. * @param width defines the new width
  115386. * @param height defines the new height
  115387. * @param depth defines the new depth (1 by default)
  115388. */
  115389. updateSize(width: int, height: int, depth?: int): void;
  115390. /** @hidden */
  115391. _rebuild(): void;
  115392. /** @hidden */
  115393. _swapAndDie(target: InternalTexture): void;
  115394. /**
  115395. * Dispose the current allocated resources
  115396. */
  115397. dispose(): void;
  115398. }
  115399. }
  115400. declare module BABYLON {
  115401. /**
  115402. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115403. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115404. */
  115405. export class Analyser {
  115406. /**
  115407. * Gets or sets the smoothing
  115408. * @ignorenaming
  115409. */
  115410. SMOOTHING: number;
  115411. /**
  115412. * Gets or sets the FFT table size
  115413. * @ignorenaming
  115414. */
  115415. FFT_SIZE: number;
  115416. /**
  115417. * Gets or sets the bar graph amplitude
  115418. * @ignorenaming
  115419. */
  115420. BARGRAPHAMPLITUDE: number;
  115421. /**
  115422. * Gets or sets the position of the debug canvas
  115423. * @ignorenaming
  115424. */
  115425. DEBUGCANVASPOS: {
  115426. x: number;
  115427. y: number;
  115428. };
  115429. /**
  115430. * Gets or sets the debug canvas size
  115431. * @ignorenaming
  115432. */
  115433. DEBUGCANVASSIZE: {
  115434. width: number;
  115435. height: number;
  115436. };
  115437. private _byteFreqs;
  115438. private _byteTime;
  115439. private _floatFreqs;
  115440. private _webAudioAnalyser;
  115441. private _debugCanvas;
  115442. private _debugCanvasContext;
  115443. private _scene;
  115444. private _registerFunc;
  115445. private _audioEngine;
  115446. /**
  115447. * Creates a new analyser
  115448. * @param scene defines hosting scene
  115449. */
  115450. constructor(scene: Scene);
  115451. /**
  115452. * Get the number of data values you will have to play with for the visualization
  115453. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  115454. * @returns a number
  115455. */
  115456. getFrequencyBinCount(): number;
  115457. /**
  115458. * Gets the current frequency data as a byte array
  115459. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115460. * @returns a Uint8Array
  115461. */
  115462. getByteFrequencyData(): Uint8Array;
  115463. /**
  115464. * Gets the current waveform as a byte array
  115465. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  115466. * @returns a Uint8Array
  115467. */
  115468. getByteTimeDomainData(): Uint8Array;
  115469. /**
  115470. * Gets the current frequency data as a float array
  115471. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115472. * @returns a Float32Array
  115473. */
  115474. getFloatFrequencyData(): Float32Array;
  115475. /**
  115476. * Renders the debug canvas
  115477. */
  115478. drawDebugCanvas(): void;
  115479. /**
  115480. * Stops rendering the debug canvas and removes it
  115481. */
  115482. stopDebugCanvas(): void;
  115483. /**
  115484. * Connects two audio nodes
  115485. * @param inputAudioNode defines first node to connect
  115486. * @param outputAudioNode defines second node to connect
  115487. */
  115488. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  115489. /**
  115490. * Releases all associated resources
  115491. */
  115492. dispose(): void;
  115493. }
  115494. }
  115495. declare module BABYLON {
  115496. /**
  115497. * This represents an audio engine and it is responsible
  115498. * to play, synchronize and analyse sounds throughout the application.
  115499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115500. */
  115501. export interface IAudioEngine extends IDisposable {
  115502. /**
  115503. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115504. */
  115505. readonly canUseWebAudio: boolean;
  115506. /**
  115507. * Gets the current AudioContext if available.
  115508. */
  115509. readonly audioContext: Nullable<AudioContext>;
  115510. /**
  115511. * The master gain node defines the global audio volume of your audio engine.
  115512. */
  115513. readonly masterGain: GainNode;
  115514. /**
  115515. * Gets whether or not mp3 are supported by your browser.
  115516. */
  115517. readonly isMP3supported: boolean;
  115518. /**
  115519. * Gets whether or not ogg are supported by your browser.
  115520. */
  115521. readonly isOGGsupported: boolean;
  115522. /**
  115523. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115524. * @ignoreNaming
  115525. */
  115526. WarnedWebAudioUnsupported: boolean;
  115527. /**
  115528. * Defines if the audio engine relies on a custom unlocked button.
  115529. * In this case, the embedded button will not be displayed.
  115530. */
  115531. useCustomUnlockedButton: boolean;
  115532. /**
  115533. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  115534. */
  115535. readonly unlocked: boolean;
  115536. /**
  115537. * Event raised when audio has been unlocked on the browser.
  115538. */
  115539. onAudioUnlockedObservable: Observable<AudioEngine>;
  115540. /**
  115541. * Event raised when audio has been locked on the browser.
  115542. */
  115543. onAudioLockedObservable: Observable<AudioEngine>;
  115544. /**
  115545. * Flags the audio engine in Locked state.
  115546. * This happens due to new browser policies preventing audio to autoplay.
  115547. */
  115548. lock(): void;
  115549. /**
  115550. * Unlocks the audio engine once a user action has been done on the dom.
  115551. * This is helpful to resume play once browser policies have been satisfied.
  115552. */
  115553. unlock(): void;
  115554. /**
  115555. * Gets the global volume sets on the master gain.
  115556. * @returns the global volume if set or -1 otherwise
  115557. */
  115558. getGlobalVolume(): number;
  115559. /**
  115560. * Sets the global volume of your experience (sets on the master gain).
  115561. * @param newVolume Defines the new global volume of the application
  115562. */
  115563. setGlobalVolume(newVolume: number): void;
  115564. /**
  115565. * Connect the audio engine to an audio analyser allowing some amazing
  115566. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115567. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115568. * @param analyser The analyser to connect to the engine
  115569. */
  115570. connectToAnalyser(analyser: Analyser): void;
  115571. }
  115572. /**
  115573. * This represents the default audio engine used in babylon.
  115574. * It is responsible to play, synchronize and analyse sounds throughout the application.
  115575. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115576. */
  115577. export class AudioEngine implements IAudioEngine {
  115578. private _audioContext;
  115579. private _audioContextInitialized;
  115580. private _muteButton;
  115581. private _hostElement;
  115582. /**
  115583. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115584. */
  115585. canUseWebAudio: boolean;
  115586. /**
  115587. * The master gain node defines the global audio volume of your audio engine.
  115588. */
  115589. masterGain: GainNode;
  115590. /**
  115591. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115592. * @ignoreNaming
  115593. */
  115594. WarnedWebAudioUnsupported: boolean;
  115595. /**
  115596. * Gets whether or not mp3 are supported by your browser.
  115597. */
  115598. isMP3supported: boolean;
  115599. /**
  115600. * Gets whether or not ogg are supported by your browser.
  115601. */
  115602. isOGGsupported: boolean;
  115603. /**
  115604. * Gets whether audio has been unlocked on the device.
  115605. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  115606. * a user interaction has happened.
  115607. */
  115608. unlocked: boolean;
  115609. /**
  115610. * Defines if the audio engine relies on a custom unlocked button.
  115611. * In this case, the embedded button will not be displayed.
  115612. */
  115613. useCustomUnlockedButton: boolean;
  115614. /**
  115615. * Event raised when audio has been unlocked on the browser.
  115616. */
  115617. onAudioUnlockedObservable: Observable<AudioEngine>;
  115618. /**
  115619. * Event raised when audio has been locked on the browser.
  115620. */
  115621. onAudioLockedObservable: Observable<AudioEngine>;
  115622. /**
  115623. * Gets the current AudioContext if available.
  115624. */
  115625. get audioContext(): Nullable<AudioContext>;
  115626. private _connectedAnalyser;
  115627. /**
  115628. * Instantiates a new audio engine.
  115629. *
  115630. * There should be only one per page as some browsers restrict the number
  115631. * of audio contexts you can create.
  115632. * @param hostElement defines the host element where to display the mute icon if necessary
  115633. */
  115634. constructor(hostElement?: Nullable<HTMLElement>);
  115635. /**
  115636. * Flags the audio engine in Locked state.
  115637. * This happens due to new browser policies preventing audio to autoplay.
  115638. */
  115639. lock(): void;
  115640. /**
  115641. * Unlocks the audio engine once a user action has been done on the dom.
  115642. * This is helpful to resume play once browser policies have been satisfied.
  115643. */
  115644. unlock(): void;
  115645. private _resumeAudioContext;
  115646. private _initializeAudioContext;
  115647. private _tryToRun;
  115648. private _triggerRunningState;
  115649. private _triggerSuspendedState;
  115650. private _displayMuteButton;
  115651. private _moveButtonToTopLeft;
  115652. private _onResize;
  115653. private _hideMuteButton;
  115654. /**
  115655. * Destroy and release the resources associated with the audio ccontext.
  115656. */
  115657. dispose(): void;
  115658. /**
  115659. * Gets the global volume sets on the master gain.
  115660. * @returns the global volume if set or -1 otherwise
  115661. */
  115662. getGlobalVolume(): number;
  115663. /**
  115664. * Sets the global volume of your experience (sets on the master gain).
  115665. * @param newVolume Defines the new global volume of the application
  115666. */
  115667. setGlobalVolume(newVolume: number): void;
  115668. /**
  115669. * Connect the audio engine to an audio analyser allowing some amazing
  115670. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115671. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115672. * @param analyser The analyser to connect to the engine
  115673. */
  115674. connectToAnalyser(analyser: Analyser): void;
  115675. }
  115676. }
  115677. declare module BABYLON {
  115678. /**
  115679. * Interface used to present a loading screen while loading a scene
  115680. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115681. */
  115682. export interface ILoadingScreen {
  115683. /**
  115684. * Function called to display the loading screen
  115685. */
  115686. displayLoadingUI: () => void;
  115687. /**
  115688. * Function called to hide the loading screen
  115689. */
  115690. hideLoadingUI: () => void;
  115691. /**
  115692. * Gets or sets the color to use for the background
  115693. */
  115694. loadingUIBackgroundColor: string;
  115695. /**
  115696. * Gets or sets the text to display while loading
  115697. */
  115698. loadingUIText: string;
  115699. }
  115700. /**
  115701. * Class used for the default loading screen
  115702. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115703. */
  115704. export class DefaultLoadingScreen implements ILoadingScreen {
  115705. private _renderingCanvas;
  115706. private _loadingText;
  115707. private _loadingDivBackgroundColor;
  115708. private _loadingDiv;
  115709. private _loadingTextDiv;
  115710. /** Gets or sets the logo url to use for the default loading screen */
  115711. static DefaultLogoUrl: string;
  115712. /** Gets or sets the spinner url to use for the default loading screen */
  115713. static DefaultSpinnerUrl: string;
  115714. /**
  115715. * Creates a new default loading screen
  115716. * @param _renderingCanvas defines the canvas used to render the scene
  115717. * @param _loadingText defines the default text to display
  115718. * @param _loadingDivBackgroundColor defines the default background color
  115719. */
  115720. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  115721. /**
  115722. * Function called to display the loading screen
  115723. */
  115724. displayLoadingUI(): void;
  115725. /**
  115726. * Function called to hide the loading screen
  115727. */
  115728. hideLoadingUI(): void;
  115729. /**
  115730. * Gets or sets the text to display while loading
  115731. */
  115732. set loadingUIText(text: string);
  115733. get loadingUIText(): string;
  115734. /**
  115735. * Gets or sets the color to use for the background
  115736. */
  115737. get loadingUIBackgroundColor(): string;
  115738. set loadingUIBackgroundColor(color: string);
  115739. private _resizeLoadingUI;
  115740. }
  115741. }
  115742. declare module BABYLON {
  115743. /**
  115744. * Interface for any object that can request an animation frame
  115745. */
  115746. export interface ICustomAnimationFrameRequester {
  115747. /**
  115748. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  115749. */
  115750. renderFunction?: Function;
  115751. /**
  115752. * Called to request the next frame to render to
  115753. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  115754. */
  115755. requestAnimationFrame: Function;
  115756. /**
  115757. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  115758. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  115759. */
  115760. requestID?: number;
  115761. }
  115762. }
  115763. declare module BABYLON {
  115764. /**
  115765. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  115766. */
  115767. export class PerformanceMonitor {
  115768. private _enabled;
  115769. private _rollingFrameTime;
  115770. private _lastFrameTimeMs;
  115771. /**
  115772. * constructor
  115773. * @param frameSampleSize The number of samples required to saturate the sliding window
  115774. */
  115775. constructor(frameSampleSize?: number);
  115776. /**
  115777. * Samples current frame
  115778. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  115779. */
  115780. sampleFrame(timeMs?: number): void;
  115781. /**
  115782. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115783. */
  115784. get averageFrameTime(): number;
  115785. /**
  115786. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115787. */
  115788. get averageFrameTimeVariance(): number;
  115789. /**
  115790. * Returns the frame time of the most recent frame
  115791. */
  115792. get instantaneousFrameTime(): number;
  115793. /**
  115794. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  115795. */
  115796. get averageFPS(): number;
  115797. /**
  115798. * Returns the average framerate in frames per second using the most recent frame time
  115799. */
  115800. get instantaneousFPS(): number;
  115801. /**
  115802. * Returns true if enough samples have been taken to completely fill the sliding window
  115803. */
  115804. get isSaturated(): boolean;
  115805. /**
  115806. * Enables contributions to the sliding window sample set
  115807. */
  115808. enable(): void;
  115809. /**
  115810. * Disables contributions to the sliding window sample set
  115811. * Samples will not be interpolated over the disabled period
  115812. */
  115813. disable(): void;
  115814. /**
  115815. * Returns true if sampling is enabled
  115816. */
  115817. get isEnabled(): boolean;
  115818. /**
  115819. * Resets performance monitor
  115820. */
  115821. reset(): void;
  115822. }
  115823. /**
  115824. * RollingAverage
  115825. *
  115826. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  115827. */
  115828. export class RollingAverage {
  115829. /**
  115830. * Current average
  115831. */
  115832. average: number;
  115833. /**
  115834. * Current variance
  115835. */
  115836. variance: number;
  115837. protected _samples: Array<number>;
  115838. protected _sampleCount: number;
  115839. protected _pos: number;
  115840. protected _m2: number;
  115841. /**
  115842. * constructor
  115843. * @param length The number of samples required to saturate the sliding window
  115844. */
  115845. constructor(length: number);
  115846. /**
  115847. * Adds a sample to the sample set
  115848. * @param v The sample value
  115849. */
  115850. add(v: number): void;
  115851. /**
  115852. * Returns previously added values or null if outside of history or outside the sliding window domain
  115853. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  115854. * @return Value previously recorded with add() or null if outside of range
  115855. */
  115856. history(i: number): number;
  115857. /**
  115858. * Returns true if enough samples have been taken to completely fill the sliding window
  115859. * @return true if sample-set saturated
  115860. */
  115861. isSaturated(): boolean;
  115862. /**
  115863. * Resets the rolling average (equivalent to 0 samples taken so far)
  115864. */
  115865. reset(): void;
  115866. /**
  115867. * Wraps a value around the sample range boundaries
  115868. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  115869. * @return Wrapped position in sample range
  115870. */
  115871. protected _wrapPosition(i: number): number;
  115872. }
  115873. }
  115874. declare module BABYLON {
  115875. /**
  115876. * This class is used to track a performance counter which is number based.
  115877. * The user has access to many properties which give statistics of different nature.
  115878. *
  115879. * The implementer can track two kinds of Performance Counter: time and count.
  115880. * 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.
  115881. * 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.
  115882. */
  115883. export class PerfCounter {
  115884. /**
  115885. * Gets or sets a global boolean to turn on and off all the counters
  115886. */
  115887. static Enabled: boolean;
  115888. /**
  115889. * Returns the smallest value ever
  115890. */
  115891. get min(): number;
  115892. /**
  115893. * Returns the biggest value ever
  115894. */
  115895. get max(): number;
  115896. /**
  115897. * Returns the average value since the performance counter is running
  115898. */
  115899. get average(): number;
  115900. /**
  115901. * Returns the average value of the last second the counter was monitored
  115902. */
  115903. get lastSecAverage(): number;
  115904. /**
  115905. * Returns the current value
  115906. */
  115907. get current(): number;
  115908. /**
  115909. * Gets the accumulated total
  115910. */
  115911. get total(): number;
  115912. /**
  115913. * Gets the total value count
  115914. */
  115915. get count(): number;
  115916. /**
  115917. * Creates a new counter
  115918. */
  115919. constructor();
  115920. /**
  115921. * Call this method to start monitoring a new frame.
  115922. * 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.
  115923. */
  115924. fetchNewFrame(): void;
  115925. /**
  115926. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  115927. * @param newCount the count value to add to the monitored count
  115928. * @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.
  115929. */
  115930. addCount(newCount: number, fetchResult: boolean): void;
  115931. /**
  115932. * Start monitoring this performance counter
  115933. */
  115934. beginMonitoring(): void;
  115935. /**
  115936. * Compute the time lapsed since the previous beginMonitoring() call.
  115937. * @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
  115938. */
  115939. endMonitoring(newFrame?: boolean): void;
  115940. private _fetchResult;
  115941. private _startMonitoringTime;
  115942. private _min;
  115943. private _max;
  115944. private _average;
  115945. private _current;
  115946. private _totalValueCount;
  115947. private _totalAccumulated;
  115948. private _lastSecAverage;
  115949. private _lastSecAccumulated;
  115950. private _lastSecTime;
  115951. private _lastSecValueCount;
  115952. }
  115953. }
  115954. declare module BABYLON {
  115955. interface ThinEngine {
  115956. /**
  115957. * Sets alpha constants used by some alpha blending modes
  115958. * @param r defines the red component
  115959. * @param g defines the green component
  115960. * @param b defines the blue component
  115961. * @param a defines the alpha component
  115962. */
  115963. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  115964. /**
  115965. * Sets the current alpha mode
  115966. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  115967. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  115968. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115969. */
  115970. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  115971. /**
  115972. * Gets the current alpha mode
  115973. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115974. * @returns the current alpha mode
  115975. */
  115976. getAlphaMode(): number;
  115977. /**
  115978. * Sets the current alpha equation
  115979. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  115980. */
  115981. setAlphaEquation(equation: number): void;
  115982. /**
  115983. * Gets the current alpha equation.
  115984. * @returns the current alpha equation
  115985. */
  115986. getAlphaEquation(): number;
  115987. }
  115988. }
  115989. declare module BABYLON {
  115990. interface ThinEngine {
  115991. /** @hidden */
  115992. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  115993. }
  115994. }
  115995. declare module BABYLON {
  115996. /**
  115997. * Defines the interface used by display changed events
  115998. */
  115999. export interface IDisplayChangedEventArgs {
  116000. /** Gets the vrDisplay object (if any) */
  116001. vrDisplay: Nullable<any>;
  116002. /** Gets a boolean indicating if webVR is supported */
  116003. vrSupported: boolean;
  116004. }
  116005. /**
  116006. * Defines the interface used by objects containing a viewport (like a camera)
  116007. */
  116008. interface IViewportOwnerLike {
  116009. /**
  116010. * Gets or sets the viewport
  116011. */
  116012. viewport: IViewportLike;
  116013. }
  116014. /**
  116015. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  116016. */
  116017. export class Engine extends ThinEngine {
  116018. /** Defines that alpha blending is disabled */
  116019. static readonly ALPHA_DISABLE: number;
  116020. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  116021. static readonly ALPHA_ADD: number;
  116022. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  116023. static readonly ALPHA_COMBINE: number;
  116024. /** Defines that alpha blending to DEST - SRC * DEST */
  116025. static readonly ALPHA_SUBTRACT: number;
  116026. /** Defines that alpha blending to SRC * DEST */
  116027. static readonly ALPHA_MULTIPLY: number;
  116028. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  116029. static readonly ALPHA_MAXIMIZED: number;
  116030. /** Defines that alpha blending to SRC + DEST */
  116031. static readonly ALPHA_ONEONE: number;
  116032. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  116033. static readonly ALPHA_PREMULTIPLIED: number;
  116034. /**
  116035. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  116036. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  116037. */
  116038. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  116039. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  116040. static readonly ALPHA_INTERPOLATE: number;
  116041. /**
  116042. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  116043. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  116044. */
  116045. static readonly ALPHA_SCREENMODE: number;
  116046. /** Defines that the ressource is not delayed*/
  116047. static readonly DELAYLOADSTATE_NONE: number;
  116048. /** Defines that the ressource was successfully delay loaded */
  116049. static readonly DELAYLOADSTATE_LOADED: number;
  116050. /** Defines that the ressource is currently delay loading */
  116051. static readonly DELAYLOADSTATE_LOADING: number;
  116052. /** Defines that the ressource is delayed and has not started loading */
  116053. static readonly DELAYLOADSTATE_NOTLOADED: number;
  116054. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  116055. static readonly NEVER: number;
  116056. /** 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 */
  116057. static readonly ALWAYS: number;
  116058. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  116059. static readonly LESS: number;
  116060. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  116061. static readonly EQUAL: number;
  116062. /** 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 */
  116063. static readonly LEQUAL: number;
  116064. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  116065. static readonly GREATER: number;
  116066. /** 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 */
  116067. static readonly GEQUAL: number;
  116068. /** 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 */
  116069. static readonly NOTEQUAL: number;
  116070. /** Passed to stencilOperation to specify that stencil value must be kept */
  116071. static readonly KEEP: number;
  116072. /** Passed to stencilOperation to specify that stencil value must be replaced */
  116073. static readonly REPLACE: number;
  116074. /** Passed to stencilOperation to specify that stencil value must be incremented */
  116075. static readonly INCR: number;
  116076. /** Passed to stencilOperation to specify that stencil value must be decremented */
  116077. static readonly DECR: number;
  116078. /** Passed to stencilOperation to specify that stencil value must be inverted */
  116079. static readonly INVERT: number;
  116080. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  116081. static readonly INCR_WRAP: number;
  116082. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  116083. static readonly DECR_WRAP: number;
  116084. /** Texture is not repeating outside of 0..1 UVs */
  116085. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  116086. /** Texture is repeating outside of 0..1 UVs */
  116087. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  116088. /** Texture is repeating and mirrored */
  116089. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  116090. /** ALPHA */
  116091. static readonly TEXTUREFORMAT_ALPHA: number;
  116092. /** LUMINANCE */
  116093. static readonly TEXTUREFORMAT_LUMINANCE: number;
  116094. /** LUMINANCE_ALPHA */
  116095. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  116096. /** RGB */
  116097. static readonly TEXTUREFORMAT_RGB: number;
  116098. /** RGBA */
  116099. static readonly TEXTUREFORMAT_RGBA: number;
  116100. /** RED */
  116101. static readonly TEXTUREFORMAT_RED: number;
  116102. /** RED (2nd reference) */
  116103. static readonly TEXTUREFORMAT_R: number;
  116104. /** RG */
  116105. static readonly TEXTUREFORMAT_RG: number;
  116106. /** RED_INTEGER */
  116107. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  116108. /** RED_INTEGER (2nd reference) */
  116109. static readonly TEXTUREFORMAT_R_INTEGER: number;
  116110. /** RG_INTEGER */
  116111. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  116112. /** RGB_INTEGER */
  116113. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  116114. /** RGBA_INTEGER */
  116115. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  116116. /** UNSIGNED_BYTE */
  116117. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  116118. /** UNSIGNED_BYTE (2nd reference) */
  116119. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  116120. /** FLOAT */
  116121. static readonly TEXTURETYPE_FLOAT: number;
  116122. /** HALF_FLOAT */
  116123. static readonly TEXTURETYPE_HALF_FLOAT: number;
  116124. /** BYTE */
  116125. static readonly TEXTURETYPE_BYTE: number;
  116126. /** SHORT */
  116127. static readonly TEXTURETYPE_SHORT: number;
  116128. /** UNSIGNED_SHORT */
  116129. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  116130. /** INT */
  116131. static readonly TEXTURETYPE_INT: number;
  116132. /** UNSIGNED_INT */
  116133. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  116134. /** UNSIGNED_SHORT_4_4_4_4 */
  116135. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  116136. /** UNSIGNED_SHORT_5_5_5_1 */
  116137. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  116138. /** UNSIGNED_SHORT_5_6_5 */
  116139. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  116140. /** UNSIGNED_INT_2_10_10_10_REV */
  116141. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  116142. /** UNSIGNED_INT_24_8 */
  116143. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  116144. /** UNSIGNED_INT_10F_11F_11F_REV */
  116145. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  116146. /** UNSIGNED_INT_5_9_9_9_REV */
  116147. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  116148. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  116149. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116150. /** nearest is mag = nearest and min = nearest and mip = linear */
  116151. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  116152. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116153. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  116154. /** Trilinear is mag = linear and min = linear and mip = linear */
  116155. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  116156. /** nearest is mag = nearest and min = nearest and mip = linear */
  116157. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  116158. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116159. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  116160. /** Trilinear is mag = linear and min = linear and mip = linear */
  116161. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  116162. /** mag = nearest and min = nearest and mip = nearest */
  116163. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  116164. /** mag = nearest and min = linear and mip = nearest */
  116165. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  116166. /** mag = nearest and min = linear and mip = linear */
  116167. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  116168. /** mag = nearest and min = linear and mip = none */
  116169. static readonly TEXTURE_NEAREST_LINEAR: number;
  116170. /** mag = nearest and min = nearest and mip = none */
  116171. static readonly TEXTURE_NEAREST_NEAREST: number;
  116172. /** mag = linear and min = nearest and mip = nearest */
  116173. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  116174. /** mag = linear and min = nearest and mip = linear */
  116175. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  116176. /** mag = linear and min = linear and mip = none */
  116177. static readonly TEXTURE_LINEAR_LINEAR: number;
  116178. /** mag = linear and min = nearest and mip = none */
  116179. static readonly TEXTURE_LINEAR_NEAREST: number;
  116180. /** Explicit coordinates mode */
  116181. static readonly TEXTURE_EXPLICIT_MODE: number;
  116182. /** Spherical coordinates mode */
  116183. static readonly TEXTURE_SPHERICAL_MODE: number;
  116184. /** Planar coordinates mode */
  116185. static readonly TEXTURE_PLANAR_MODE: number;
  116186. /** Cubic coordinates mode */
  116187. static readonly TEXTURE_CUBIC_MODE: number;
  116188. /** Projection coordinates mode */
  116189. static readonly TEXTURE_PROJECTION_MODE: number;
  116190. /** Skybox coordinates mode */
  116191. static readonly TEXTURE_SKYBOX_MODE: number;
  116192. /** Inverse Cubic coordinates mode */
  116193. static readonly TEXTURE_INVCUBIC_MODE: number;
  116194. /** Equirectangular coordinates mode */
  116195. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  116196. /** Equirectangular Fixed coordinates mode */
  116197. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  116198. /** Equirectangular Fixed Mirrored coordinates mode */
  116199. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  116200. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  116201. static readonly SCALEMODE_FLOOR: number;
  116202. /** Defines that texture rescaling will look for the nearest power of 2 size */
  116203. static readonly SCALEMODE_NEAREST: number;
  116204. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  116205. static readonly SCALEMODE_CEILING: number;
  116206. /**
  116207. * Returns the current npm package of the sdk
  116208. */
  116209. static get NpmPackage(): string;
  116210. /**
  116211. * Returns the current version of the framework
  116212. */
  116213. static get Version(): string;
  116214. /** Gets the list of created engines */
  116215. static get Instances(): Engine[];
  116216. /**
  116217. * Gets the latest created engine
  116218. */
  116219. static get LastCreatedEngine(): Nullable<Engine>;
  116220. /**
  116221. * Gets the latest created scene
  116222. */
  116223. static get LastCreatedScene(): Nullable<Scene>;
  116224. /**
  116225. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  116226. * @param flag defines which part of the materials must be marked as dirty
  116227. * @param predicate defines a predicate used to filter which materials should be affected
  116228. */
  116229. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116230. /**
  116231. * Method called to create the default loading screen.
  116232. * This can be overriden in your own app.
  116233. * @param canvas The rendering canvas element
  116234. * @returns The loading screen
  116235. */
  116236. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  116237. /**
  116238. * Method called to create the default rescale post process on each engine.
  116239. */
  116240. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  116241. /**
  116242. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  116243. **/
  116244. enableOfflineSupport: boolean;
  116245. /**
  116246. * 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)
  116247. **/
  116248. disableManifestCheck: boolean;
  116249. /**
  116250. * Gets the list of created scenes
  116251. */
  116252. scenes: Scene[];
  116253. /**
  116254. * Event raised when a new scene is created
  116255. */
  116256. onNewSceneAddedObservable: Observable<Scene>;
  116257. /**
  116258. * Gets the list of created postprocesses
  116259. */
  116260. postProcesses: PostProcess[];
  116261. /**
  116262. * Gets a boolean indicating if the pointer is currently locked
  116263. */
  116264. isPointerLock: boolean;
  116265. /**
  116266. * Observable event triggered each time the rendering canvas is resized
  116267. */
  116268. onResizeObservable: Observable<Engine>;
  116269. /**
  116270. * Observable event triggered each time the canvas loses focus
  116271. */
  116272. onCanvasBlurObservable: Observable<Engine>;
  116273. /**
  116274. * Observable event triggered each time the canvas gains focus
  116275. */
  116276. onCanvasFocusObservable: Observable<Engine>;
  116277. /**
  116278. * Observable event triggered each time the canvas receives pointerout event
  116279. */
  116280. onCanvasPointerOutObservable: Observable<PointerEvent>;
  116281. /**
  116282. * Observable raised when the engine begins a new frame
  116283. */
  116284. onBeginFrameObservable: Observable<Engine>;
  116285. /**
  116286. * If set, will be used to request the next animation frame for the render loop
  116287. */
  116288. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  116289. /**
  116290. * Observable raised when the engine ends the current frame
  116291. */
  116292. onEndFrameObservable: Observable<Engine>;
  116293. /**
  116294. * Observable raised when the engine is about to compile a shader
  116295. */
  116296. onBeforeShaderCompilationObservable: Observable<Engine>;
  116297. /**
  116298. * Observable raised when the engine has jsut compiled a shader
  116299. */
  116300. onAfterShaderCompilationObservable: Observable<Engine>;
  116301. /**
  116302. * Gets the audio engine
  116303. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116304. * @ignorenaming
  116305. */
  116306. static audioEngine: IAudioEngine;
  116307. /**
  116308. * Default AudioEngine factory responsible of creating the Audio Engine.
  116309. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  116310. */
  116311. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  116312. /**
  116313. * Default offline support factory responsible of creating a tool used to store data locally.
  116314. * By default, this will create a Database object if the workload has been embedded.
  116315. */
  116316. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  116317. private _loadingScreen;
  116318. private _pointerLockRequested;
  116319. private _rescalePostProcess;
  116320. private _deterministicLockstep;
  116321. private _lockstepMaxSteps;
  116322. private _timeStep;
  116323. protected get _supportsHardwareTextureRescaling(): boolean;
  116324. private _fps;
  116325. private _deltaTime;
  116326. /** @hidden */
  116327. _drawCalls: PerfCounter;
  116328. /** 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 */
  116329. canvasTabIndex: number;
  116330. /**
  116331. * Turn this value on if you want to pause FPS computation when in background
  116332. */
  116333. disablePerformanceMonitorInBackground: boolean;
  116334. private _performanceMonitor;
  116335. /**
  116336. * Gets the performance monitor attached to this engine
  116337. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116338. */
  116339. get performanceMonitor(): PerformanceMonitor;
  116340. private _onFocus;
  116341. private _onBlur;
  116342. private _onCanvasPointerOut;
  116343. private _onCanvasBlur;
  116344. private _onCanvasFocus;
  116345. private _onFullscreenChange;
  116346. private _onPointerLockChange;
  116347. /**
  116348. * Gets the HTML element used to attach event listeners
  116349. * @returns a HTML element
  116350. */
  116351. getInputElement(): Nullable<HTMLElement>;
  116352. /**
  116353. * Creates a new engine
  116354. * @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
  116355. * @param antialias defines enable antialiasing (default: false)
  116356. * @param options defines further options to be sent to the getContext() function
  116357. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116358. */
  116359. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116360. /**
  116361. * Gets current aspect ratio
  116362. * @param viewportOwner defines the camera to use to get the aspect ratio
  116363. * @param useScreen defines if screen size must be used (or the current render target if any)
  116364. * @returns a number defining the aspect ratio
  116365. */
  116366. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  116367. /**
  116368. * Gets current screen aspect ratio
  116369. * @returns a number defining the aspect ratio
  116370. */
  116371. getScreenAspectRatio(): number;
  116372. /**
  116373. * Gets the client rect of the HTML canvas attached with the current webGL context
  116374. * @returns a client rectanglee
  116375. */
  116376. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116377. /**
  116378. * Gets the client rect of the HTML element used for events
  116379. * @returns a client rectanglee
  116380. */
  116381. getInputElementClientRect(): Nullable<ClientRect>;
  116382. /**
  116383. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116384. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116385. * @returns true if engine is in deterministic lock step mode
  116386. */
  116387. isDeterministicLockStep(): boolean;
  116388. /**
  116389. * Gets the max steps when engine is running in deterministic lock step
  116390. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116391. * @returns the max steps
  116392. */
  116393. getLockstepMaxSteps(): number;
  116394. /**
  116395. * Returns the time in ms between steps when using deterministic lock step.
  116396. * @returns time step in (ms)
  116397. */
  116398. getTimeStep(): number;
  116399. /**
  116400. * Force the mipmap generation for the given render target texture
  116401. * @param texture defines the render target texture to use
  116402. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116403. */
  116404. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116405. /** States */
  116406. /**
  116407. * Set various states to the webGL context
  116408. * @param culling defines backface culling state
  116409. * @param zOffset defines the value to apply to zOffset (0 by default)
  116410. * @param force defines if states must be applied even if cache is up to date
  116411. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116412. */
  116413. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116414. /**
  116415. * Set the z offset to apply to current rendering
  116416. * @param value defines the offset to apply
  116417. */
  116418. setZOffset(value: number): void;
  116419. /**
  116420. * Gets the current value of the zOffset
  116421. * @returns the current zOffset state
  116422. */
  116423. getZOffset(): number;
  116424. /**
  116425. * Enable or disable depth buffering
  116426. * @param enable defines the state to set
  116427. */
  116428. setDepthBuffer(enable: boolean): void;
  116429. /**
  116430. * Gets a boolean indicating if depth writing is enabled
  116431. * @returns the current depth writing state
  116432. */
  116433. getDepthWrite(): boolean;
  116434. /**
  116435. * Enable or disable depth writing
  116436. * @param enable defines the state to set
  116437. */
  116438. setDepthWrite(enable: boolean): void;
  116439. /**
  116440. * Gets a boolean indicating if stencil buffer is enabled
  116441. * @returns the current stencil buffer state
  116442. */
  116443. getStencilBuffer(): boolean;
  116444. /**
  116445. * Enable or disable the stencil buffer
  116446. * @param enable defines if the stencil buffer must be enabled or disabled
  116447. */
  116448. setStencilBuffer(enable: boolean): void;
  116449. /**
  116450. * Gets the current stencil mask
  116451. * @returns a number defining the new stencil mask to use
  116452. */
  116453. getStencilMask(): number;
  116454. /**
  116455. * Sets the current stencil mask
  116456. * @param mask defines the new stencil mask to use
  116457. */
  116458. setStencilMask(mask: number): void;
  116459. /**
  116460. * Gets the current stencil function
  116461. * @returns a number defining the stencil function to use
  116462. */
  116463. getStencilFunction(): number;
  116464. /**
  116465. * Gets the current stencil reference value
  116466. * @returns a number defining the stencil reference value to use
  116467. */
  116468. getStencilFunctionReference(): number;
  116469. /**
  116470. * Gets the current stencil mask
  116471. * @returns a number defining the stencil mask to use
  116472. */
  116473. getStencilFunctionMask(): number;
  116474. /**
  116475. * Sets the current stencil function
  116476. * @param stencilFunc defines the new stencil function to use
  116477. */
  116478. setStencilFunction(stencilFunc: number): void;
  116479. /**
  116480. * Sets the current stencil reference
  116481. * @param reference defines the new stencil reference to use
  116482. */
  116483. setStencilFunctionReference(reference: number): void;
  116484. /**
  116485. * Sets the current stencil mask
  116486. * @param mask defines the new stencil mask to use
  116487. */
  116488. setStencilFunctionMask(mask: number): void;
  116489. /**
  116490. * Gets the current stencil operation when stencil fails
  116491. * @returns a number defining stencil operation to use when stencil fails
  116492. */
  116493. getStencilOperationFail(): number;
  116494. /**
  116495. * Gets the current stencil operation when depth fails
  116496. * @returns a number defining stencil operation to use when depth fails
  116497. */
  116498. getStencilOperationDepthFail(): number;
  116499. /**
  116500. * Gets the current stencil operation when stencil passes
  116501. * @returns a number defining stencil operation to use when stencil passes
  116502. */
  116503. getStencilOperationPass(): number;
  116504. /**
  116505. * Sets the stencil operation to use when stencil fails
  116506. * @param operation defines the stencil operation to use when stencil fails
  116507. */
  116508. setStencilOperationFail(operation: number): void;
  116509. /**
  116510. * Sets the stencil operation to use when depth fails
  116511. * @param operation defines the stencil operation to use when depth fails
  116512. */
  116513. setStencilOperationDepthFail(operation: number): void;
  116514. /**
  116515. * Sets the stencil operation to use when stencil passes
  116516. * @param operation defines the stencil operation to use when stencil passes
  116517. */
  116518. setStencilOperationPass(operation: number): void;
  116519. /**
  116520. * Sets a boolean indicating if the dithering state is enabled or disabled
  116521. * @param value defines the dithering state
  116522. */
  116523. setDitheringState(value: boolean): void;
  116524. /**
  116525. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  116526. * @param value defines the rasterizer state
  116527. */
  116528. setRasterizerState(value: boolean): void;
  116529. /**
  116530. * Gets the current depth function
  116531. * @returns a number defining the depth function
  116532. */
  116533. getDepthFunction(): Nullable<number>;
  116534. /**
  116535. * Sets the current depth function
  116536. * @param depthFunc defines the function to use
  116537. */
  116538. setDepthFunction(depthFunc: number): void;
  116539. /**
  116540. * Sets the current depth function to GREATER
  116541. */
  116542. setDepthFunctionToGreater(): void;
  116543. /**
  116544. * Sets the current depth function to GEQUAL
  116545. */
  116546. setDepthFunctionToGreaterOrEqual(): void;
  116547. /**
  116548. * Sets the current depth function to LESS
  116549. */
  116550. setDepthFunctionToLess(): void;
  116551. /**
  116552. * Sets the current depth function to LEQUAL
  116553. */
  116554. setDepthFunctionToLessOrEqual(): void;
  116555. private _cachedStencilBuffer;
  116556. private _cachedStencilFunction;
  116557. private _cachedStencilMask;
  116558. private _cachedStencilOperationPass;
  116559. private _cachedStencilOperationFail;
  116560. private _cachedStencilOperationDepthFail;
  116561. private _cachedStencilReference;
  116562. /**
  116563. * Caches the the state of the stencil buffer
  116564. */
  116565. cacheStencilState(): void;
  116566. /**
  116567. * Restores the state of the stencil buffer
  116568. */
  116569. restoreStencilState(): void;
  116570. /**
  116571. * Directly set the WebGL Viewport
  116572. * @param x defines the x coordinate of the viewport (in screen space)
  116573. * @param y defines the y coordinate of the viewport (in screen space)
  116574. * @param width defines the width of the viewport (in screen space)
  116575. * @param height defines the height of the viewport (in screen space)
  116576. * @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
  116577. */
  116578. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  116579. /**
  116580. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  116581. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116582. * @param y defines the y-coordinate of the corner of the clear rectangle
  116583. * @param width defines the width of the clear rectangle
  116584. * @param height defines the height of the clear rectangle
  116585. * @param clearColor defines the clear color
  116586. */
  116587. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  116588. /**
  116589. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  116590. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116591. * @param y defines the y-coordinate of the corner of the clear rectangle
  116592. * @param width defines the width of the clear rectangle
  116593. * @param height defines the height of the clear rectangle
  116594. */
  116595. enableScissor(x: number, y: number, width: number, height: number): void;
  116596. /**
  116597. * Disable previously set scissor test rectangle
  116598. */
  116599. disableScissor(): void;
  116600. protected _reportDrawCall(): void;
  116601. /**
  116602. * Initializes a webVR display and starts listening to display change events
  116603. * The onVRDisplayChangedObservable will be notified upon these changes
  116604. * @returns The onVRDisplayChangedObservable
  116605. */
  116606. initWebVR(): Observable<IDisplayChangedEventArgs>;
  116607. /** @hidden */
  116608. _prepareVRComponent(): void;
  116609. /** @hidden */
  116610. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  116611. /** @hidden */
  116612. _submitVRFrame(): void;
  116613. /**
  116614. * Call this function to leave webVR mode
  116615. * Will do nothing if webVR is not supported or if there is no webVR device
  116616. * @see https://doc.babylonjs.com/how_to/webvr_camera
  116617. */
  116618. disableVR(): void;
  116619. /**
  116620. * Gets a boolean indicating that the system is in VR mode and is presenting
  116621. * @returns true if VR mode is engaged
  116622. */
  116623. isVRPresenting(): boolean;
  116624. /** @hidden */
  116625. _requestVRFrame(): void;
  116626. /** @hidden */
  116627. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116628. /**
  116629. * Gets the source code of the vertex shader associated with a specific webGL program
  116630. * @param program defines the program to use
  116631. * @returns a string containing the source code of the vertex shader associated with the program
  116632. */
  116633. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  116634. /**
  116635. * Gets the source code of the fragment shader associated with a specific webGL program
  116636. * @param program defines the program to use
  116637. * @returns a string containing the source code of the fragment shader associated with the program
  116638. */
  116639. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  116640. /**
  116641. * Sets a depth stencil texture from a render target to the according uniform.
  116642. * @param channel The texture channel
  116643. * @param uniform The uniform to set
  116644. * @param texture The render target texture containing the depth stencil texture to apply
  116645. */
  116646. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  116647. /**
  116648. * Sets a texture to the webGL context from a postprocess
  116649. * @param channel defines the channel to use
  116650. * @param postProcess defines the source postprocess
  116651. */
  116652. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  116653. /**
  116654. * Binds the output of the passed in post process to the texture channel specified
  116655. * @param channel The channel the texture should be bound to
  116656. * @param postProcess The post process which's output should be bound
  116657. */
  116658. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  116659. protected _rebuildBuffers(): void;
  116660. /** @hidden */
  116661. _renderFrame(): void;
  116662. _renderLoop(): void;
  116663. /** @hidden */
  116664. _renderViews(): boolean;
  116665. /**
  116666. * Toggle full screen mode
  116667. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116668. */
  116669. switchFullscreen(requestPointerLock: boolean): void;
  116670. /**
  116671. * Enters full screen mode
  116672. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116673. */
  116674. enterFullscreen(requestPointerLock: boolean): void;
  116675. /**
  116676. * Exits full screen mode
  116677. */
  116678. exitFullscreen(): void;
  116679. /**
  116680. * Enters Pointerlock mode
  116681. */
  116682. enterPointerlock(): void;
  116683. /**
  116684. * Exits Pointerlock mode
  116685. */
  116686. exitPointerlock(): void;
  116687. /**
  116688. * Begin a new frame
  116689. */
  116690. beginFrame(): void;
  116691. /**
  116692. * Enf the current frame
  116693. */
  116694. endFrame(): void;
  116695. resize(): void;
  116696. /**
  116697. * Force a specific size of the canvas
  116698. * @param width defines the new canvas' width
  116699. * @param height defines the new canvas' height
  116700. * @returns true if the size was changed
  116701. */
  116702. setSize(width: number, height: number): boolean;
  116703. /**
  116704. * Updates a dynamic vertex buffer.
  116705. * @param vertexBuffer the vertex buffer to update
  116706. * @param data the data used to update the vertex buffer
  116707. * @param byteOffset the byte offset of the data
  116708. * @param byteLength the byte length of the data
  116709. */
  116710. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  116711. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116712. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116713. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116714. _releaseTexture(texture: InternalTexture): void;
  116715. /**
  116716. * @hidden
  116717. * Rescales a texture
  116718. * @param source input texutre
  116719. * @param destination destination texture
  116720. * @param scene scene to use to render the resize
  116721. * @param internalFormat format to use when resizing
  116722. * @param onComplete callback to be called when resize has completed
  116723. */
  116724. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116725. /**
  116726. * Gets the current framerate
  116727. * @returns a number representing the framerate
  116728. */
  116729. getFps(): number;
  116730. /**
  116731. * Gets the time spent between current and previous frame
  116732. * @returns a number representing the delta time in ms
  116733. */
  116734. getDeltaTime(): number;
  116735. private _measureFps;
  116736. /** @hidden */
  116737. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  116738. /**
  116739. * Update a dynamic index buffer
  116740. * @param indexBuffer defines the target index buffer
  116741. * @param indices defines the data to update
  116742. * @param offset defines the offset in the target index buffer where update should start
  116743. */
  116744. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  116745. /**
  116746. * Updates the sample count of a render target texture
  116747. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  116748. * @param texture defines the texture to update
  116749. * @param samples defines the sample count to set
  116750. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  116751. */
  116752. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  116753. /**
  116754. * Updates a depth texture Comparison Mode and Function.
  116755. * If the comparison Function is equal to 0, the mode will be set to none.
  116756. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  116757. * @param texture The texture to set the comparison function for
  116758. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  116759. */
  116760. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  116761. /**
  116762. * Creates a webGL buffer to use with instanciation
  116763. * @param capacity defines the size of the buffer
  116764. * @returns the webGL buffer
  116765. */
  116766. createInstancesBuffer(capacity: number): DataBuffer;
  116767. /**
  116768. * Delete a webGL buffer used with instanciation
  116769. * @param buffer defines the webGL buffer to delete
  116770. */
  116771. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  116772. private _clientWaitAsync;
  116773. /** @hidden */
  116774. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  116775. dispose(): void;
  116776. private _disableTouchAction;
  116777. /**
  116778. * Display the loading screen
  116779. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116780. */
  116781. displayLoadingUI(): void;
  116782. /**
  116783. * Hide the loading screen
  116784. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116785. */
  116786. hideLoadingUI(): void;
  116787. /**
  116788. * Gets the current loading screen object
  116789. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116790. */
  116791. get loadingScreen(): ILoadingScreen;
  116792. /**
  116793. * Sets the current loading screen object
  116794. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116795. */
  116796. set loadingScreen(loadingScreen: ILoadingScreen);
  116797. /**
  116798. * Sets the current loading screen text
  116799. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116800. */
  116801. set loadingUIText(text: string);
  116802. /**
  116803. * Sets the current loading screen background color
  116804. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116805. */
  116806. set loadingUIBackgroundColor(color: string);
  116807. /** Pointerlock and fullscreen */
  116808. /**
  116809. * Ask the browser to promote the current element to pointerlock mode
  116810. * @param element defines the DOM element to promote
  116811. */
  116812. static _RequestPointerlock(element: HTMLElement): void;
  116813. /**
  116814. * Asks the browser to exit pointerlock mode
  116815. */
  116816. static _ExitPointerlock(): void;
  116817. /**
  116818. * Ask the browser to promote the current element to fullscreen rendering mode
  116819. * @param element defines the DOM element to promote
  116820. */
  116821. static _RequestFullscreen(element: HTMLElement): void;
  116822. /**
  116823. * Asks the browser to exit fullscreen mode
  116824. */
  116825. static _ExitFullscreen(): void;
  116826. }
  116827. }
  116828. declare module BABYLON {
  116829. /**
  116830. * The engine store class is responsible to hold all the instances of Engine and Scene created
  116831. * during the life time of the application.
  116832. */
  116833. export class EngineStore {
  116834. /** Gets the list of created engines */
  116835. static Instances: Engine[];
  116836. /** @hidden */
  116837. static _LastCreatedScene: Nullable<Scene>;
  116838. /**
  116839. * Gets the latest created engine
  116840. */
  116841. static get LastCreatedEngine(): Nullable<Engine>;
  116842. /**
  116843. * Gets the latest created scene
  116844. */
  116845. static get LastCreatedScene(): Nullable<Scene>;
  116846. /**
  116847. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116848. * @ignorenaming
  116849. */
  116850. static UseFallbackTexture: boolean;
  116851. /**
  116852. * Texture content used if a texture cannot loaded
  116853. * @ignorenaming
  116854. */
  116855. static FallbackTexture: string;
  116856. }
  116857. }
  116858. declare module BABYLON {
  116859. /**
  116860. * Helper class that provides a small promise polyfill
  116861. */
  116862. export class PromisePolyfill {
  116863. /**
  116864. * Static function used to check if the polyfill is required
  116865. * If this is the case then the function will inject the polyfill to window.Promise
  116866. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  116867. */
  116868. static Apply(force?: boolean): void;
  116869. }
  116870. }
  116871. declare module BABYLON {
  116872. /**
  116873. * Interface for screenshot methods with describe argument called `size` as object with options
  116874. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  116875. */
  116876. export interface IScreenshotSize {
  116877. /**
  116878. * number in pixels for canvas height
  116879. */
  116880. height?: number;
  116881. /**
  116882. * multiplier allowing render at a higher or lower resolution
  116883. * If value is defined then height and width will be ignored and taken from camera
  116884. */
  116885. precision?: number;
  116886. /**
  116887. * number in pixels for canvas width
  116888. */
  116889. width?: number;
  116890. }
  116891. }
  116892. declare module BABYLON {
  116893. interface IColor4Like {
  116894. r: float;
  116895. g: float;
  116896. b: float;
  116897. a: float;
  116898. }
  116899. /**
  116900. * Class containing a set of static utilities functions
  116901. */
  116902. export class Tools {
  116903. /**
  116904. * Gets or sets the base URL to use to load assets
  116905. */
  116906. static get BaseUrl(): string;
  116907. static set BaseUrl(value: string);
  116908. /**
  116909. * Enable/Disable Custom HTTP Request Headers globally.
  116910. * default = false
  116911. * @see CustomRequestHeaders
  116912. */
  116913. static UseCustomRequestHeaders: boolean;
  116914. /**
  116915. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  116916. * i.e. when loading files, where the server/service expects an Authorization header
  116917. */
  116918. static CustomRequestHeaders: {
  116919. [key: string]: string;
  116920. };
  116921. /**
  116922. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  116923. */
  116924. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  116925. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  116926. /**
  116927. * Default behaviour for cors in the application.
  116928. * It can be a string if the expected behavior is identical in the entire app.
  116929. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  116930. */
  116931. static get CorsBehavior(): string | ((url: string | string[]) => string);
  116932. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  116933. /**
  116934. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116935. * @ignorenaming
  116936. */
  116937. static get UseFallbackTexture(): boolean;
  116938. static set UseFallbackTexture(value: boolean);
  116939. /**
  116940. * Use this object to register external classes like custom textures or material
  116941. * to allow the laoders to instantiate them
  116942. */
  116943. static get RegisteredExternalClasses(): {
  116944. [key: string]: Object;
  116945. };
  116946. static set RegisteredExternalClasses(classes: {
  116947. [key: string]: Object;
  116948. });
  116949. /**
  116950. * Texture content used if a texture cannot loaded
  116951. * @ignorenaming
  116952. */
  116953. static get fallbackTexture(): string;
  116954. static set fallbackTexture(value: string);
  116955. /**
  116956. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  116957. * @param u defines the coordinate on X axis
  116958. * @param v defines the coordinate on Y axis
  116959. * @param width defines the width of the source data
  116960. * @param height defines the height of the source data
  116961. * @param pixels defines the source byte array
  116962. * @param color defines the output color
  116963. */
  116964. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  116965. /**
  116966. * Interpolates between a and b via alpha
  116967. * @param a The lower value (returned when alpha = 0)
  116968. * @param b The upper value (returned when alpha = 1)
  116969. * @param alpha The interpolation-factor
  116970. * @return The mixed value
  116971. */
  116972. static Mix(a: number, b: number, alpha: number): number;
  116973. /**
  116974. * Tries to instantiate a new object from a given class name
  116975. * @param className defines the class name to instantiate
  116976. * @returns the new object or null if the system was not able to do the instantiation
  116977. */
  116978. static Instantiate(className: string): any;
  116979. /**
  116980. * Provides a slice function that will work even on IE
  116981. * @param data defines the array to slice
  116982. * @param start defines the start of the data (optional)
  116983. * @param end defines the end of the data (optional)
  116984. * @returns the new sliced array
  116985. */
  116986. static Slice<T>(data: T, start?: number, end?: number): T;
  116987. /**
  116988. * Polyfill for setImmediate
  116989. * @param action defines the action to execute after the current execution block
  116990. */
  116991. static SetImmediate(action: () => void): void;
  116992. /**
  116993. * Function indicating if a number is an exponent of 2
  116994. * @param value defines the value to test
  116995. * @returns true if the value is an exponent of 2
  116996. */
  116997. static IsExponentOfTwo(value: number): boolean;
  116998. private static _tmpFloatArray;
  116999. /**
  117000. * Returns the nearest 32-bit single precision float representation of a Number
  117001. * @param value A Number. If the parameter is of a different type, it will get converted
  117002. * to a number or to NaN if it cannot be converted
  117003. * @returns number
  117004. */
  117005. static FloatRound(value: number): number;
  117006. /**
  117007. * Extracts the filename from a path
  117008. * @param path defines the path to use
  117009. * @returns the filename
  117010. */
  117011. static GetFilename(path: string): string;
  117012. /**
  117013. * Extracts the "folder" part of a path (everything before the filename).
  117014. * @param uri The URI to extract the info from
  117015. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  117016. * @returns The "folder" part of the path
  117017. */
  117018. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  117019. /**
  117020. * Extracts text content from a DOM element hierarchy
  117021. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  117022. */
  117023. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  117024. /**
  117025. * Convert an angle in radians to degrees
  117026. * @param angle defines the angle to convert
  117027. * @returns the angle in degrees
  117028. */
  117029. static ToDegrees(angle: number): number;
  117030. /**
  117031. * Convert an angle in degrees to radians
  117032. * @param angle defines the angle to convert
  117033. * @returns the angle in radians
  117034. */
  117035. static ToRadians(angle: number): number;
  117036. /**
  117037. * Returns an array if obj is not an array
  117038. * @param obj defines the object to evaluate as an array
  117039. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117040. * @returns either obj directly if obj is an array or a new array containing obj
  117041. */
  117042. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  117043. /**
  117044. * Gets the pointer prefix to use
  117045. * @param engine defines the engine we are finding the prefix for
  117046. * @returns "pointer" if touch is enabled. Else returns "mouse"
  117047. */
  117048. static GetPointerPrefix(engine: Engine): string;
  117049. /**
  117050. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  117051. * @param url define the url we are trying
  117052. * @param element define the dom element where to configure the cors policy
  117053. */
  117054. static SetCorsBehavior(url: string | string[], element: {
  117055. crossOrigin: string | null;
  117056. }): void;
  117057. /**
  117058. * Removes unwanted characters from an url
  117059. * @param url defines the url to clean
  117060. * @returns the cleaned url
  117061. */
  117062. static CleanUrl(url: string): string;
  117063. /**
  117064. * Gets or sets a function used to pre-process url before using them to load assets
  117065. */
  117066. static get PreprocessUrl(): (url: string) => string;
  117067. static set PreprocessUrl(processor: (url: string) => string);
  117068. /**
  117069. * Loads an image as an HTMLImageElement.
  117070. * @param input url string, ArrayBuffer, or Blob to load
  117071. * @param onLoad callback called when the image successfully loads
  117072. * @param onError callback called when the image fails to load
  117073. * @param offlineProvider offline provider for caching
  117074. * @param mimeType optional mime type
  117075. * @returns the HTMLImageElement of the loaded image
  117076. */
  117077. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  117078. /**
  117079. * Loads a file from a url
  117080. * @param url url string, ArrayBuffer, or Blob to load
  117081. * @param onSuccess callback called when the file successfully loads
  117082. * @param onProgress callback called while file is loading (if the server supports this mode)
  117083. * @param offlineProvider defines the offline provider for caching
  117084. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117085. * @param onError callback called when the file fails to load
  117086. * @returns a file request object
  117087. */
  117088. 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;
  117089. /**
  117090. * Loads a file from a url
  117091. * @param url the file url to load
  117092. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117093. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  117094. */
  117095. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  117096. /**
  117097. * Load a script (identified by an url). When the url returns, the
  117098. * content of this file is added into a new script element, attached to the DOM (body element)
  117099. * @param scriptUrl defines the url of the script to laod
  117100. * @param onSuccess defines the callback called when the script is loaded
  117101. * @param onError defines the callback to call if an error occurs
  117102. * @param scriptId defines the id of the script element
  117103. */
  117104. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  117105. /**
  117106. * Load an asynchronous script (identified by an url). When the url returns, the
  117107. * content of this file is added into a new script element, attached to the DOM (body element)
  117108. * @param scriptUrl defines the url of the script to laod
  117109. * @param scriptId defines the id of the script element
  117110. * @returns a promise request object
  117111. */
  117112. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  117113. /**
  117114. * Loads a file from a blob
  117115. * @param fileToLoad defines the blob to use
  117116. * @param callback defines the callback to call when data is loaded
  117117. * @param progressCallback defines the callback to call during loading process
  117118. * @returns a file request object
  117119. */
  117120. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  117121. /**
  117122. * Reads a file from a File object
  117123. * @param file defines the file to load
  117124. * @param onSuccess defines the callback to call when data is loaded
  117125. * @param onProgress defines the callback to call during loading process
  117126. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117127. * @param onError defines the callback to call when an error occurs
  117128. * @returns a file request object
  117129. */
  117130. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117131. /**
  117132. * Creates a data url from a given string content
  117133. * @param content defines the content to convert
  117134. * @returns the new data url link
  117135. */
  117136. static FileAsURL(content: string): string;
  117137. /**
  117138. * Format the given number to a specific decimal format
  117139. * @param value defines the number to format
  117140. * @param decimals defines the number of decimals to use
  117141. * @returns the formatted string
  117142. */
  117143. static Format(value: number, decimals?: number): string;
  117144. /**
  117145. * Tries to copy an object by duplicating every property
  117146. * @param source defines the source object
  117147. * @param destination defines the target object
  117148. * @param doNotCopyList defines a list of properties to avoid
  117149. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  117150. */
  117151. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  117152. /**
  117153. * Gets a boolean indicating if the given object has no own property
  117154. * @param obj defines the object to test
  117155. * @returns true if object has no own property
  117156. */
  117157. static IsEmpty(obj: any): boolean;
  117158. /**
  117159. * Function used to register events at window level
  117160. * @param windowElement defines the Window object to use
  117161. * @param events defines the events to register
  117162. */
  117163. static RegisterTopRootEvents(windowElement: Window, events: {
  117164. name: string;
  117165. handler: Nullable<(e: FocusEvent) => any>;
  117166. }[]): void;
  117167. /**
  117168. * Function used to unregister events from window level
  117169. * @param windowElement defines the Window object to use
  117170. * @param events defines the events to unregister
  117171. */
  117172. static UnregisterTopRootEvents(windowElement: Window, events: {
  117173. name: string;
  117174. handler: Nullable<(e: FocusEvent) => any>;
  117175. }[]): void;
  117176. /**
  117177. * @ignore
  117178. */
  117179. static _ScreenshotCanvas: HTMLCanvasElement;
  117180. /**
  117181. * Dumps the current bound framebuffer
  117182. * @param width defines the rendering width
  117183. * @param height defines the rendering height
  117184. * @param engine defines the hosting engine
  117185. * @param successCallback defines the callback triggered once the data are available
  117186. * @param mimeType defines the mime type of the result
  117187. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  117188. */
  117189. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117190. /**
  117191. * Converts the canvas data to blob.
  117192. * This acts as a polyfill for browsers not supporting the to blob function.
  117193. * @param canvas Defines the canvas to extract the data from
  117194. * @param successCallback Defines the callback triggered once the data are available
  117195. * @param mimeType Defines the mime type of the result
  117196. */
  117197. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  117198. /**
  117199. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  117200. * @param successCallback defines the callback triggered once the data are available
  117201. * @param mimeType defines the mime type of the result
  117202. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  117203. */
  117204. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117205. /**
  117206. * Downloads a blob in the browser
  117207. * @param blob defines the blob to download
  117208. * @param fileName defines the name of the downloaded file
  117209. */
  117210. static Download(blob: Blob, fileName: string): void;
  117211. /**
  117212. * Captures a screenshot of the current rendering
  117213. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117214. * @param engine defines the rendering engine
  117215. * @param camera defines the source camera
  117216. * @param size This parameter can be set to a single number or to an object with the
  117217. * following (optional) properties: precision, width, height. If a single number is passed,
  117218. * it will be used for both width and height. If an object is passed, the screenshot size
  117219. * will be derived from the parameters. The precision property is a multiplier allowing
  117220. * rendering at a higher or lower resolution
  117221. * @param successCallback defines the callback receives a single parameter which contains the
  117222. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117223. * src parameter of an <img> to display it
  117224. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117225. * Check your browser for supported MIME types
  117226. */
  117227. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  117228. /**
  117229. * Captures a screenshot of the current rendering
  117230. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117231. * @param engine defines the rendering engine
  117232. * @param camera defines the source camera
  117233. * @param size This parameter can be set to a single number or to an object with the
  117234. * following (optional) properties: precision, width, height. If a single number is passed,
  117235. * it will be used for both width and height. If an object is passed, the screenshot size
  117236. * will be derived from the parameters. The precision property is a multiplier allowing
  117237. * rendering at a higher or lower resolution
  117238. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117239. * Check your browser for supported MIME types
  117240. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117241. * to the src parameter of an <img> to display it
  117242. */
  117243. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  117244. /**
  117245. * Generates an image screenshot from the specified camera.
  117246. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117247. * @param engine The engine to use for rendering
  117248. * @param camera The camera to use for rendering
  117249. * @param size This parameter can be set to a single number or to an object with the
  117250. * following (optional) properties: precision, width, height. If a single number is passed,
  117251. * it will be used for both width and height. If an object is passed, the screenshot size
  117252. * will be derived from the parameters. The precision property is a multiplier allowing
  117253. * rendering at a higher or lower resolution
  117254. * @param successCallback The callback receives a single parameter which contains the
  117255. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117256. * src parameter of an <img> to display it
  117257. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117258. * Check your browser for supported MIME types
  117259. * @param samples Texture samples (default: 1)
  117260. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117261. * @param fileName A name for for the downloaded file.
  117262. */
  117263. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  117264. /**
  117265. * Generates an image screenshot from the specified camera.
  117266. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117267. * @param engine The engine to use for rendering
  117268. * @param camera The camera to use for rendering
  117269. * @param size This parameter can be set to a single number or to an object with the
  117270. * following (optional) properties: precision, width, height. If a single number is passed,
  117271. * it will be used for both width and height. If an object is passed, the screenshot size
  117272. * will be derived from the parameters. The precision property is a multiplier allowing
  117273. * rendering at a higher or lower resolution
  117274. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117275. * Check your browser for supported MIME types
  117276. * @param samples Texture samples (default: 1)
  117277. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117278. * @param fileName A name for for the downloaded file.
  117279. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117280. * to the src parameter of an <img> to display it
  117281. */
  117282. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  117283. /**
  117284. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117285. * Be aware Math.random() could cause collisions, but:
  117286. * "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"
  117287. * @returns a pseudo random id
  117288. */
  117289. static RandomId(): string;
  117290. /**
  117291. * Test if the given uri is a base64 string
  117292. * @param uri The uri to test
  117293. * @return True if the uri is a base64 string or false otherwise
  117294. */
  117295. static IsBase64(uri: string): boolean;
  117296. /**
  117297. * Decode the given base64 uri.
  117298. * @param uri The uri to decode
  117299. * @return The decoded base64 data.
  117300. */
  117301. static DecodeBase64(uri: string): ArrayBuffer;
  117302. /**
  117303. * Gets the absolute url.
  117304. * @param url the input url
  117305. * @return the absolute url
  117306. */
  117307. static GetAbsoluteUrl(url: string): string;
  117308. /**
  117309. * No log
  117310. */
  117311. static readonly NoneLogLevel: number;
  117312. /**
  117313. * Only message logs
  117314. */
  117315. static readonly MessageLogLevel: number;
  117316. /**
  117317. * Only warning logs
  117318. */
  117319. static readonly WarningLogLevel: number;
  117320. /**
  117321. * Only error logs
  117322. */
  117323. static readonly ErrorLogLevel: number;
  117324. /**
  117325. * All logs
  117326. */
  117327. static readonly AllLogLevel: number;
  117328. /**
  117329. * Gets a value indicating the number of loading errors
  117330. * @ignorenaming
  117331. */
  117332. static get errorsCount(): number;
  117333. /**
  117334. * Callback called when a new log is added
  117335. */
  117336. static OnNewCacheEntry: (entry: string) => void;
  117337. /**
  117338. * Log a message to the console
  117339. * @param message defines the message to log
  117340. */
  117341. static Log(message: string): void;
  117342. /**
  117343. * Write a warning message to the console
  117344. * @param message defines the message to log
  117345. */
  117346. static Warn(message: string): void;
  117347. /**
  117348. * Write an error message to the console
  117349. * @param message defines the message to log
  117350. */
  117351. static Error(message: string): void;
  117352. /**
  117353. * Gets current log cache (list of logs)
  117354. */
  117355. static get LogCache(): string;
  117356. /**
  117357. * Clears the log cache
  117358. */
  117359. static ClearLogCache(): void;
  117360. /**
  117361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  117362. */
  117363. static set LogLevels(level: number);
  117364. /**
  117365. * Checks if the window object exists
  117366. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  117367. */
  117368. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  117369. /**
  117370. * No performance log
  117371. */
  117372. static readonly PerformanceNoneLogLevel: number;
  117373. /**
  117374. * Use user marks to log performance
  117375. */
  117376. static readonly PerformanceUserMarkLogLevel: number;
  117377. /**
  117378. * Log performance to the console
  117379. */
  117380. static readonly PerformanceConsoleLogLevel: number;
  117381. private static _performance;
  117382. /**
  117383. * Sets the current performance log level
  117384. */
  117385. static set PerformanceLogLevel(level: number);
  117386. private static _StartPerformanceCounterDisabled;
  117387. private static _EndPerformanceCounterDisabled;
  117388. private static _StartUserMark;
  117389. private static _EndUserMark;
  117390. private static _StartPerformanceConsole;
  117391. private static _EndPerformanceConsole;
  117392. /**
  117393. * Starts a performance counter
  117394. */
  117395. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117396. /**
  117397. * Ends a specific performance coutner
  117398. */
  117399. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117400. /**
  117401. * Gets either window.performance.now() if supported or Date.now() else
  117402. */
  117403. static get Now(): number;
  117404. /**
  117405. * This method will return the name of the class used to create the instance of the given object.
  117406. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117407. * @param object the object to get the class name from
  117408. * @param isType defines if the object is actually a type
  117409. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117410. */
  117411. static GetClassName(object: any, isType?: boolean): string;
  117412. /**
  117413. * Gets the first element of an array satisfying a given predicate
  117414. * @param array defines the array to browse
  117415. * @param predicate defines the predicate to use
  117416. * @returns null if not found or the element
  117417. */
  117418. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117419. /**
  117420. * This method will return the name of the full name of the class, including its owning module (if any).
  117421. * 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).
  117422. * @param object the object to get the class name from
  117423. * @param isType defines if the object is actually a type
  117424. * @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.
  117425. * @ignorenaming
  117426. */
  117427. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117428. /**
  117429. * Returns a promise that resolves after the given amount of time.
  117430. * @param delay Number of milliseconds to delay
  117431. * @returns Promise that resolves after the given amount of time
  117432. */
  117433. static DelayAsync(delay: number): Promise<void>;
  117434. /**
  117435. * Utility function to detect if the current user agent is Safari
  117436. * @returns whether or not the current user agent is safari
  117437. */
  117438. static IsSafari(): boolean;
  117439. }
  117440. /**
  117441. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117442. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117443. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117444. * @param name The name of the class, case should be preserved
  117445. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117446. */
  117447. export function className(name: string, module?: string): (target: Object) => void;
  117448. /**
  117449. * An implementation of a loop for asynchronous functions.
  117450. */
  117451. export class AsyncLoop {
  117452. /**
  117453. * Defines the number of iterations for the loop
  117454. */
  117455. iterations: number;
  117456. /**
  117457. * Defines the current index of the loop.
  117458. */
  117459. index: number;
  117460. private _done;
  117461. private _fn;
  117462. private _successCallback;
  117463. /**
  117464. * Constructor.
  117465. * @param iterations the number of iterations.
  117466. * @param func the function to run each iteration
  117467. * @param successCallback the callback that will be called upon succesful execution
  117468. * @param offset starting offset.
  117469. */
  117470. constructor(
  117471. /**
  117472. * Defines the number of iterations for the loop
  117473. */
  117474. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  117475. /**
  117476. * Execute the next iteration. Must be called after the last iteration was finished.
  117477. */
  117478. executeNext(): void;
  117479. /**
  117480. * Break the loop and run the success callback.
  117481. */
  117482. breakLoop(): void;
  117483. /**
  117484. * Create and run an async loop.
  117485. * @param iterations the number of iterations.
  117486. * @param fn the function to run each iteration
  117487. * @param successCallback the callback that will be called upon succesful execution
  117488. * @param offset starting offset.
  117489. * @returns the created async loop object
  117490. */
  117491. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  117492. /**
  117493. * A for-loop that will run a given number of iterations synchronous and the rest async.
  117494. * @param iterations total number of iterations
  117495. * @param syncedIterations number of synchronous iterations in each async iteration.
  117496. * @param fn the function to call each iteration.
  117497. * @param callback a success call back that will be called when iterating stops.
  117498. * @param breakFunction a break condition (optional)
  117499. * @param timeout timeout settings for the setTimeout function. default - 0.
  117500. * @returns the created async loop object
  117501. */
  117502. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  117503. }
  117504. }
  117505. declare module BABYLON {
  117506. /**
  117507. * This class implement a typical dictionary using a string as key and the generic type T as value.
  117508. * The underlying implementation relies on an associative array to ensure the best performances.
  117509. * The value can be anything including 'null' but except 'undefined'
  117510. */
  117511. export class StringDictionary<T> {
  117512. /**
  117513. * This will clear this dictionary and copy the content from the 'source' one.
  117514. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  117515. * @param source the dictionary to take the content from and copy to this dictionary
  117516. */
  117517. copyFrom(source: StringDictionary<T>): void;
  117518. /**
  117519. * Get a value based from its key
  117520. * @param key the given key to get the matching value from
  117521. * @return the value if found, otherwise undefined is returned
  117522. */
  117523. get(key: string): T | undefined;
  117524. /**
  117525. * Get a value from its key or add it if it doesn't exist.
  117526. * This method will ensure you that a given key/data will be present in the dictionary.
  117527. * @param key the given key to get the matching value from
  117528. * @param factory the factory that will create the value if the key is not present in the dictionary.
  117529. * The factory will only be invoked if there's no data for the given key.
  117530. * @return the value corresponding to the key.
  117531. */
  117532. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  117533. /**
  117534. * Get a value from its key if present in the dictionary otherwise add it
  117535. * @param key the key to get the value from
  117536. * @param val if there's no such key/value pair in the dictionary add it with this value
  117537. * @return the value corresponding to the key
  117538. */
  117539. getOrAdd(key: string, val: T): T;
  117540. /**
  117541. * Check if there's a given key in the dictionary
  117542. * @param key the key to check for
  117543. * @return true if the key is present, false otherwise
  117544. */
  117545. contains(key: string): boolean;
  117546. /**
  117547. * Add a new key and its corresponding value
  117548. * @param key the key to add
  117549. * @param value the value corresponding to the key
  117550. * @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
  117551. */
  117552. add(key: string, value: T): boolean;
  117553. /**
  117554. * Update a specific value associated to a key
  117555. * @param key defines the key to use
  117556. * @param value defines the value to store
  117557. * @returns true if the value was updated (or false if the key was not found)
  117558. */
  117559. set(key: string, value: T): boolean;
  117560. /**
  117561. * Get the element of the given key and remove it from the dictionary
  117562. * @param key defines the key to search
  117563. * @returns the value associated with the key or null if not found
  117564. */
  117565. getAndRemove(key: string): Nullable<T>;
  117566. /**
  117567. * Remove a key/value from the dictionary.
  117568. * @param key the key to remove
  117569. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  117570. */
  117571. remove(key: string): boolean;
  117572. /**
  117573. * Clear the whole content of the dictionary
  117574. */
  117575. clear(): void;
  117576. /**
  117577. * Gets the current count
  117578. */
  117579. get count(): number;
  117580. /**
  117581. * Execute a callback on each key/val of the dictionary.
  117582. * Note that you can remove any element in this dictionary in the callback implementation
  117583. * @param callback the callback to execute on a given key/value pair
  117584. */
  117585. forEach(callback: (key: string, val: T) => void): void;
  117586. /**
  117587. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  117588. * If the callback returns null or undefined the method will iterate to the next key/value pair
  117589. * Note that you can remove any element in this dictionary in the callback implementation
  117590. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  117591. * @returns the first item
  117592. */
  117593. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  117594. private _count;
  117595. private _data;
  117596. }
  117597. }
  117598. declare module BABYLON {
  117599. /** @hidden */
  117600. export interface ICollisionCoordinator {
  117601. createCollider(): Collider;
  117602. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117603. init(scene: Scene): void;
  117604. }
  117605. /** @hidden */
  117606. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  117607. private _scene;
  117608. private _scaledPosition;
  117609. private _scaledVelocity;
  117610. private _finalPosition;
  117611. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117612. createCollider(): Collider;
  117613. init(scene: Scene): void;
  117614. private _collideWithWorld;
  117615. }
  117616. }
  117617. declare module BABYLON {
  117618. /**
  117619. * Class used to manage all inputs for the scene.
  117620. */
  117621. export class InputManager {
  117622. /** The distance in pixel that you have to move to prevent some events */
  117623. static DragMovementThreshold: number;
  117624. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  117625. static LongPressDelay: number;
  117626. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  117627. static DoubleClickDelay: number;
  117628. /** If you need to check double click without raising a single click at first click, enable this flag */
  117629. static ExclusiveDoubleClickMode: boolean;
  117630. /** 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. */
  117631. private _alreadyAttached;
  117632. private _wheelEventName;
  117633. private _onPointerMove;
  117634. private _onPointerDown;
  117635. private _onPointerUp;
  117636. private _initClickEvent;
  117637. private _initActionManager;
  117638. private _delayedSimpleClick;
  117639. private _delayedSimpleClickTimeout;
  117640. private _previousDelayedSimpleClickTimeout;
  117641. private _meshPickProceed;
  117642. private _previousButtonPressed;
  117643. private _currentPickResult;
  117644. private _previousPickResult;
  117645. private _totalPointersPressed;
  117646. private _doubleClickOccured;
  117647. private _pointerOverMesh;
  117648. private _pickedDownMesh;
  117649. private _pickedUpMesh;
  117650. private _pointerX;
  117651. private _pointerY;
  117652. private _unTranslatedPointerX;
  117653. private _unTranslatedPointerY;
  117654. private _startingPointerPosition;
  117655. private _previousStartingPointerPosition;
  117656. private _startingPointerTime;
  117657. private _previousStartingPointerTime;
  117658. private _pointerCaptures;
  117659. private _onKeyDown;
  117660. private _onKeyUp;
  117661. private _onCanvasFocusObserver;
  117662. private _onCanvasBlurObserver;
  117663. private _scene;
  117664. /**
  117665. * Creates a new InputManager
  117666. * @param scene defines the hosting scene
  117667. */
  117668. constructor(scene: Scene);
  117669. /**
  117670. * Gets the mesh that is currently under the pointer
  117671. */
  117672. get meshUnderPointer(): Nullable<AbstractMesh>;
  117673. /**
  117674. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  117675. */
  117676. get unTranslatedPointer(): Vector2;
  117677. /**
  117678. * Gets or sets the current on-screen X position of the pointer
  117679. */
  117680. get pointerX(): number;
  117681. set pointerX(value: number);
  117682. /**
  117683. * Gets or sets the current on-screen Y position of the pointer
  117684. */
  117685. get pointerY(): number;
  117686. set pointerY(value: number);
  117687. private _updatePointerPosition;
  117688. private _processPointerMove;
  117689. private _setRayOnPointerInfo;
  117690. private _checkPrePointerObservable;
  117691. /**
  117692. * Use this method to simulate a pointer move on a mesh
  117693. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117694. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117695. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117696. */
  117697. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117698. /**
  117699. * Use this method to simulate a pointer down on a mesh
  117700. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117701. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117702. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117703. */
  117704. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117705. private _processPointerDown;
  117706. /** @hidden */
  117707. _isPointerSwiping(): boolean;
  117708. /**
  117709. * Use this method to simulate a pointer up on a mesh
  117710. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117711. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117712. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117713. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117714. */
  117715. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  117716. private _processPointerUp;
  117717. /**
  117718. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117719. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117720. * @returns true if the pointer was captured
  117721. */
  117722. isPointerCaptured(pointerId?: number): boolean;
  117723. /**
  117724. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117725. * @param attachUp defines if you want to attach events to pointerup
  117726. * @param attachDown defines if you want to attach events to pointerdown
  117727. * @param attachMove defines if you want to attach events to pointermove
  117728. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  117729. */
  117730. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  117731. /**
  117732. * Detaches all event handlers
  117733. */
  117734. detachControl(): void;
  117735. /**
  117736. * Force the value of meshUnderPointer
  117737. * @param mesh defines the mesh to use
  117738. */
  117739. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117740. /**
  117741. * Gets the mesh under the pointer
  117742. * @returns a Mesh or null if no mesh is under the pointer
  117743. */
  117744. getPointerOverMesh(): Nullable<AbstractMesh>;
  117745. }
  117746. }
  117747. declare module BABYLON {
  117748. /**
  117749. * This class defines the direct association between an animation and a target
  117750. */
  117751. export class TargetedAnimation {
  117752. /**
  117753. * Animation to perform
  117754. */
  117755. animation: Animation;
  117756. /**
  117757. * Target to animate
  117758. */
  117759. target: any;
  117760. /**
  117761. * Returns the string "TargetedAnimation"
  117762. * @returns "TargetedAnimation"
  117763. */
  117764. getClassName(): string;
  117765. /**
  117766. * Serialize the object
  117767. * @returns the JSON object representing the current entity
  117768. */
  117769. serialize(): any;
  117770. }
  117771. /**
  117772. * Use this class to create coordinated animations on multiple targets
  117773. */
  117774. export class AnimationGroup implements IDisposable {
  117775. /** The name of the animation group */
  117776. name: string;
  117777. private _scene;
  117778. private _targetedAnimations;
  117779. private _animatables;
  117780. private _from;
  117781. private _to;
  117782. private _isStarted;
  117783. private _isPaused;
  117784. private _speedRatio;
  117785. private _loopAnimation;
  117786. private _isAdditive;
  117787. /**
  117788. * Gets or sets the unique id of the node
  117789. */
  117790. uniqueId: number;
  117791. /**
  117792. * This observable will notify when one animation have ended
  117793. */
  117794. onAnimationEndObservable: Observable<TargetedAnimation>;
  117795. /**
  117796. * Observer raised when one animation loops
  117797. */
  117798. onAnimationLoopObservable: Observable<TargetedAnimation>;
  117799. /**
  117800. * Observer raised when all animations have looped
  117801. */
  117802. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  117803. /**
  117804. * This observable will notify when all animations have ended.
  117805. */
  117806. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  117807. /**
  117808. * This observable will notify when all animations have paused.
  117809. */
  117810. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  117811. /**
  117812. * This observable will notify when all animations are playing.
  117813. */
  117814. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  117815. /**
  117816. * Gets the first frame
  117817. */
  117818. get from(): number;
  117819. /**
  117820. * Gets the last frame
  117821. */
  117822. get to(): number;
  117823. /**
  117824. * Define if the animations are started
  117825. */
  117826. get isStarted(): boolean;
  117827. /**
  117828. * Gets a value indicating that the current group is playing
  117829. */
  117830. get isPlaying(): boolean;
  117831. /**
  117832. * Gets or sets the speed ratio to use for all animations
  117833. */
  117834. get speedRatio(): number;
  117835. /**
  117836. * Gets or sets the speed ratio to use for all animations
  117837. */
  117838. set speedRatio(value: number);
  117839. /**
  117840. * Gets or sets if all animations should loop or not
  117841. */
  117842. get loopAnimation(): boolean;
  117843. set loopAnimation(value: boolean);
  117844. /**
  117845. * Gets or sets if all animations should be evaluated additively
  117846. */
  117847. get isAdditive(): boolean;
  117848. set isAdditive(value: boolean);
  117849. /**
  117850. * Gets the targeted animations for this animation group
  117851. */
  117852. get targetedAnimations(): Array<TargetedAnimation>;
  117853. /**
  117854. * returning the list of animatables controlled by this animation group.
  117855. */
  117856. get animatables(): Array<Animatable>;
  117857. /**
  117858. * Gets the list of target animations
  117859. */
  117860. get children(): TargetedAnimation[];
  117861. /**
  117862. * Instantiates a new Animation Group.
  117863. * This helps managing several animations at once.
  117864. * @see https://doc.babylonjs.com/how_to/group
  117865. * @param name Defines the name of the group
  117866. * @param scene Defines the scene the group belongs to
  117867. */
  117868. constructor(
  117869. /** The name of the animation group */
  117870. name: string, scene?: Nullable<Scene>);
  117871. /**
  117872. * Add an animation (with its target) in the group
  117873. * @param animation defines the animation we want to add
  117874. * @param target defines the target of the animation
  117875. * @returns the TargetedAnimation object
  117876. */
  117877. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  117878. /**
  117879. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  117880. * It can add constant keys at begin or end
  117881. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  117882. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  117883. * @returns the animation group
  117884. */
  117885. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  117886. private _animationLoopCount;
  117887. private _animationLoopFlags;
  117888. private _processLoop;
  117889. /**
  117890. * Start all animations on given targets
  117891. * @param loop defines if animations must loop
  117892. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  117893. * @param from defines the from key (optional)
  117894. * @param to defines the to key (optional)
  117895. * @param isAdditive defines the additive state for the resulting animatables (optional)
  117896. * @returns the current animation group
  117897. */
  117898. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  117899. /**
  117900. * Pause all animations
  117901. * @returns the animation group
  117902. */
  117903. pause(): AnimationGroup;
  117904. /**
  117905. * Play all animations to initial state
  117906. * This function will start() the animations if they were not started or will restart() them if they were paused
  117907. * @param loop defines if animations must loop
  117908. * @returns the animation group
  117909. */
  117910. play(loop?: boolean): AnimationGroup;
  117911. /**
  117912. * Reset all animations to initial state
  117913. * @returns the animation group
  117914. */
  117915. reset(): AnimationGroup;
  117916. /**
  117917. * Restart animations from key 0
  117918. * @returns the animation group
  117919. */
  117920. restart(): AnimationGroup;
  117921. /**
  117922. * Stop all animations
  117923. * @returns the animation group
  117924. */
  117925. stop(): AnimationGroup;
  117926. /**
  117927. * Set animation weight for all animatables
  117928. * @param weight defines the weight to use
  117929. * @return the animationGroup
  117930. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117931. */
  117932. setWeightForAllAnimatables(weight: number): AnimationGroup;
  117933. /**
  117934. * Synchronize and normalize all animatables with a source animatable
  117935. * @param root defines the root animatable to synchronize with
  117936. * @return the animationGroup
  117937. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117938. */
  117939. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  117940. /**
  117941. * Goes to a specific frame in this animation group
  117942. * @param frame the frame number to go to
  117943. * @return the animationGroup
  117944. */
  117945. goToFrame(frame: number): AnimationGroup;
  117946. /**
  117947. * Dispose all associated resources
  117948. */
  117949. dispose(): void;
  117950. private _checkAnimationGroupEnded;
  117951. /**
  117952. * Clone the current animation group and returns a copy
  117953. * @param newName defines the name of the new group
  117954. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  117955. * @returns the new aniamtion group
  117956. */
  117957. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  117958. /**
  117959. * Serializes the animationGroup to an object
  117960. * @returns Serialized object
  117961. */
  117962. serialize(): any;
  117963. /**
  117964. * Returns a new AnimationGroup object parsed from the source provided.
  117965. * @param parsedAnimationGroup defines the source
  117966. * @param scene defines the scene that will receive the animationGroup
  117967. * @returns a new AnimationGroup
  117968. */
  117969. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  117970. /**
  117971. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117972. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  117973. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117974. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  117975. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  117976. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  117977. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  117978. */
  117979. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  117980. /**
  117981. * Returns the string "AnimationGroup"
  117982. * @returns "AnimationGroup"
  117983. */
  117984. getClassName(): string;
  117985. /**
  117986. * Creates a detailled string about the object
  117987. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  117988. * @returns a string representing the object
  117989. */
  117990. toString(fullDetails?: boolean): string;
  117991. }
  117992. }
  117993. declare module BABYLON {
  117994. /**
  117995. * Define an interface for all classes that will hold resources
  117996. */
  117997. export interface IDisposable {
  117998. /**
  117999. * Releases all held resources
  118000. */
  118001. dispose(): void;
  118002. }
  118003. /** Interface defining initialization parameters for Scene class */
  118004. export interface SceneOptions {
  118005. /**
  118006. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  118007. * It will improve performance when the number of geometries becomes important.
  118008. */
  118009. useGeometryUniqueIdsMap?: boolean;
  118010. /**
  118011. * Defines that each material of the scene should keep up-to-date a map of referencing 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. useMaterialMeshMap?: boolean;
  118015. /**
  118016. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  118017. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118018. */
  118019. useClonedMeshMap?: boolean;
  118020. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  118021. virtual?: boolean;
  118022. }
  118023. /**
  118024. * Represents a scene to be rendered by the engine.
  118025. * @see https://doc.babylonjs.com/features/scene
  118026. */
  118027. export class Scene extends AbstractScene implements IAnimatable {
  118028. /** The fog is deactivated */
  118029. static readonly FOGMODE_NONE: number;
  118030. /** The fog density is following an exponential function */
  118031. static readonly FOGMODE_EXP: number;
  118032. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118033. static readonly FOGMODE_EXP2: number;
  118034. /** The fog density is following a linear function. */
  118035. static readonly FOGMODE_LINEAR: number;
  118036. /**
  118037. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  118038. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118039. */
  118040. static MinDeltaTime: number;
  118041. /**
  118042. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  118043. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118044. */
  118045. static MaxDeltaTime: number;
  118046. /**
  118047. * Factory used to create the default material.
  118048. * @param name The name of the material to create
  118049. * @param scene The scene to create the material for
  118050. * @returns The default material
  118051. */
  118052. static DefaultMaterialFactory(scene: Scene): Material;
  118053. /**
  118054. * Factory used to create the a collision coordinator.
  118055. * @returns The collision coordinator
  118056. */
  118057. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  118058. /** @hidden */
  118059. _inputManager: InputManager;
  118060. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  118061. cameraToUseForPointers: Nullable<Camera>;
  118062. /** @hidden */
  118063. readonly _isScene: boolean;
  118064. /** @hidden */
  118065. _blockEntityCollection: boolean;
  118066. /**
  118067. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  118068. */
  118069. autoClear: boolean;
  118070. /**
  118071. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  118072. */
  118073. autoClearDepthAndStencil: boolean;
  118074. /**
  118075. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  118076. */
  118077. clearColor: Color4;
  118078. /**
  118079. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  118080. */
  118081. ambientColor: Color3;
  118082. /**
  118083. * This is use to store the default BRDF lookup for PBR materials in your scene.
  118084. * It should only be one of the following (if not the default embedded one):
  118085. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118086. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  118087. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118088. * The material properties need to be setup according to the type of texture in use.
  118089. */
  118090. environmentBRDFTexture: BaseTexture;
  118091. /** @hidden */
  118092. protected _environmentTexture: Nullable<BaseTexture>;
  118093. /**
  118094. * Texture used in all pbr material as the reflection texture.
  118095. * As in the majority of the scene they are the same (exception for multi room and so on),
  118096. * this is easier to reference from here than from all the materials.
  118097. */
  118098. get environmentTexture(): Nullable<BaseTexture>;
  118099. /**
  118100. * Texture used in all pbr material as the reflection texture.
  118101. * As in the majority of the scene they are the same (exception for multi room and so on),
  118102. * this is easier to set here than in all the materials.
  118103. */
  118104. set environmentTexture(value: Nullable<BaseTexture>);
  118105. /** @hidden */
  118106. protected _environmentIntensity: number;
  118107. /**
  118108. * Intensity of the environment in all pbr material.
  118109. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118110. * As in the majority of the scene they are the same (exception for multi room and so on),
  118111. * this is easier to reference from here than from all the materials.
  118112. */
  118113. get environmentIntensity(): number;
  118114. /**
  118115. * Intensity of the environment in all pbr material.
  118116. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118117. * As in the majority of the scene they are the same (exception for multi room and so on),
  118118. * this is easier to set here than in all the materials.
  118119. */
  118120. set environmentIntensity(value: number);
  118121. /** @hidden */
  118122. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118123. /**
  118124. * Default image processing configuration used either in the rendering
  118125. * Forward main pass or through the imageProcessingPostProcess if present.
  118126. * As in the majority of the scene they are the same (exception for multi camera),
  118127. * this is easier to reference from here than from all the materials and post process.
  118128. *
  118129. * No setter as we it is a shared configuration, you can set the values instead.
  118130. */
  118131. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118132. private _forceWireframe;
  118133. /**
  118134. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  118135. */
  118136. set forceWireframe(value: boolean);
  118137. get forceWireframe(): boolean;
  118138. private _skipFrustumClipping;
  118139. /**
  118140. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  118141. */
  118142. set skipFrustumClipping(value: boolean);
  118143. get skipFrustumClipping(): boolean;
  118144. private _forcePointsCloud;
  118145. /**
  118146. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  118147. */
  118148. set forcePointsCloud(value: boolean);
  118149. get forcePointsCloud(): boolean;
  118150. /**
  118151. * Gets or sets the active clipplane 1
  118152. */
  118153. clipPlane: Nullable<Plane>;
  118154. /**
  118155. * Gets or sets the active clipplane 2
  118156. */
  118157. clipPlane2: Nullable<Plane>;
  118158. /**
  118159. * Gets or sets the active clipplane 3
  118160. */
  118161. clipPlane3: Nullable<Plane>;
  118162. /**
  118163. * Gets or sets the active clipplane 4
  118164. */
  118165. clipPlane4: Nullable<Plane>;
  118166. /**
  118167. * Gets or sets the active clipplane 5
  118168. */
  118169. clipPlane5: Nullable<Plane>;
  118170. /**
  118171. * Gets or sets the active clipplane 6
  118172. */
  118173. clipPlane6: Nullable<Plane>;
  118174. /**
  118175. * Gets or sets a boolean indicating if animations are enabled
  118176. */
  118177. animationsEnabled: boolean;
  118178. private _animationPropertiesOverride;
  118179. /**
  118180. * Gets or sets the animation properties override
  118181. */
  118182. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  118183. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  118184. /**
  118185. * Gets or sets a boolean indicating if a constant deltatime has to be used
  118186. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  118187. */
  118188. useConstantAnimationDeltaTime: boolean;
  118189. /**
  118190. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  118191. * Please note that it requires to run a ray cast through the scene on every frame
  118192. */
  118193. constantlyUpdateMeshUnderPointer: boolean;
  118194. /**
  118195. * Defines the HTML cursor to use when hovering over interactive elements
  118196. */
  118197. hoverCursor: string;
  118198. /**
  118199. * Defines the HTML default cursor to use (empty by default)
  118200. */
  118201. defaultCursor: string;
  118202. /**
  118203. * Defines whether cursors are handled by the scene.
  118204. */
  118205. doNotHandleCursors: boolean;
  118206. /**
  118207. * This is used to call preventDefault() on pointer down
  118208. * in order to block unwanted artifacts like system double clicks
  118209. */
  118210. preventDefaultOnPointerDown: boolean;
  118211. /**
  118212. * This is used to call preventDefault() on pointer up
  118213. * in order to block unwanted artifacts like system double clicks
  118214. */
  118215. preventDefaultOnPointerUp: boolean;
  118216. /**
  118217. * Gets or sets user defined metadata
  118218. */
  118219. metadata: any;
  118220. /**
  118221. * For internal use only. Please do not use.
  118222. */
  118223. reservedDataStore: any;
  118224. /**
  118225. * Gets the name of the plugin used to load this scene (null by default)
  118226. */
  118227. loadingPluginName: string;
  118228. /**
  118229. * Use this array to add regular expressions used to disable offline support for specific urls
  118230. */
  118231. disableOfflineSupportExceptionRules: RegExp[];
  118232. /**
  118233. * An event triggered when the scene is disposed.
  118234. */
  118235. onDisposeObservable: Observable<Scene>;
  118236. private _onDisposeObserver;
  118237. /** Sets a function to be executed when this scene is disposed. */
  118238. set onDispose(callback: () => void);
  118239. /**
  118240. * An event triggered before rendering the scene (right after animations and physics)
  118241. */
  118242. onBeforeRenderObservable: Observable<Scene>;
  118243. private _onBeforeRenderObserver;
  118244. /** Sets a function to be executed before rendering this scene */
  118245. set beforeRender(callback: Nullable<() => void>);
  118246. /**
  118247. * An event triggered after rendering the scene
  118248. */
  118249. onAfterRenderObservable: Observable<Scene>;
  118250. /**
  118251. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  118252. */
  118253. onAfterRenderCameraObservable: Observable<Camera>;
  118254. private _onAfterRenderObserver;
  118255. /** Sets a function to be executed after rendering this scene */
  118256. set afterRender(callback: Nullable<() => void>);
  118257. /**
  118258. * An event triggered before animating the scene
  118259. */
  118260. onBeforeAnimationsObservable: Observable<Scene>;
  118261. /**
  118262. * An event triggered after animations processing
  118263. */
  118264. onAfterAnimationsObservable: Observable<Scene>;
  118265. /**
  118266. * An event triggered before draw calls are ready to be sent
  118267. */
  118268. onBeforeDrawPhaseObservable: Observable<Scene>;
  118269. /**
  118270. * An event triggered after draw calls have been sent
  118271. */
  118272. onAfterDrawPhaseObservable: Observable<Scene>;
  118273. /**
  118274. * An event triggered when the scene is ready
  118275. */
  118276. onReadyObservable: Observable<Scene>;
  118277. /**
  118278. * An event triggered before rendering a camera
  118279. */
  118280. onBeforeCameraRenderObservable: Observable<Camera>;
  118281. private _onBeforeCameraRenderObserver;
  118282. /** Sets a function to be executed before rendering a camera*/
  118283. set beforeCameraRender(callback: () => void);
  118284. /**
  118285. * An event triggered after rendering a camera
  118286. */
  118287. onAfterCameraRenderObservable: Observable<Camera>;
  118288. private _onAfterCameraRenderObserver;
  118289. /** Sets a function to be executed after rendering a camera*/
  118290. set afterCameraRender(callback: () => void);
  118291. /**
  118292. * An event triggered when active meshes evaluation is about to start
  118293. */
  118294. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  118295. /**
  118296. * An event triggered when active meshes evaluation is done
  118297. */
  118298. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  118299. /**
  118300. * An event triggered when particles rendering is about to start
  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. onBeforeParticlesRenderingObservable: Observable<Scene>;
  118304. /**
  118305. * An event triggered when particles rendering is done
  118306. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118307. */
  118308. onAfterParticlesRenderingObservable: Observable<Scene>;
  118309. /**
  118310. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  118311. */
  118312. onDataLoadedObservable: Observable<Scene>;
  118313. /**
  118314. * An event triggered when a camera is created
  118315. */
  118316. onNewCameraAddedObservable: Observable<Camera>;
  118317. /**
  118318. * An event triggered when a camera is removed
  118319. */
  118320. onCameraRemovedObservable: Observable<Camera>;
  118321. /**
  118322. * An event triggered when a light is created
  118323. */
  118324. onNewLightAddedObservable: Observable<Light>;
  118325. /**
  118326. * An event triggered when a light is removed
  118327. */
  118328. onLightRemovedObservable: Observable<Light>;
  118329. /**
  118330. * An event triggered when a geometry is created
  118331. */
  118332. onNewGeometryAddedObservable: Observable<Geometry>;
  118333. /**
  118334. * An event triggered when a geometry is removed
  118335. */
  118336. onGeometryRemovedObservable: Observable<Geometry>;
  118337. /**
  118338. * An event triggered when a transform node is created
  118339. */
  118340. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  118341. /**
  118342. * An event triggered when a transform node is removed
  118343. */
  118344. onTransformNodeRemovedObservable: Observable<TransformNode>;
  118345. /**
  118346. * An event triggered when a mesh is created
  118347. */
  118348. onNewMeshAddedObservable: Observable<AbstractMesh>;
  118349. /**
  118350. * An event triggered when a mesh is removed
  118351. */
  118352. onMeshRemovedObservable: Observable<AbstractMesh>;
  118353. /**
  118354. * An event triggered when a skeleton is created
  118355. */
  118356. onNewSkeletonAddedObservable: Observable<Skeleton>;
  118357. /**
  118358. * An event triggered when a skeleton is removed
  118359. */
  118360. onSkeletonRemovedObservable: Observable<Skeleton>;
  118361. /**
  118362. * An event triggered when a material is created
  118363. */
  118364. onNewMaterialAddedObservable: Observable<Material>;
  118365. /**
  118366. * An event triggered when a material is removed
  118367. */
  118368. onMaterialRemovedObservable: Observable<Material>;
  118369. /**
  118370. * An event triggered when a texture is created
  118371. */
  118372. onNewTextureAddedObservable: Observable<BaseTexture>;
  118373. /**
  118374. * An event triggered when a texture is removed
  118375. */
  118376. onTextureRemovedObservable: Observable<BaseTexture>;
  118377. /**
  118378. * An event triggered when render targets are about to be rendered
  118379. * Can happen multiple times per frame.
  118380. */
  118381. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118382. /**
  118383. * An event triggered when render targets were rendered.
  118384. * Can happen multiple times per frame.
  118385. */
  118386. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118387. /**
  118388. * An event triggered before calculating deterministic simulation step
  118389. */
  118390. onBeforeStepObservable: Observable<Scene>;
  118391. /**
  118392. * An event triggered after calculating deterministic simulation step
  118393. */
  118394. onAfterStepObservable: Observable<Scene>;
  118395. /**
  118396. * An event triggered when the activeCamera property is updated
  118397. */
  118398. onActiveCameraChanged: Observable<Scene>;
  118399. /**
  118400. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118401. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118402. * 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)
  118403. */
  118404. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118405. /**
  118406. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118407. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118408. * 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)
  118409. */
  118410. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118411. /**
  118412. * This Observable will when a mesh has been imported into the scene.
  118413. */
  118414. onMeshImportedObservable: Observable<AbstractMesh>;
  118415. /**
  118416. * This Observable will when an animation file has been imported into the scene.
  118417. */
  118418. onAnimationFileImportedObservable: Observable<Scene>;
  118419. /**
  118420. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118421. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118422. */
  118423. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118424. /** @hidden */
  118425. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118426. /**
  118427. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118428. */
  118429. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118430. /**
  118431. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118432. */
  118433. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118434. /**
  118435. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118436. */
  118437. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118438. /** Callback called when a pointer move is detected */
  118439. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118440. /** Callback called when a pointer down is detected */
  118441. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118442. /** Callback called when a pointer up is detected */
  118443. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118444. /** Callback called when a pointer pick is detected */
  118445. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118446. /**
  118447. * 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).
  118448. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118449. */
  118450. onPrePointerObservable: Observable<PointerInfoPre>;
  118451. /**
  118452. * Observable event triggered each time an input event is received from the rendering canvas
  118453. */
  118454. onPointerObservable: Observable<PointerInfo>;
  118455. /**
  118456. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118457. */
  118458. get unTranslatedPointer(): Vector2;
  118459. /**
  118460. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118461. */
  118462. static get DragMovementThreshold(): number;
  118463. static set DragMovementThreshold(value: number);
  118464. /**
  118465. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  118466. */
  118467. static get LongPressDelay(): number;
  118468. static set LongPressDelay(value: number);
  118469. /**
  118470. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  118471. */
  118472. static get DoubleClickDelay(): number;
  118473. static set DoubleClickDelay(value: number);
  118474. /** If you need to check double click without raising a single click at first click, enable this flag */
  118475. static get ExclusiveDoubleClickMode(): boolean;
  118476. static set ExclusiveDoubleClickMode(value: boolean);
  118477. /** @hidden */
  118478. _mirroredCameraPosition: Nullable<Vector3>;
  118479. /**
  118480. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  118481. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  118482. */
  118483. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  118484. /**
  118485. * Observable event triggered each time an keyboard event is received from the hosting window
  118486. */
  118487. onKeyboardObservable: Observable<KeyboardInfo>;
  118488. private _useRightHandedSystem;
  118489. /**
  118490. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  118491. */
  118492. set useRightHandedSystem(value: boolean);
  118493. get useRightHandedSystem(): boolean;
  118494. private _timeAccumulator;
  118495. private _currentStepId;
  118496. private _currentInternalStep;
  118497. /**
  118498. * Sets the step Id used by deterministic lock step
  118499. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118500. * @param newStepId defines the step Id
  118501. */
  118502. setStepId(newStepId: number): void;
  118503. /**
  118504. * Gets the step Id used by deterministic lock step
  118505. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118506. * @returns the step Id
  118507. */
  118508. getStepId(): number;
  118509. /**
  118510. * Gets the internal step used by deterministic lock step
  118511. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118512. * @returns the internal step
  118513. */
  118514. getInternalStep(): number;
  118515. private _fogEnabled;
  118516. /**
  118517. * Gets or sets a boolean indicating if fog is enabled on this scene
  118518. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118519. * (Default is true)
  118520. */
  118521. set fogEnabled(value: boolean);
  118522. get fogEnabled(): boolean;
  118523. private _fogMode;
  118524. /**
  118525. * Gets or sets the fog mode to use
  118526. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118527. * | mode | value |
  118528. * | --- | --- |
  118529. * | FOGMODE_NONE | 0 |
  118530. * | FOGMODE_EXP | 1 |
  118531. * | FOGMODE_EXP2 | 2 |
  118532. * | FOGMODE_LINEAR | 3 |
  118533. */
  118534. set fogMode(value: number);
  118535. get fogMode(): number;
  118536. /**
  118537. * Gets or sets the fog color to use
  118538. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118539. * (Default is Color3(0.2, 0.2, 0.3))
  118540. */
  118541. fogColor: Color3;
  118542. /**
  118543. * Gets or sets the fog density to use
  118544. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118545. * (Default is 0.1)
  118546. */
  118547. fogDensity: number;
  118548. /**
  118549. * Gets or sets the fog start distance to use
  118550. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118551. * (Default is 0)
  118552. */
  118553. fogStart: number;
  118554. /**
  118555. * Gets or sets the fog end distance to use
  118556. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118557. * (Default is 1000)
  118558. */
  118559. fogEnd: number;
  118560. /**
  118561. * Flag indicating that the frame buffer binding is handled by another component
  118562. */
  118563. prePass: boolean;
  118564. private _shadowsEnabled;
  118565. /**
  118566. * Gets or sets a boolean indicating if shadows are enabled on this scene
  118567. */
  118568. set shadowsEnabled(value: boolean);
  118569. get shadowsEnabled(): boolean;
  118570. private _lightsEnabled;
  118571. /**
  118572. * Gets or sets a boolean indicating if lights are enabled on this scene
  118573. */
  118574. set lightsEnabled(value: boolean);
  118575. get lightsEnabled(): boolean;
  118576. /** All of the active cameras added to this scene. */
  118577. activeCameras: Camera[];
  118578. /** @hidden */
  118579. _activeCamera: Nullable<Camera>;
  118580. /** Gets or sets the current active camera */
  118581. get activeCamera(): Nullable<Camera>;
  118582. set activeCamera(value: Nullable<Camera>);
  118583. private _defaultMaterial;
  118584. /** The default material used on meshes when no material is affected */
  118585. get defaultMaterial(): Material;
  118586. /** The default material used on meshes when no material is affected */
  118587. set defaultMaterial(value: Material);
  118588. private _texturesEnabled;
  118589. /**
  118590. * Gets or sets a boolean indicating if textures are enabled on this scene
  118591. */
  118592. set texturesEnabled(value: boolean);
  118593. get texturesEnabled(): boolean;
  118594. /**
  118595. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  118596. */
  118597. physicsEnabled: boolean;
  118598. /**
  118599. * Gets or sets a boolean indicating if particles are enabled on this scene
  118600. */
  118601. particlesEnabled: boolean;
  118602. /**
  118603. * Gets or sets a boolean indicating if sprites are enabled on this scene
  118604. */
  118605. spritesEnabled: boolean;
  118606. private _skeletonsEnabled;
  118607. /**
  118608. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  118609. */
  118610. set skeletonsEnabled(value: boolean);
  118611. get skeletonsEnabled(): boolean;
  118612. /**
  118613. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  118614. */
  118615. lensFlaresEnabled: boolean;
  118616. /**
  118617. * Gets or sets a boolean indicating if collisions are enabled on this scene
  118618. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118619. */
  118620. collisionsEnabled: boolean;
  118621. private _collisionCoordinator;
  118622. /** @hidden */
  118623. get collisionCoordinator(): ICollisionCoordinator;
  118624. /**
  118625. * Defines the gravity applied to this scene (used only for collisions)
  118626. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118627. */
  118628. gravity: Vector3;
  118629. /**
  118630. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  118631. */
  118632. postProcessesEnabled: boolean;
  118633. /**
  118634. * The list of postprocesses added to the scene
  118635. */
  118636. postProcesses: PostProcess[];
  118637. /**
  118638. * Gets the current postprocess manager
  118639. */
  118640. postProcessManager: PostProcessManager;
  118641. /**
  118642. * Gets or sets a boolean indicating if render targets are enabled on this scene
  118643. */
  118644. renderTargetsEnabled: boolean;
  118645. /**
  118646. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  118647. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  118648. */
  118649. dumpNextRenderTargets: boolean;
  118650. /**
  118651. * The list of user defined render targets added to the scene
  118652. */
  118653. customRenderTargets: RenderTargetTexture[];
  118654. /**
  118655. * Defines if texture loading must be delayed
  118656. * If true, textures will only be loaded when they need to be rendered
  118657. */
  118658. useDelayedTextureLoading: boolean;
  118659. /**
  118660. * Gets the list of meshes imported to the scene through SceneLoader
  118661. */
  118662. importedMeshesFiles: String[];
  118663. /**
  118664. * Gets or sets a boolean indicating if probes are enabled on this scene
  118665. */
  118666. probesEnabled: boolean;
  118667. /**
  118668. * Gets or sets the current offline provider to use to store scene data
  118669. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118670. */
  118671. offlineProvider: IOfflineProvider;
  118672. /**
  118673. * Gets or sets the action manager associated with the scene
  118674. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  118675. */
  118676. actionManager: AbstractActionManager;
  118677. private _meshesForIntersections;
  118678. /**
  118679. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  118680. */
  118681. proceduralTexturesEnabled: boolean;
  118682. private _engine;
  118683. private _totalVertices;
  118684. /** @hidden */
  118685. _activeIndices: PerfCounter;
  118686. /** @hidden */
  118687. _activeParticles: PerfCounter;
  118688. /** @hidden */
  118689. _activeBones: PerfCounter;
  118690. private _animationRatio;
  118691. /** @hidden */
  118692. _animationTimeLast: number;
  118693. /** @hidden */
  118694. _animationTime: number;
  118695. /**
  118696. * Gets or sets a general scale for animation speed
  118697. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  118698. */
  118699. animationTimeScale: number;
  118700. /** @hidden */
  118701. _cachedMaterial: Nullable<Material>;
  118702. /** @hidden */
  118703. _cachedEffect: Nullable<Effect>;
  118704. /** @hidden */
  118705. _cachedVisibility: Nullable<number>;
  118706. private _renderId;
  118707. private _frameId;
  118708. private _executeWhenReadyTimeoutId;
  118709. private _intermediateRendering;
  118710. private _viewUpdateFlag;
  118711. private _projectionUpdateFlag;
  118712. /** @hidden */
  118713. _toBeDisposed: Nullable<IDisposable>[];
  118714. private _activeRequests;
  118715. /** @hidden */
  118716. _pendingData: any[];
  118717. private _isDisposed;
  118718. /**
  118719. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  118720. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  118721. */
  118722. dispatchAllSubMeshesOfActiveMeshes: boolean;
  118723. private _activeMeshes;
  118724. private _processedMaterials;
  118725. private _renderTargets;
  118726. /** @hidden */
  118727. _activeParticleSystems: SmartArray<IParticleSystem>;
  118728. private _activeSkeletons;
  118729. private _softwareSkinnedMeshes;
  118730. private _renderingManager;
  118731. /** @hidden */
  118732. _activeAnimatables: Animatable[];
  118733. private _transformMatrix;
  118734. private _sceneUbo;
  118735. /** @hidden */
  118736. _viewMatrix: Matrix;
  118737. private _projectionMatrix;
  118738. /** @hidden */
  118739. _forcedViewPosition: Nullable<Vector3>;
  118740. /** @hidden */
  118741. _frustumPlanes: Plane[];
  118742. /**
  118743. * Gets the list of frustum planes (built from the active camera)
  118744. */
  118745. get frustumPlanes(): Plane[];
  118746. /**
  118747. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  118748. * This is useful if there are more lights that the maximum simulteanous authorized
  118749. */
  118750. requireLightSorting: boolean;
  118751. /** @hidden */
  118752. readonly useMaterialMeshMap: boolean;
  118753. /** @hidden */
  118754. readonly useClonedMeshMap: boolean;
  118755. private _externalData;
  118756. private _uid;
  118757. /**
  118758. * @hidden
  118759. * Backing store of defined scene components.
  118760. */
  118761. _components: ISceneComponent[];
  118762. /**
  118763. * @hidden
  118764. * Backing store of defined scene components.
  118765. */
  118766. _serializableComponents: ISceneSerializableComponent[];
  118767. /**
  118768. * List of components to register on the next registration step.
  118769. */
  118770. private _transientComponents;
  118771. /**
  118772. * Registers the transient components if needed.
  118773. */
  118774. private _registerTransientComponents;
  118775. /**
  118776. * @hidden
  118777. * Add a component to the scene.
  118778. * Note that the ccomponent could be registered on th next frame if this is called after
  118779. * the register component stage.
  118780. * @param component Defines the component to add to the scene
  118781. */
  118782. _addComponent(component: ISceneComponent): void;
  118783. /**
  118784. * @hidden
  118785. * Gets a component from the scene.
  118786. * @param name defines the name of the component to retrieve
  118787. * @returns the component or null if not present
  118788. */
  118789. _getComponent(name: string): Nullable<ISceneComponent>;
  118790. /**
  118791. * @hidden
  118792. * Defines the actions happening before camera updates.
  118793. */
  118794. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  118795. /**
  118796. * @hidden
  118797. * Defines the actions happening before clear the canvas.
  118798. */
  118799. _beforeClearStage: Stage<SimpleStageAction>;
  118800. /**
  118801. * @hidden
  118802. * Defines the actions when collecting render targets for the frame.
  118803. */
  118804. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118805. /**
  118806. * @hidden
  118807. * Defines the actions happening for one camera in the frame.
  118808. */
  118809. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118810. /**
  118811. * @hidden
  118812. * Defines the actions happening during the per mesh ready checks.
  118813. */
  118814. _isReadyForMeshStage: Stage<MeshStageAction>;
  118815. /**
  118816. * @hidden
  118817. * Defines the actions happening before evaluate active mesh checks.
  118818. */
  118819. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  118820. /**
  118821. * @hidden
  118822. * Defines the actions happening during the evaluate sub mesh checks.
  118823. */
  118824. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  118825. /**
  118826. * @hidden
  118827. * Defines the actions happening during the active mesh stage.
  118828. */
  118829. _activeMeshStage: Stage<ActiveMeshStageAction>;
  118830. /**
  118831. * @hidden
  118832. * Defines the actions happening during the per camera render target step.
  118833. */
  118834. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  118835. /**
  118836. * @hidden
  118837. * Defines the actions happening just before the active camera is drawing.
  118838. */
  118839. _beforeCameraDrawStage: Stage<CameraStageAction>;
  118840. /**
  118841. * @hidden
  118842. * Defines the actions happening just before a render target is drawing.
  118843. */
  118844. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118845. /**
  118846. * @hidden
  118847. * Defines the actions happening just before a rendering group is drawing.
  118848. */
  118849. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118850. /**
  118851. * @hidden
  118852. * Defines the actions happening just before a mesh is drawing.
  118853. */
  118854. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118855. /**
  118856. * @hidden
  118857. * Defines the actions happening just after a mesh has been drawn.
  118858. */
  118859. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118860. /**
  118861. * @hidden
  118862. * Defines the actions happening just after a rendering group has been drawn.
  118863. */
  118864. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118865. /**
  118866. * @hidden
  118867. * Defines the actions happening just after the active camera has been drawn.
  118868. */
  118869. _afterCameraDrawStage: Stage<CameraStageAction>;
  118870. /**
  118871. * @hidden
  118872. * Defines the actions happening just after a render target has been drawn.
  118873. */
  118874. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118875. /**
  118876. * @hidden
  118877. * Defines the actions happening just after rendering all cameras and computing intersections.
  118878. */
  118879. _afterRenderStage: Stage<SimpleStageAction>;
  118880. /**
  118881. * @hidden
  118882. * Defines the actions happening when a pointer move event happens.
  118883. */
  118884. _pointerMoveStage: Stage<PointerMoveStageAction>;
  118885. /**
  118886. * @hidden
  118887. * Defines the actions happening when a pointer down event happens.
  118888. */
  118889. _pointerDownStage: Stage<PointerUpDownStageAction>;
  118890. /**
  118891. * @hidden
  118892. * Defines the actions happening when a pointer up event happens.
  118893. */
  118894. _pointerUpStage: Stage<PointerUpDownStageAction>;
  118895. /**
  118896. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  118897. */
  118898. private geometriesByUniqueId;
  118899. /**
  118900. * Creates a new Scene
  118901. * @param engine defines the engine to use to render this scene
  118902. * @param options defines the scene options
  118903. */
  118904. constructor(engine: Engine, options?: SceneOptions);
  118905. /**
  118906. * Gets a string idenfifying the name of the class
  118907. * @returns "Scene" string
  118908. */
  118909. getClassName(): string;
  118910. private _defaultMeshCandidates;
  118911. /**
  118912. * @hidden
  118913. */
  118914. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118915. private _defaultSubMeshCandidates;
  118916. /**
  118917. * @hidden
  118918. */
  118919. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118920. /**
  118921. * Sets the default candidate providers for the scene.
  118922. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  118923. * and getCollidingSubMeshCandidates to their default function
  118924. */
  118925. setDefaultCandidateProviders(): void;
  118926. /**
  118927. * Gets the mesh that is currently under the pointer
  118928. */
  118929. get meshUnderPointer(): Nullable<AbstractMesh>;
  118930. /**
  118931. * Gets or sets the current on-screen X position of the pointer
  118932. */
  118933. get pointerX(): number;
  118934. set pointerX(value: number);
  118935. /**
  118936. * Gets or sets the current on-screen Y position of the pointer
  118937. */
  118938. get pointerY(): number;
  118939. set pointerY(value: number);
  118940. /**
  118941. * Gets the cached material (ie. the latest rendered one)
  118942. * @returns the cached material
  118943. */
  118944. getCachedMaterial(): Nullable<Material>;
  118945. /**
  118946. * Gets the cached effect (ie. the latest rendered one)
  118947. * @returns the cached effect
  118948. */
  118949. getCachedEffect(): Nullable<Effect>;
  118950. /**
  118951. * Gets the cached visibility state (ie. the latest rendered one)
  118952. * @returns the cached visibility state
  118953. */
  118954. getCachedVisibility(): Nullable<number>;
  118955. /**
  118956. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  118957. * @param material defines the current material
  118958. * @param effect defines the current effect
  118959. * @param visibility defines the current visibility state
  118960. * @returns true if one parameter is not cached
  118961. */
  118962. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  118963. /**
  118964. * Gets the engine associated with the scene
  118965. * @returns an Engine
  118966. */
  118967. getEngine(): Engine;
  118968. /**
  118969. * Gets the total number of vertices rendered per frame
  118970. * @returns the total number of vertices rendered per frame
  118971. */
  118972. getTotalVertices(): number;
  118973. /**
  118974. * Gets the performance counter for total vertices
  118975. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118976. */
  118977. get totalVerticesPerfCounter(): PerfCounter;
  118978. /**
  118979. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  118980. * @returns the total number of active indices rendered per frame
  118981. */
  118982. getActiveIndices(): number;
  118983. /**
  118984. * Gets the performance counter for active indices
  118985. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118986. */
  118987. get totalActiveIndicesPerfCounter(): PerfCounter;
  118988. /**
  118989. * Gets the total number of active particles rendered per frame
  118990. * @returns the total number of active particles rendered per frame
  118991. */
  118992. getActiveParticles(): number;
  118993. /**
  118994. * Gets the performance counter for active particles
  118995. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118996. */
  118997. get activeParticlesPerfCounter(): PerfCounter;
  118998. /**
  118999. * Gets the total number of active bones rendered per frame
  119000. * @returns the total number of active bones rendered per frame
  119001. */
  119002. getActiveBones(): number;
  119003. /**
  119004. * Gets the performance counter for active bones
  119005. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119006. */
  119007. get activeBonesPerfCounter(): PerfCounter;
  119008. /**
  119009. * Gets the array of active meshes
  119010. * @returns an array of AbstractMesh
  119011. */
  119012. getActiveMeshes(): SmartArray<AbstractMesh>;
  119013. /**
  119014. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  119015. * @returns a number
  119016. */
  119017. getAnimationRatio(): number;
  119018. /**
  119019. * Gets an unique Id for the current render phase
  119020. * @returns a number
  119021. */
  119022. getRenderId(): number;
  119023. /**
  119024. * Gets an unique Id for the current frame
  119025. * @returns a number
  119026. */
  119027. getFrameId(): number;
  119028. /** Call this function if you want to manually increment the render Id*/
  119029. incrementRenderId(): void;
  119030. private _createUbo;
  119031. /**
  119032. * Use this method to simulate a pointer move on a mesh
  119033. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119034. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119035. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119036. * @returns the current scene
  119037. */
  119038. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119039. /**
  119040. * Use this method to simulate a pointer down on a mesh
  119041. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119042. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119043. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119044. * @returns the current scene
  119045. */
  119046. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119047. /**
  119048. * Use this method to simulate a pointer up on a mesh
  119049. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119050. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119051. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119052. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119053. * @returns the current scene
  119054. */
  119055. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  119056. /**
  119057. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119058. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119059. * @returns true if the pointer was captured
  119060. */
  119061. isPointerCaptured(pointerId?: number): boolean;
  119062. /**
  119063. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119064. * @param attachUp defines if you want to attach events to pointerup
  119065. * @param attachDown defines if you want to attach events to pointerdown
  119066. * @param attachMove defines if you want to attach events to pointermove
  119067. */
  119068. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  119069. /** Detaches all event handlers*/
  119070. detachControl(): void;
  119071. /**
  119072. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  119073. * Delay loaded resources are not taking in account
  119074. * @return true if all required resources are ready
  119075. */
  119076. isReady(): boolean;
  119077. /** Resets all cached information relative to material (including effect and visibility) */
  119078. resetCachedMaterial(): void;
  119079. /**
  119080. * Registers a function to be called before every frame render
  119081. * @param func defines the function to register
  119082. */
  119083. registerBeforeRender(func: () => void): void;
  119084. /**
  119085. * Unregisters a function called before every frame render
  119086. * @param func defines the function to unregister
  119087. */
  119088. unregisterBeforeRender(func: () => void): void;
  119089. /**
  119090. * Registers a function to be called after every frame render
  119091. * @param func defines the function to register
  119092. */
  119093. registerAfterRender(func: () => void): void;
  119094. /**
  119095. * Unregisters a function called after every frame render
  119096. * @param func defines the function to unregister
  119097. */
  119098. unregisterAfterRender(func: () => void): void;
  119099. private _executeOnceBeforeRender;
  119100. /**
  119101. * The provided function will run before render once and will be disposed afterwards.
  119102. * A timeout delay can be provided so that the function will be executed in N ms.
  119103. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  119104. * @param func The function to be executed.
  119105. * @param timeout optional delay in ms
  119106. */
  119107. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  119108. /** @hidden */
  119109. _addPendingData(data: any): void;
  119110. /** @hidden */
  119111. _removePendingData(data: any): void;
  119112. /**
  119113. * Returns the number of items waiting to be loaded
  119114. * @returns the number of items waiting to be loaded
  119115. */
  119116. getWaitingItemsCount(): number;
  119117. /**
  119118. * Returns a boolean indicating if the scene is still loading data
  119119. */
  119120. get isLoading(): boolean;
  119121. /**
  119122. * Registers a function to be executed when the scene is ready
  119123. * @param {Function} func - the function to be executed
  119124. */
  119125. executeWhenReady(func: () => void): void;
  119126. /**
  119127. * Returns a promise that resolves when the scene is ready
  119128. * @returns A promise that resolves when the scene is ready
  119129. */
  119130. whenReadyAsync(): Promise<void>;
  119131. /** @hidden */
  119132. _checkIsReady(): void;
  119133. /**
  119134. * Gets all animatable attached to the scene
  119135. */
  119136. get animatables(): Animatable[];
  119137. /**
  119138. * Resets the last animation time frame.
  119139. * Useful to override when animations start running when loading a scene for the first time.
  119140. */
  119141. resetLastAnimationTimeFrame(): void;
  119142. /**
  119143. * Gets the current view matrix
  119144. * @returns a Matrix
  119145. */
  119146. getViewMatrix(): Matrix;
  119147. /**
  119148. * Gets the current projection matrix
  119149. * @returns a Matrix
  119150. */
  119151. getProjectionMatrix(): Matrix;
  119152. /**
  119153. * Gets the current transform matrix
  119154. * @returns a Matrix made of View * Projection
  119155. */
  119156. getTransformMatrix(): Matrix;
  119157. /**
  119158. * Sets the current transform matrix
  119159. * @param viewL defines the View matrix to use
  119160. * @param projectionL defines the Projection matrix to use
  119161. * @param viewR defines the right View matrix to use (if provided)
  119162. * @param projectionR defines the right Projection matrix to use (if provided)
  119163. */
  119164. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  119165. /**
  119166. * Gets the uniform buffer used to store scene data
  119167. * @returns a UniformBuffer
  119168. */
  119169. getSceneUniformBuffer(): UniformBuffer;
  119170. /**
  119171. * Gets an unique (relatively to the current scene) Id
  119172. * @returns an unique number for the scene
  119173. */
  119174. getUniqueId(): number;
  119175. /**
  119176. * Add a mesh to the list of scene's meshes
  119177. * @param newMesh defines the mesh to add
  119178. * @param recursive if all child meshes should also be added to the scene
  119179. */
  119180. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  119181. /**
  119182. * Remove a mesh for the list of scene's meshes
  119183. * @param toRemove defines the mesh to remove
  119184. * @param recursive if all child meshes should also be removed from the scene
  119185. * @returns the index where the mesh was in the mesh list
  119186. */
  119187. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  119188. /**
  119189. * Add a transform node to the list of scene's transform nodes
  119190. * @param newTransformNode defines the transform node to add
  119191. */
  119192. addTransformNode(newTransformNode: TransformNode): void;
  119193. /**
  119194. * Remove a transform node for the list of scene's transform nodes
  119195. * @param toRemove defines the transform node to remove
  119196. * @returns the index where the transform node was in the transform node list
  119197. */
  119198. removeTransformNode(toRemove: TransformNode): number;
  119199. /**
  119200. * Remove a skeleton for the list of scene's skeletons
  119201. * @param toRemove defines the skeleton to remove
  119202. * @returns the index where the skeleton was in the skeleton list
  119203. */
  119204. removeSkeleton(toRemove: Skeleton): number;
  119205. /**
  119206. * Remove a morph target for the list of scene's morph targets
  119207. * @param toRemove defines the morph target to remove
  119208. * @returns the index where the morph target was in the morph target list
  119209. */
  119210. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  119211. /**
  119212. * Remove a light for the list of scene's lights
  119213. * @param toRemove defines the light to remove
  119214. * @returns the index where the light was in the light list
  119215. */
  119216. removeLight(toRemove: Light): number;
  119217. /**
  119218. * Remove a camera for the list of scene's cameras
  119219. * @param toRemove defines the camera to remove
  119220. * @returns the index where the camera was in the camera list
  119221. */
  119222. removeCamera(toRemove: Camera): number;
  119223. /**
  119224. * Remove a particle system for the list of scene's particle systems
  119225. * @param toRemove defines the particle system to remove
  119226. * @returns the index where the particle system was in the particle system list
  119227. */
  119228. removeParticleSystem(toRemove: IParticleSystem): number;
  119229. /**
  119230. * Remove a animation for the list of scene's animations
  119231. * @param toRemove defines the animation to remove
  119232. * @returns the index where the animation was in the animation list
  119233. */
  119234. removeAnimation(toRemove: Animation): number;
  119235. /**
  119236. * Will stop the animation of the given target
  119237. * @param target - the target
  119238. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  119239. * @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)
  119240. */
  119241. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  119242. /**
  119243. * Removes the given animation group from this scene.
  119244. * @param toRemove The animation group to remove
  119245. * @returns The index of the removed animation group
  119246. */
  119247. removeAnimationGroup(toRemove: AnimationGroup): number;
  119248. /**
  119249. * Removes the given multi-material from this scene.
  119250. * @param toRemove The multi-material to remove
  119251. * @returns The index of the removed multi-material
  119252. */
  119253. removeMultiMaterial(toRemove: MultiMaterial): number;
  119254. /**
  119255. * Removes the given material from this scene.
  119256. * @param toRemove The material to remove
  119257. * @returns The index of the removed material
  119258. */
  119259. removeMaterial(toRemove: Material): number;
  119260. /**
  119261. * Removes the given action manager from this scene.
  119262. * @param toRemove The action manager to remove
  119263. * @returns The index of the removed action manager
  119264. */
  119265. removeActionManager(toRemove: AbstractActionManager): number;
  119266. /**
  119267. * Removes the given texture from this scene.
  119268. * @param toRemove The texture to remove
  119269. * @returns The index of the removed texture
  119270. */
  119271. removeTexture(toRemove: BaseTexture): number;
  119272. /**
  119273. * Adds the given light to this scene
  119274. * @param newLight The light to add
  119275. */
  119276. addLight(newLight: Light): void;
  119277. /**
  119278. * Sorts the list list based on light priorities
  119279. */
  119280. sortLightsByPriority(): void;
  119281. /**
  119282. * Adds the given camera to this scene
  119283. * @param newCamera The camera to add
  119284. */
  119285. addCamera(newCamera: Camera): void;
  119286. /**
  119287. * Adds the given skeleton to this scene
  119288. * @param newSkeleton The skeleton to add
  119289. */
  119290. addSkeleton(newSkeleton: Skeleton): void;
  119291. /**
  119292. * Adds the given particle system to this scene
  119293. * @param newParticleSystem The particle system to add
  119294. */
  119295. addParticleSystem(newParticleSystem: IParticleSystem): void;
  119296. /**
  119297. * Adds the given animation to this scene
  119298. * @param newAnimation The animation to add
  119299. */
  119300. addAnimation(newAnimation: Animation): void;
  119301. /**
  119302. * Adds the given animation group to this scene.
  119303. * @param newAnimationGroup The animation group to add
  119304. */
  119305. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  119306. /**
  119307. * Adds the given multi-material to this scene
  119308. * @param newMultiMaterial The multi-material to add
  119309. */
  119310. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  119311. /**
  119312. * Adds the given material to this scene
  119313. * @param newMaterial The material to add
  119314. */
  119315. addMaterial(newMaterial: Material): void;
  119316. /**
  119317. * Adds the given morph target to this scene
  119318. * @param newMorphTargetManager The morph target to add
  119319. */
  119320. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  119321. /**
  119322. * Adds the given geometry to this scene
  119323. * @param newGeometry The geometry to add
  119324. */
  119325. addGeometry(newGeometry: Geometry): void;
  119326. /**
  119327. * Adds the given action manager to this scene
  119328. * @param newActionManager The action manager to add
  119329. */
  119330. addActionManager(newActionManager: AbstractActionManager): void;
  119331. /**
  119332. * Adds the given texture to this scene.
  119333. * @param newTexture The texture to add
  119334. */
  119335. addTexture(newTexture: BaseTexture): void;
  119336. /**
  119337. * Switch active camera
  119338. * @param newCamera defines the new active camera
  119339. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  119340. */
  119341. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  119342. /**
  119343. * sets the active camera of the scene using its ID
  119344. * @param id defines the camera's ID
  119345. * @return the new active camera or null if none found.
  119346. */
  119347. setActiveCameraByID(id: string): Nullable<Camera>;
  119348. /**
  119349. * sets the active camera of the scene using its name
  119350. * @param name defines the camera's name
  119351. * @returns the new active camera or null if none found.
  119352. */
  119353. setActiveCameraByName(name: string): Nullable<Camera>;
  119354. /**
  119355. * get an animation group using its name
  119356. * @param name defines the material's name
  119357. * @return the animation group or null if none found.
  119358. */
  119359. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  119360. /**
  119361. * Get a material using its unique id
  119362. * @param uniqueId defines the material's unique id
  119363. * @return the material or null if none found.
  119364. */
  119365. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  119366. /**
  119367. * get a material using its id
  119368. * @param id defines the material's ID
  119369. * @return the material or null if none found.
  119370. */
  119371. getMaterialByID(id: string): Nullable<Material>;
  119372. /**
  119373. * Gets a the last added material using a given id
  119374. * @param id defines the material's ID
  119375. * @return the last material with the given id or null if none found.
  119376. */
  119377. getLastMaterialByID(id: string): Nullable<Material>;
  119378. /**
  119379. * Gets a material using its name
  119380. * @param name defines the material's name
  119381. * @return the material or null if none found.
  119382. */
  119383. getMaterialByName(name: string): Nullable<Material>;
  119384. /**
  119385. * Get a texture using its unique id
  119386. * @param uniqueId defines the texture's unique id
  119387. * @return the texture or null if none found.
  119388. */
  119389. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119390. /**
  119391. * Gets a camera using its id
  119392. * @param id defines the id to look for
  119393. * @returns the camera or null if not found
  119394. */
  119395. getCameraByID(id: string): Nullable<Camera>;
  119396. /**
  119397. * Gets a camera using its unique id
  119398. * @param uniqueId defines the unique id to look for
  119399. * @returns the camera or null if not found
  119400. */
  119401. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119402. /**
  119403. * Gets a camera using its name
  119404. * @param name defines the camera's name
  119405. * @return the camera or null if none found.
  119406. */
  119407. getCameraByName(name: string): Nullable<Camera>;
  119408. /**
  119409. * Gets a bone using its id
  119410. * @param id defines the bone's id
  119411. * @return the bone or null if not found
  119412. */
  119413. getBoneByID(id: string): Nullable<Bone>;
  119414. /**
  119415. * Gets a bone using its id
  119416. * @param name defines the bone's name
  119417. * @return the bone or null if not found
  119418. */
  119419. getBoneByName(name: string): Nullable<Bone>;
  119420. /**
  119421. * Gets a light node using its name
  119422. * @param name defines the the light's name
  119423. * @return the light or null if none found.
  119424. */
  119425. getLightByName(name: string): Nullable<Light>;
  119426. /**
  119427. * Gets a light node using its id
  119428. * @param id defines the light's id
  119429. * @return the light or null if none found.
  119430. */
  119431. getLightByID(id: string): Nullable<Light>;
  119432. /**
  119433. * Gets a light node using its scene-generated unique ID
  119434. * @param uniqueId defines the light's unique id
  119435. * @return the light or null if none found.
  119436. */
  119437. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119438. /**
  119439. * Gets a particle system by id
  119440. * @param id defines the particle system id
  119441. * @return the corresponding system or null if none found
  119442. */
  119443. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119444. /**
  119445. * Gets a geometry using its ID
  119446. * @param id defines the geometry's id
  119447. * @return the geometry or null if none found.
  119448. */
  119449. getGeometryByID(id: string): Nullable<Geometry>;
  119450. private _getGeometryByUniqueID;
  119451. /**
  119452. * Add a new geometry to this scene
  119453. * @param geometry defines the geometry to be added to the scene.
  119454. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119455. * @return a boolean defining if the geometry was added or not
  119456. */
  119457. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119458. /**
  119459. * Removes an existing geometry
  119460. * @param geometry defines the geometry to be removed from the scene
  119461. * @return a boolean defining if the geometry was removed or not
  119462. */
  119463. removeGeometry(geometry: Geometry): boolean;
  119464. /**
  119465. * Gets the list of geometries attached to the scene
  119466. * @returns an array of Geometry
  119467. */
  119468. getGeometries(): Geometry[];
  119469. /**
  119470. * Gets the first added mesh found of a given ID
  119471. * @param id defines the id to search for
  119472. * @return the mesh found or null if not found at all
  119473. */
  119474. getMeshByID(id: string): Nullable<AbstractMesh>;
  119475. /**
  119476. * Gets a list of meshes using their id
  119477. * @param id defines the id to search for
  119478. * @returns a list of meshes
  119479. */
  119480. getMeshesByID(id: string): Array<AbstractMesh>;
  119481. /**
  119482. * Gets the first added transform node found of a given ID
  119483. * @param id defines the id to search for
  119484. * @return the found transform node or null if not found at all.
  119485. */
  119486. getTransformNodeByID(id: string): Nullable<TransformNode>;
  119487. /**
  119488. * Gets a transform node with its auto-generated unique id
  119489. * @param uniqueId efines the unique id to search for
  119490. * @return the found transform node or null if not found at all.
  119491. */
  119492. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  119493. /**
  119494. * Gets a list of transform nodes using their id
  119495. * @param id defines the id to search for
  119496. * @returns a list of transform nodes
  119497. */
  119498. getTransformNodesByID(id: string): Array<TransformNode>;
  119499. /**
  119500. * Gets a mesh with its auto-generated unique id
  119501. * @param uniqueId defines the unique id to search for
  119502. * @return the found mesh or null if not found at all.
  119503. */
  119504. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  119505. /**
  119506. * Gets a the last added mesh using a given id
  119507. * @param id defines the id to search for
  119508. * @return the found mesh or null if not found at all.
  119509. */
  119510. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  119511. /**
  119512. * Gets a the last added node (Mesh, Camera, Light) using a given id
  119513. * @param id defines the id to search for
  119514. * @return the found node or null if not found at all
  119515. */
  119516. getLastEntryByID(id: string): Nullable<Node>;
  119517. /**
  119518. * Gets a node (Mesh, Camera, Light) using a given id
  119519. * @param id defines the id to search for
  119520. * @return the found node or null if not found at all
  119521. */
  119522. getNodeByID(id: string): Nullable<Node>;
  119523. /**
  119524. * Gets a node (Mesh, Camera, Light) using a given name
  119525. * @param name defines the name to search for
  119526. * @return the found node or null if not found at all.
  119527. */
  119528. getNodeByName(name: string): Nullable<Node>;
  119529. /**
  119530. * Gets a mesh using a given name
  119531. * @param name defines the name to search for
  119532. * @return the found mesh or null if not found at all.
  119533. */
  119534. getMeshByName(name: string): Nullable<AbstractMesh>;
  119535. /**
  119536. * Gets a transform node using a given name
  119537. * @param name defines the name to search for
  119538. * @return the found transform node or null if not found at all.
  119539. */
  119540. getTransformNodeByName(name: string): Nullable<TransformNode>;
  119541. /**
  119542. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  119543. * @param id defines the id to search for
  119544. * @return the found skeleton or null if not found at all.
  119545. */
  119546. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  119547. /**
  119548. * Gets a skeleton using a given auto generated unique id
  119549. * @param uniqueId defines the unique id to search for
  119550. * @return the found skeleton or null if not found at all.
  119551. */
  119552. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  119553. /**
  119554. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  119555. * @param id defines the id to search for
  119556. * @return the found skeleton or null if not found at all.
  119557. */
  119558. getSkeletonById(id: string): Nullable<Skeleton>;
  119559. /**
  119560. * Gets a skeleton using a given name
  119561. * @param name defines the name to search for
  119562. * @return the found skeleton or null if not found at all.
  119563. */
  119564. getSkeletonByName(name: string): Nullable<Skeleton>;
  119565. /**
  119566. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  119567. * @param id defines the id to search for
  119568. * @return the found morph target manager or null if not found at all.
  119569. */
  119570. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  119571. /**
  119572. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  119573. * @param id defines the id to search for
  119574. * @return the found morph target or null if not found at all.
  119575. */
  119576. getMorphTargetById(id: string): Nullable<MorphTarget>;
  119577. /**
  119578. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  119579. * @param name defines the name to search for
  119580. * @return the found morph target or null if not found at all.
  119581. */
  119582. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  119583. /**
  119584. * Gets a boolean indicating if the given mesh is active
  119585. * @param mesh defines the mesh to look for
  119586. * @returns true if the mesh is in the active list
  119587. */
  119588. isActiveMesh(mesh: AbstractMesh): boolean;
  119589. /**
  119590. * Return a unique id as a string which can serve as an identifier for the scene
  119591. */
  119592. get uid(): string;
  119593. /**
  119594. * Add an externaly attached data from its key.
  119595. * This method call will fail and return false, if such key already exists.
  119596. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  119597. * @param key the unique key that identifies the data
  119598. * @param data the data object to associate to the key for this Engine instance
  119599. * @return true if no such key were already present and the data was added successfully, false otherwise
  119600. */
  119601. addExternalData<T>(key: string, data: T): boolean;
  119602. /**
  119603. * Get an externaly attached data from its key
  119604. * @param key the unique key that identifies the data
  119605. * @return the associated data, if present (can be null), or undefined if not present
  119606. */
  119607. getExternalData<T>(key: string): Nullable<T>;
  119608. /**
  119609. * Get an externaly attached data from its key, create it using a factory if it's not already present
  119610. * @param key the unique key that identifies the data
  119611. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  119612. * @return the associated data, can be null if the factory returned null.
  119613. */
  119614. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  119615. /**
  119616. * Remove an externaly attached data from the Engine instance
  119617. * @param key the unique key that identifies the data
  119618. * @return true if the data was successfully removed, false if it doesn't exist
  119619. */
  119620. removeExternalData(key: string): boolean;
  119621. private _evaluateSubMesh;
  119622. /**
  119623. * Clear the processed materials smart array preventing retention point in material dispose.
  119624. */
  119625. freeProcessedMaterials(): void;
  119626. private _preventFreeActiveMeshesAndRenderingGroups;
  119627. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  119628. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  119629. * when disposing several meshes in a row or a hierarchy of meshes.
  119630. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  119631. */
  119632. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  119633. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  119634. /**
  119635. * Clear the active meshes smart array preventing retention point in mesh dispose.
  119636. */
  119637. freeActiveMeshes(): void;
  119638. /**
  119639. * Clear the info related to rendering groups preventing retention points during dispose.
  119640. */
  119641. freeRenderingGroups(): void;
  119642. /** @hidden */
  119643. _isInIntermediateRendering(): boolean;
  119644. /**
  119645. * Lambda returning the list of potentially active meshes.
  119646. */
  119647. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  119648. /**
  119649. * Lambda returning the list of potentially active sub meshes.
  119650. */
  119651. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  119652. /**
  119653. * Lambda returning the list of potentially intersecting sub meshes.
  119654. */
  119655. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  119656. /**
  119657. * Lambda returning the list of potentially colliding sub meshes.
  119658. */
  119659. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  119660. private _activeMeshesFrozen;
  119661. private _skipEvaluateActiveMeshesCompletely;
  119662. /**
  119663. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  119664. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  119665. * @returns the current scene
  119666. */
  119667. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  119668. /**
  119669. * Use this function to restart evaluating active meshes on every frame
  119670. * @returns the current scene
  119671. */
  119672. unfreezeActiveMeshes(): Scene;
  119673. private _evaluateActiveMeshes;
  119674. private _activeMesh;
  119675. /**
  119676. * Update the transform matrix to update from the current active camera
  119677. * @param force defines a boolean used to force the update even if cache is up to date
  119678. */
  119679. updateTransformMatrix(force?: boolean): void;
  119680. private _bindFrameBuffer;
  119681. /** @hidden */
  119682. _allowPostProcessClearColor: boolean;
  119683. /** @hidden */
  119684. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  119685. private _processSubCameras;
  119686. private _checkIntersections;
  119687. /** @hidden */
  119688. _advancePhysicsEngineStep(step: number): void;
  119689. /**
  119690. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  119691. */
  119692. getDeterministicFrameTime: () => number;
  119693. /** @hidden */
  119694. _animate(): void;
  119695. /** Execute all animations (for a frame) */
  119696. animate(): void;
  119697. /**
  119698. * Render the scene
  119699. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  119700. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  119701. */
  119702. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  119703. /**
  119704. * Freeze all materials
  119705. * A frozen material will not be updatable but should be faster to render
  119706. */
  119707. freezeMaterials(): void;
  119708. /**
  119709. * Unfreeze all materials
  119710. * A frozen material will not be updatable but should be faster to render
  119711. */
  119712. unfreezeMaterials(): void;
  119713. /**
  119714. * Releases all held ressources
  119715. */
  119716. dispose(): void;
  119717. /**
  119718. * Gets if the scene is already disposed
  119719. */
  119720. get isDisposed(): boolean;
  119721. /**
  119722. * Call this function to reduce memory footprint of the scene.
  119723. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  119724. */
  119725. clearCachedVertexData(): void;
  119726. /**
  119727. * This function will remove the local cached buffer data from texture.
  119728. * It will save memory but will prevent the texture from being rebuilt
  119729. */
  119730. cleanCachedTextureBuffer(): void;
  119731. /**
  119732. * Get the world extend vectors with an optional filter
  119733. *
  119734. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  119735. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  119736. */
  119737. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  119738. min: Vector3;
  119739. max: Vector3;
  119740. };
  119741. /**
  119742. * Creates a ray that can be used to pick in the scene
  119743. * @param x defines the x coordinate of the origin (on-screen)
  119744. * @param y defines the y coordinate of the origin (on-screen)
  119745. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119746. * @param camera defines the camera to use for the picking
  119747. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119748. * @returns a Ray
  119749. */
  119750. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  119751. /**
  119752. * Creates a ray that can be used to pick in the scene
  119753. * @param x defines the x coordinate of the origin (on-screen)
  119754. * @param y defines the y coordinate of the origin (on-screen)
  119755. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119756. * @param result defines the ray where to store the picking ray
  119757. * @param camera defines the camera to use for the picking
  119758. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119759. * @returns the current scene
  119760. */
  119761. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  119762. /**
  119763. * Creates a ray that can be used to pick in the scene
  119764. * @param x defines the x coordinate of the origin (on-screen)
  119765. * @param y defines the y coordinate of the origin (on-screen)
  119766. * @param camera defines the camera to use for the picking
  119767. * @returns a Ray
  119768. */
  119769. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  119770. /**
  119771. * Creates a ray that can be used to pick in the scene
  119772. * @param x defines the x coordinate of the origin (on-screen)
  119773. * @param y defines the y coordinate of the origin (on-screen)
  119774. * @param result defines the ray where to store the picking ray
  119775. * @param camera defines the camera to use for the picking
  119776. * @returns the current scene
  119777. */
  119778. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  119779. /** Launch a ray to try to pick a mesh in the scene
  119780. * @param x position on screen
  119781. * @param y position on screen
  119782. * @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
  119783. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119784. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119785. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119786. * @returns a PickingInfo
  119787. */
  119788. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119789. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  119790. * @param x position on screen
  119791. * @param y position on screen
  119792. * @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
  119793. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119794. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119795. * @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)
  119796. */
  119797. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  119798. /** Use the given ray to pick a mesh in the scene
  119799. * @param ray The ray to use to pick meshes
  119800. * @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
  119801. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119802. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119803. * @returns a PickingInfo
  119804. */
  119805. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119806. /**
  119807. * Launch a ray to try to pick a mesh in the scene
  119808. * @param x X position on screen
  119809. * @param y Y position on screen
  119810. * @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
  119811. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119812. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119813. * @returns an array of PickingInfo
  119814. */
  119815. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119816. /**
  119817. * Launch a ray to try to pick a mesh in the scene
  119818. * @param ray Ray to use
  119819. * @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
  119820. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119821. * @returns an array of PickingInfo
  119822. */
  119823. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119824. /**
  119825. * Force the value of meshUnderPointer
  119826. * @param mesh defines the mesh to use
  119827. */
  119828. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  119829. /**
  119830. * Gets the mesh under the pointer
  119831. * @returns a Mesh or null if no mesh is under the pointer
  119832. */
  119833. getPointerOverMesh(): Nullable<AbstractMesh>;
  119834. /** @hidden */
  119835. _rebuildGeometries(): void;
  119836. /** @hidden */
  119837. _rebuildTextures(): void;
  119838. private _getByTags;
  119839. /**
  119840. * Get a list of meshes by tags
  119841. * @param tagsQuery defines the tags query to use
  119842. * @param forEach defines a predicate used to filter results
  119843. * @returns an array of Mesh
  119844. */
  119845. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  119846. /**
  119847. * Get a list of cameras by tags
  119848. * @param tagsQuery defines the tags query to use
  119849. * @param forEach defines a predicate used to filter results
  119850. * @returns an array of Camera
  119851. */
  119852. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  119853. /**
  119854. * Get a list of lights by tags
  119855. * @param tagsQuery defines the tags query to use
  119856. * @param forEach defines a predicate used to filter results
  119857. * @returns an array of Light
  119858. */
  119859. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  119860. /**
  119861. * Get a list of materials by tags
  119862. * @param tagsQuery defines the tags query to use
  119863. * @param forEach defines a predicate used to filter results
  119864. * @returns an array of Material
  119865. */
  119866. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  119867. /**
  119868. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119869. * This allowed control for front to back rendering or reversly depending of the special needs.
  119870. *
  119871. * @param renderingGroupId The rendering group id corresponding to its index
  119872. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119873. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119874. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119875. */
  119876. 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;
  119877. /**
  119878. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119879. *
  119880. * @param renderingGroupId The rendering group id corresponding to its index
  119881. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119882. * @param depth Automatically clears depth between groups if true and autoClear is true.
  119883. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  119884. */
  119885. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  119886. /**
  119887. * Gets the current auto clear configuration for one rendering group of the rendering
  119888. * manager.
  119889. * @param index the rendering group index to get the information for
  119890. * @returns The auto clear setup for the requested rendering group
  119891. */
  119892. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  119893. private _blockMaterialDirtyMechanism;
  119894. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  119895. get blockMaterialDirtyMechanism(): boolean;
  119896. set blockMaterialDirtyMechanism(value: boolean);
  119897. /**
  119898. * Will flag all materials as dirty to trigger new shader compilation
  119899. * @param flag defines the flag used to specify which material part must be marked as dirty
  119900. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  119901. */
  119902. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  119903. /** @hidden */
  119904. _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;
  119905. /** @hidden */
  119906. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119907. /** @hidden */
  119908. _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;
  119909. /** @hidden */
  119910. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  119911. /** @hidden */
  119912. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  119913. /** @hidden */
  119914. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119915. }
  119916. }
  119917. declare module BABYLON {
  119918. /**
  119919. * Set of assets to keep when moving a scene into an asset container.
  119920. */
  119921. export class KeepAssets extends AbstractScene {
  119922. }
  119923. /**
  119924. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  119925. */
  119926. export class InstantiatedEntries {
  119927. /**
  119928. * List of new root nodes (eg. nodes with no parent)
  119929. */
  119930. rootNodes: TransformNode[];
  119931. /**
  119932. * List of new skeletons
  119933. */
  119934. skeletons: Skeleton[];
  119935. /**
  119936. * List of new animation groups
  119937. */
  119938. animationGroups: AnimationGroup[];
  119939. }
  119940. /**
  119941. * Container with a set of assets that can be added or removed from a scene.
  119942. */
  119943. export class AssetContainer extends AbstractScene {
  119944. private _wasAddedToScene;
  119945. /**
  119946. * The scene the AssetContainer belongs to.
  119947. */
  119948. scene: Scene;
  119949. /**
  119950. * Instantiates an AssetContainer.
  119951. * @param scene The scene the AssetContainer belongs to.
  119952. */
  119953. constructor(scene: Scene);
  119954. /**
  119955. * Instantiate or clone all meshes and add the new ones to the scene.
  119956. * Skeletons and animation groups will all be cloned
  119957. * @param nameFunction defines an optional function used to get new names for clones
  119958. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  119959. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  119960. */
  119961. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  119962. /**
  119963. * Adds all the assets from the container to the scene.
  119964. */
  119965. addAllToScene(): void;
  119966. /**
  119967. * Removes all the assets in the container from the scene
  119968. */
  119969. removeAllFromScene(): void;
  119970. /**
  119971. * Disposes all the assets in the container
  119972. */
  119973. dispose(): void;
  119974. private _moveAssets;
  119975. /**
  119976. * Removes all the assets contained in the scene and adds them to the container.
  119977. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  119978. */
  119979. moveAllFromScene(keepAssets?: KeepAssets): void;
  119980. /**
  119981. * 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.
  119982. * @returns the root mesh
  119983. */
  119984. createRootMesh(): Mesh;
  119985. /**
  119986. * Merge animations (direct and animation groups) from this asset container into a scene
  119987. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119988. * @param animatables set of animatables to retarget to a node from the scene
  119989. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  119990. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  119991. */
  119992. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  119993. }
  119994. }
  119995. declare module BABYLON {
  119996. /**
  119997. * Defines how the parser contract is defined.
  119998. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  119999. */
  120000. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  120001. /**
  120002. * Defines how the individual parser contract is defined.
  120003. * These parser can parse an individual asset
  120004. */
  120005. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  120006. /**
  120007. * Base class of the scene acting as a container for the different elements composing a scene.
  120008. * This class is dynamically extended by the different components of the scene increasing
  120009. * flexibility and reducing coupling
  120010. */
  120011. export abstract class AbstractScene {
  120012. /**
  120013. * Stores the list of available parsers in the application.
  120014. */
  120015. private static _BabylonFileParsers;
  120016. /**
  120017. * Stores the list of available individual parsers in the application.
  120018. */
  120019. private static _IndividualBabylonFileParsers;
  120020. /**
  120021. * Adds a parser in the list of available ones
  120022. * @param name Defines the name of the parser
  120023. * @param parser Defines the parser to add
  120024. */
  120025. static AddParser(name: string, parser: BabylonFileParser): void;
  120026. /**
  120027. * Gets a general parser from the list of avaialble ones
  120028. * @param name Defines the name of the parser
  120029. * @returns the requested parser or null
  120030. */
  120031. static GetParser(name: string): Nullable<BabylonFileParser>;
  120032. /**
  120033. * Adds n individual parser in the list of available ones
  120034. * @param name Defines the name of the parser
  120035. * @param parser Defines the parser to add
  120036. */
  120037. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  120038. /**
  120039. * Gets an individual parser from the list of avaialble ones
  120040. * @param name Defines the name of the parser
  120041. * @returns the requested parser or null
  120042. */
  120043. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  120044. /**
  120045. * Parser json data and populate both a scene and its associated container object
  120046. * @param jsonData Defines the data to parse
  120047. * @param scene Defines the scene to parse the data for
  120048. * @param container Defines the container attached to the parsing sequence
  120049. * @param rootUrl Defines the root url of the data
  120050. */
  120051. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  120052. /**
  120053. * Gets the list of root nodes (ie. nodes with no parent)
  120054. */
  120055. rootNodes: Node[];
  120056. /** All of the cameras added to this scene
  120057. * @see https://doc.babylonjs.com/babylon101/cameras
  120058. */
  120059. cameras: Camera[];
  120060. /**
  120061. * All of the lights added to this scene
  120062. * @see https://doc.babylonjs.com/babylon101/lights
  120063. */
  120064. lights: Light[];
  120065. /**
  120066. * All of the (abstract) meshes added to this scene
  120067. */
  120068. meshes: AbstractMesh[];
  120069. /**
  120070. * The list of skeletons added to the scene
  120071. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120072. */
  120073. skeletons: Skeleton[];
  120074. /**
  120075. * All of the particle systems added to this scene
  120076. * @see https://doc.babylonjs.com/babylon101/particles
  120077. */
  120078. particleSystems: IParticleSystem[];
  120079. /**
  120080. * Gets a list of Animations associated with the scene
  120081. */
  120082. animations: Animation[];
  120083. /**
  120084. * All of the animation groups added to this scene
  120085. * @see https://doc.babylonjs.com/how_to/group
  120086. */
  120087. animationGroups: AnimationGroup[];
  120088. /**
  120089. * All of the multi-materials added to this scene
  120090. * @see https://doc.babylonjs.com/how_to/multi_materials
  120091. */
  120092. multiMaterials: MultiMaterial[];
  120093. /**
  120094. * All of the materials added to this scene
  120095. * In the context of a Scene, it is not supposed to be modified manually.
  120096. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  120097. * Note also that the order of the Material within the array is not significant and might change.
  120098. * @see https://doc.babylonjs.com/babylon101/materials
  120099. */
  120100. materials: Material[];
  120101. /**
  120102. * The list of morph target managers added to the scene
  120103. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  120104. */
  120105. morphTargetManagers: MorphTargetManager[];
  120106. /**
  120107. * The list of geometries used in the scene.
  120108. */
  120109. geometries: Geometry[];
  120110. /**
  120111. * All of the tranform nodes added to this scene
  120112. * In the context of a Scene, it is not supposed to be modified manually.
  120113. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120114. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  120115. * @see https://doc.babylonjs.com/how_to/transformnode
  120116. */
  120117. transformNodes: TransformNode[];
  120118. /**
  120119. * ActionManagers available on the scene.
  120120. */
  120121. actionManagers: AbstractActionManager[];
  120122. /**
  120123. * Textures to keep.
  120124. */
  120125. textures: BaseTexture[];
  120126. /**
  120127. * Environment texture for the scene
  120128. */
  120129. environmentTexture: Nullable<BaseTexture>;
  120130. /**
  120131. * @returns all meshes, lights, cameras, transformNodes and bones
  120132. */
  120133. getNodes(): Array<Node>;
  120134. }
  120135. }
  120136. declare module BABYLON {
  120137. /**
  120138. * Interface used to define options for Sound class
  120139. */
  120140. export interface ISoundOptions {
  120141. /**
  120142. * Does the sound autoplay once loaded.
  120143. */
  120144. autoplay?: boolean;
  120145. /**
  120146. * Does the sound loop after it finishes playing once.
  120147. */
  120148. loop?: boolean;
  120149. /**
  120150. * Sound's volume
  120151. */
  120152. volume?: number;
  120153. /**
  120154. * Is it a spatial sound?
  120155. */
  120156. spatialSound?: boolean;
  120157. /**
  120158. * Maximum distance to hear that sound
  120159. */
  120160. maxDistance?: number;
  120161. /**
  120162. * Uses user defined attenuation function
  120163. */
  120164. useCustomAttenuation?: boolean;
  120165. /**
  120166. * Define the roll off factor of spatial sounds.
  120167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120168. */
  120169. rolloffFactor?: number;
  120170. /**
  120171. * Define the reference distance the sound should be heard perfectly.
  120172. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120173. */
  120174. refDistance?: number;
  120175. /**
  120176. * Define the distance attenuation model the sound will follow.
  120177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120178. */
  120179. distanceModel?: string;
  120180. /**
  120181. * Defines the playback speed (1 by default)
  120182. */
  120183. playbackRate?: number;
  120184. /**
  120185. * Defines if the sound is from a streaming source
  120186. */
  120187. streaming?: boolean;
  120188. /**
  120189. * Defines an optional length (in seconds) inside the sound file
  120190. */
  120191. length?: number;
  120192. /**
  120193. * Defines an optional offset (in seconds) inside the sound file
  120194. */
  120195. offset?: number;
  120196. /**
  120197. * If true, URLs will not be required to state the audio file codec to use.
  120198. */
  120199. skipCodecCheck?: boolean;
  120200. }
  120201. /**
  120202. * Defines a sound that can be played in the application.
  120203. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  120204. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120205. */
  120206. export class Sound {
  120207. /**
  120208. * The name of the sound in the scene.
  120209. */
  120210. name: string;
  120211. /**
  120212. * Does the sound autoplay once loaded.
  120213. */
  120214. autoplay: boolean;
  120215. /**
  120216. * Does the sound loop after it finishes playing once.
  120217. */
  120218. loop: boolean;
  120219. /**
  120220. * Does the sound use a custom attenuation curve to simulate the falloff
  120221. * happening when the source gets further away from the camera.
  120222. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120223. */
  120224. useCustomAttenuation: boolean;
  120225. /**
  120226. * The sound track id this sound belongs to.
  120227. */
  120228. soundTrackId: number;
  120229. /**
  120230. * Is this sound currently played.
  120231. */
  120232. isPlaying: boolean;
  120233. /**
  120234. * Is this sound currently paused.
  120235. */
  120236. isPaused: boolean;
  120237. /**
  120238. * Does this sound enables spatial sound.
  120239. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120240. */
  120241. spatialSound: boolean;
  120242. /**
  120243. * Define the reference distance the sound should be heard perfectly.
  120244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120245. */
  120246. refDistance: number;
  120247. /**
  120248. * Define the roll off factor of spatial sounds.
  120249. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120250. */
  120251. rolloffFactor: number;
  120252. /**
  120253. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  120254. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120255. */
  120256. maxDistance: number;
  120257. /**
  120258. * Define the distance attenuation model the sound will follow.
  120259. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120260. */
  120261. distanceModel: string;
  120262. /**
  120263. * @hidden
  120264. * Back Compat
  120265. **/
  120266. onended: () => any;
  120267. /**
  120268. * Gets or sets an object used to store user defined information for the sound.
  120269. */
  120270. metadata: any;
  120271. /**
  120272. * Observable event when the current playing sound finishes.
  120273. */
  120274. onEndedObservable: Observable<Sound>;
  120275. private _panningModel;
  120276. private _playbackRate;
  120277. private _streaming;
  120278. private _startTime;
  120279. private _startOffset;
  120280. private _position;
  120281. /** @hidden */
  120282. _positionInEmitterSpace: boolean;
  120283. private _localDirection;
  120284. private _volume;
  120285. private _isReadyToPlay;
  120286. private _isDirectional;
  120287. private _readyToPlayCallback;
  120288. private _audioBuffer;
  120289. private _soundSource;
  120290. private _streamingSource;
  120291. private _soundPanner;
  120292. private _soundGain;
  120293. private _inputAudioNode;
  120294. private _outputAudioNode;
  120295. private _coneInnerAngle;
  120296. private _coneOuterAngle;
  120297. private _coneOuterGain;
  120298. private _scene;
  120299. private _connectedTransformNode;
  120300. private _customAttenuationFunction;
  120301. private _registerFunc;
  120302. private _isOutputConnected;
  120303. private _htmlAudioElement;
  120304. private _urlType;
  120305. private _length?;
  120306. private _offset?;
  120307. /** @hidden */
  120308. static _SceneComponentInitialization: (scene: Scene) => void;
  120309. /**
  120310. * Create a sound and attach it to a scene
  120311. * @param name Name of your sound
  120312. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  120313. * @param scene defines the scene the sound belongs to
  120314. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  120315. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  120316. */
  120317. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  120318. /**
  120319. * Release the sound and its associated resources
  120320. */
  120321. dispose(): void;
  120322. /**
  120323. * Gets if the sounds is ready to be played or not.
  120324. * @returns true if ready, otherwise false
  120325. */
  120326. isReady(): boolean;
  120327. private _soundLoaded;
  120328. /**
  120329. * Sets the data of the sound from an audiobuffer
  120330. * @param audioBuffer The audioBuffer containing the data
  120331. */
  120332. setAudioBuffer(audioBuffer: AudioBuffer): void;
  120333. /**
  120334. * Updates the current sounds options such as maxdistance, loop...
  120335. * @param options A JSON object containing values named as the object properties
  120336. */
  120337. updateOptions(options: ISoundOptions): void;
  120338. private _createSpatialParameters;
  120339. private _updateSpatialParameters;
  120340. /**
  120341. * Switch the panning model to HRTF:
  120342. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120344. */
  120345. switchPanningModelToHRTF(): void;
  120346. /**
  120347. * Switch the panning model to Equal Power:
  120348. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120349. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120350. */
  120351. switchPanningModelToEqualPower(): void;
  120352. private _switchPanningModel;
  120353. /**
  120354. * Connect this sound to a sound track audio node like gain...
  120355. * @param soundTrackAudioNode the sound track audio node to connect to
  120356. */
  120357. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  120358. /**
  120359. * Transform this sound into a directional source
  120360. * @param coneInnerAngle Size of the inner cone in degree
  120361. * @param coneOuterAngle Size of the outer cone in degree
  120362. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  120363. */
  120364. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  120365. /**
  120366. * Gets or sets the inner angle for the directional cone.
  120367. */
  120368. get directionalConeInnerAngle(): number;
  120369. /**
  120370. * Gets or sets the inner angle for the directional cone.
  120371. */
  120372. set directionalConeInnerAngle(value: number);
  120373. /**
  120374. * Gets or sets the outer angle for the directional cone.
  120375. */
  120376. get directionalConeOuterAngle(): number;
  120377. /**
  120378. * Gets or sets the outer angle for the directional cone.
  120379. */
  120380. set directionalConeOuterAngle(value: number);
  120381. /**
  120382. * Sets the position of the emitter if spatial sound is enabled
  120383. * @param newPosition Defines the new posisiton
  120384. */
  120385. setPosition(newPosition: Vector3): void;
  120386. /**
  120387. * Sets the local direction of the emitter if spatial sound is enabled
  120388. * @param newLocalDirection Defines the new local direction
  120389. */
  120390. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120391. private _updateDirection;
  120392. /** @hidden */
  120393. updateDistanceFromListener(): void;
  120394. /**
  120395. * Sets a new custom attenuation function for the sound.
  120396. * @param callback Defines the function used for the attenuation
  120397. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120398. */
  120399. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120400. /**
  120401. * Play the sound
  120402. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120403. * @param offset (optional) Start the sound at a specific time in seconds
  120404. * @param length (optional) Sound duration (in seconds)
  120405. */
  120406. play(time?: number, offset?: number, length?: number): void;
  120407. private _onended;
  120408. /**
  120409. * Stop the sound
  120410. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120411. */
  120412. stop(time?: number): void;
  120413. /**
  120414. * Put the sound in pause
  120415. */
  120416. pause(): void;
  120417. /**
  120418. * Sets a dedicated volume for this sounds
  120419. * @param newVolume Define the new volume of the sound
  120420. * @param time Define time for gradual change to new volume
  120421. */
  120422. setVolume(newVolume: number, time?: number): void;
  120423. /**
  120424. * Set the sound play back rate
  120425. * @param newPlaybackRate Define the playback rate the sound should be played at
  120426. */
  120427. setPlaybackRate(newPlaybackRate: number): void;
  120428. /**
  120429. * Gets the volume of the sound.
  120430. * @returns the volume of the sound
  120431. */
  120432. getVolume(): number;
  120433. /**
  120434. * Attach the sound to a dedicated mesh
  120435. * @param transformNode The transform node to connect the sound with
  120436. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120437. */
  120438. attachToMesh(transformNode: TransformNode): void;
  120439. /**
  120440. * Detach the sound from the previously attached mesh
  120441. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120442. */
  120443. detachFromMesh(): void;
  120444. private _onRegisterAfterWorldMatrixUpdate;
  120445. /**
  120446. * Clone the current sound in the scene.
  120447. * @returns the new sound clone
  120448. */
  120449. clone(): Nullable<Sound>;
  120450. /**
  120451. * Gets the current underlying audio buffer containing the data
  120452. * @returns the audio buffer
  120453. */
  120454. getAudioBuffer(): Nullable<AudioBuffer>;
  120455. /**
  120456. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120457. * @returns the source node
  120458. */
  120459. getSoundSource(): Nullable<AudioBufferSourceNode>;
  120460. /**
  120461. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  120462. * @returns the gain node
  120463. */
  120464. getSoundGain(): Nullable<GainNode>;
  120465. /**
  120466. * Serializes the Sound in a JSON representation
  120467. * @returns the JSON representation of the sound
  120468. */
  120469. serialize(): any;
  120470. /**
  120471. * Parse a JSON representation of a sound to innstantiate in a given scene
  120472. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  120473. * @param scene Define the scene the new parsed sound should be created in
  120474. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  120475. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  120476. * @returns the newly parsed sound
  120477. */
  120478. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  120479. }
  120480. }
  120481. declare module BABYLON {
  120482. /**
  120483. * This defines an action helpful to play a defined sound on a triggered action.
  120484. */
  120485. export class PlaySoundAction extends Action {
  120486. private _sound;
  120487. /**
  120488. * Instantiate the action
  120489. * @param triggerOptions defines the trigger options
  120490. * @param sound defines the sound to play
  120491. * @param condition defines the trigger related conditions
  120492. */
  120493. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120494. /** @hidden */
  120495. _prepare(): void;
  120496. /**
  120497. * Execute the action and play the sound.
  120498. */
  120499. execute(): void;
  120500. /**
  120501. * Serializes the actions and its related information.
  120502. * @param parent defines the object to serialize in
  120503. * @returns the serialized object
  120504. */
  120505. serialize(parent: any): any;
  120506. }
  120507. /**
  120508. * This defines an action helpful to stop a defined sound on a triggered action.
  120509. */
  120510. export class StopSoundAction extends Action {
  120511. private _sound;
  120512. /**
  120513. * Instantiate the action
  120514. * @param triggerOptions defines the trigger options
  120515. * @param sound defines the sound to stop
  120516. * @param condition defines the trigger related conditions
  120517. */
  120518. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120519. /** @hidden */
  120520. _prepare(): void;
  120521. /**
  120522. * Execute the action and stop the sound.
  120523. */
  120524. execute(): void;
  120525. /**
  120526. * Serializes the actions and its related information.
  120527. * @param parent defines the object to serialize in
  120528. * @returns the serialized object
  120529. */
  120530. serialize(parent: any): any;
  120531. }
  120532. }
  120533. declare module BABYLON {
  120534. /**
  120535. * This defines an action responsible to change the value of a property
  120536. * by interpolating between its current value and the newly set one once triggered.
  120537. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120538. */
  120539. export class InterpolateValueAction extends Action {
  120540. /**
  120541. * Defines the path of the property where the value should be interpolated
  120542. */
  120543. propertyPath: string;
  120544. /**
  120545. * Defines the target value at the end of the interpolation.
  120546. */
  120547. value: any;
  120548. /**
  120549. * Defines the time it will take for the property to interpolate to the value.
  120550. */
  120551. duration: number;
  120552. /**
  120553. * Defines if the other scene animations should be stopped when the action has been triggered
  120554. */
  120555. stopOtherAnimations?: boolean;
  120556. /**
  120557. * Defines a callback raised once the interpolation animation has been done.
  120558. */
  120559. onInterpolationDone?: () => void;
  120560. /**
  120561. * Observable triggered once the interpolation animation has been done.
  120562. */
  120563. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  120564. private _target;
  120565. private _effectiveTarget;
  120566. private _property;
  120567. /**
  120568. * Instantiate the action
  120569. * @param triggerOptions defines the trigger options
  120570. * @param target defines the object containing the value to interpolate
  120571. * @param propertyPath defines the path to the property in the target object
  120572. * @param value defines the target value at the end of the interpolation
  120573. * @param duration deines the time it will take for the property to interpolate to the value.
  120574. * @param condition defines the trigger related conditions
  120575. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  120576. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  120577. */
  120578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  120579. /** @hidden */
  120580. _prepare(): void;
  120581. /**
  120582. * Execute the action starts the value interpolation.
  120583. */
  120584. execute(): void;
  120585. /**
  120586. * Serializes the actions and its related information.
  120587. * @param parent defines the object to serialize in
  120588. * @returns the serialized object
  120589. */
  120590. serialize(parent: any): any;
  120591. }
  120592. }
  120593. declare module BABYLON {
  120594. /**
  120595. * Options allowed during the creation of a sound track.
  120596. */
  120597. export interface ISoundTrackOptions {
  120598. /**
  120599. * The volume the sound track should take during creation
  120600. */
  120601. volume?: number;
  120602. /**
  120603. * Define if the sound track is the main sound track of the scene
  120604. */
  120605. mainTrack?: boolean;
  120606. }
  120607. /**
  120608. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  120609. * It will be also used in a future release to apply effects on a specific track.
  120610. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120611. */
  120612. export class SoundTrack {
  120613. /**
  120614. * The unique identifier of the sound track in the scene.
  120615. */
  120616. id: number;
  120617. /**
  120618. * The list of sounds included in the sound track.
  120619. */
  120620. soundCollection: Array<Sound>;
  120621. private _outputAudioNode;
  120622. private _scene;
  120623. private _connectedAnalyser;
  120624. private _options;
  120625. private _isInitialized;
  120626. /**
  120627. * Creates a new sound track.
  120628. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120629. * @param scene Define the scene the sound track belongs to
  120630. * @param options
  120631. */
  120632. constructor(scene: Scene, options?: ISoundTrackOptions);
  120633. private _initializeSoundTrackAudioGraph;
  120634. /**
  120635. * Release the sound track and its associated resources
  120636. */
  120637. dispose(): void;
  120638. /**
  120639. * Adds a sound to this sound track
  120640. * @param sound define the cound to add
  120641. * @ignoreNaming
  120642. */
  120643. AddSound(sound: Sound): void;
  120644. /**
  120645. * Removes a sound to this sound track
  120646. * @param sound define the cound to remove
  120647. * @ignoreNaming
  120648. */
  120649. RemoveSound(sound: Sound): void;
  120650. /**
  120651. * Set a global volume for the full sound track.
  120652. * @param newVolume Define the new volume of the sound track
  120653. */
  120654. setVolume(newVolume: number): void;
  120655. /**
  120656. * Switch the panning model to HRTF:
  120657. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120658. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120659. */
  120660. switchPanningModelToHRTF(): void;
  120661. /**
  120662. * Switch the panning model to Equal Power:
  120663. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120664. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120665. */
  120666. switchPanningModelToEqualPower(): void;
  120667. /**
  120668. * Connect the sound track to an audio analyser allowing some amazing
  120669. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120670. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120671. * @param analyser The analyser to connect to the engine
  120672. */
  120673. connectToAnalyser(analyser: Analyser): void;
  120674. }
  120675. }
  120676. declare module BABYLON {
  120677. interface AbstractScene {
  120678. /**
  120679. * The list of sounds used in the scene.
  120680. */
  120681. sounds: Nullable<Array<Sound>>;
  120682. }
  120683. interface Scene {
  120684. /**
  120685. * @hidden
  120686. * Backing field
  120687. */
  120688. _mainSoundTrack: SoundTrack;
  120689. /**
  120690. * The main sound track played by the scene.
  120691. * It cotains your primary collection of sounds.
  120692. */
  120693. mainSoundTrack: SoundTrack;
  120694. /**
  120695. * The list of sound tracks added to the scene
  120696. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120697. */
  120698. soundTracks: Nullable<Array<SoundTrack>>;
  120699. /**
  120700. * Gets a sound using a given name
  120701. * @param name defines the name to search for
  120702. * @return the found sound or null if not found at all.
  120703. */
  120704. getSoundByName(name: string): Nullable<Sound>;
  120705. /**
  120706. * Gets or sets if audio support is enabled
  120707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120708. */
  120709. audioEnabled: boolean;
  120710. /**
  120711. * Gets or sets if audio will be output to headphones
  120712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120713. */
  120714. headphone: boolean;
  120715. /**
  120716. * Gets or sets custom audio listener position provider
  120717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120718. */
  120719. audioListenerPositionProvider: Nullable<() => Vector3>;
  120720. /**
  120721. * Gets or sets a refresh rate when using 3D audio positioning
  120722. */
  120723. audioPositioningRefreshRate: number;
  120724. }
  120725. /**
  120726. * Defines the sound scene component responsible to manage any sounds
  120727. * in a given scene.
  120728. */
  120729. export class AudioSceneComponent implements ISceneSerializableComponent {
  120730. /**
  120731. * The component name helpfull to identify the component in the list of scene components.
  120732. */
  120733. readonly name: string;
  120734. /**
  120735. * The scene the component belongs to.
  120736. */
  120737. scene: Scene;
  120738. private _audioEnabled;
  120739. /**
  120740. * Gets whether audio is enabled or not.
  120741. * Please use related enable/disable method to switch state.
  120742. */
  120743. get audioEnabled(): boolean;
  120744. private _headphone;
  120745. /**
  120746. * Gets whether audio is outputing to headphone or not.
  120747. * Please use the according Switch methods to change output.
  120748. */
  120749. get headphone(): boolean;
  120750. /**
  120751. * Gets or sets a refresh rate when using 3D audio positioning
  120752. */
  120753. audioPositioningRefreshRate: number;
  120754. private _audioListenerPositionProvider;
  120755. /**
  120756. * Gets the current audio listener position provider
  120757. */
  120758. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  120759. /**
  120760. * Sets a custom listener position for all sounds in the scene
  120761. * By default, this is the position of the first active camera
  120762. */
  120763. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  120764. /**
  120765. * Creates a new instance of the component for the given scene
  120766. * @param scene Defines the scene to register the component in
  120767. */
  120768. constructor(scene: Scene);
  120769. /**
  120770. * Registers the component in a given scene
  120771. */
  120772. register(): void;
  120773. /**
  120774. * Rebuilds the elements related to this component in case of
  120775. * context lost for instance.
  120776. */
  120777. rebuild(): void;
  120778. /**
  120779. * Serializes the component data to the specified json object
  120780. * @param serializationObject The object to serialize to
  120781. */
  120782. serialize(serializationObject: any): void;
  120783. /**
  120784. * Adds all the elements from the container to the scene
  120785. * @param container the container holding the elements
  120786. */
  120787. addFromContainer(container: AbstractScene): void;
  120788. /**
  120789. * Removes all the elements in the container from the scene
  120790. * @param container contains the elements to remove
  120791. * @param dispose if the removed element should be disposed (default: false)
  120792. */
  120793. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120794. /**
  120795. * Disposes the component and the associated ressources.
  120796. */
  120797. dispose(): void;
  120798. /**
  120799. * Disables audio in the associated scene.
  120800. */
  120801. disableAudio(): void;
  120802. /**
  120803. * Enables audio in the associated scene.
  120804. */
  120805. enableAudio(): void;
  120806. /**
  120807. * Switch audio to headphone output.
  120808. */
  120809. switchAudioModeForHeadphones(): void;
  120810. /**
  120811. * Switch audio to normal speakers.
  120812. */
  120813. switchAudioModeForNormalSpeakers(): void;
  120814. private _cachedCameraDirection;
  120815. private _cachedCameraPosition;
  120816. private _lastCheck;
  120817. private _afterRender;
  120818. }
  120819. }
  120820. declare module BABYLON {
  120821. /**
  120822. * Wraps one or more Sound objects and selects one with random weight for playback.
  120823. */
  120824. export class WeightedSound {
  120825. /** When true a Sound will be selected and played when the current playing Sound completes. */
  120826. loop: boolean;
  120827. private _coneInnerAngle;
  120828. private _coneOuterAngle;
  120829. private _volume;
  120830. /** A Sound is currently playing. */
  120831. isPlaying: boolean;
  120832. /** A Sound is currently paused. */
  120833. isPaused: boolean;
  120834. private _sounds;
  120835. private _weights;
  120836. private _currentIndex?;
  120837. /**
  120838. * Creates a new WeightedSound from the list of sounds given.
  120839. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  120840. * @param sounds Array of Sounds that will be selected from.
  120841. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  120842. */
  120843. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  120844. /**
  120845. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  120846. */
  120847. get directionalConeInnerAngle(): number;
  120848. /**
  120849. * The size of cone in degress for a directional sound in which there will be no attenuation.
  120850. */
  120851. set directionalConeInnerAngle(value: 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. get directionalConeOuterAngle(): number;
  120857. /**
  120858. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120859. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120860. */
  120861. set directionalConeOuterAngle(value: number);
  120862. /**
  120863. * Playback volume.
  120864. */
  120865. get volume(): number;
  120866. /**
  120867. * Playback volume.
  120868. */
  120869. set volume(value: number);
  120870. private _onended;
  120871. /**
  120872. * Suspend playback
  120873. */
  120874. pause(): void;
  120875. /**
  120876. * Stop playback
  120877. */
  120878. stop(): void;
  120879. /**
  120880. * Start playback.
  120881. * @param startOffset Position the clip head at a specific time in seconds.
  120882. */
  120883. play(startOffset?: number): void;
  120884. }
  120885. }
  120886. declare module BABYLON {
  120887. /**
  120888. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  120889. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120890. */
  120891. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  120892. /**
  120893. * Gets the name of the behavior.
  120894. */
  120895. get name(): string;
  120896. /**
  120897. * The easing function used by animations
  120898. */
  120899. static EasingFunction: BackEase;
  120900. /**
  120901. * The easing mode used by animations
  120902. */
  120903. static EasingMode: number;
  120904. /**
  120905. * The duration of the animation, in milliseconds
  120906. */
  120907. transitionDuration: number;
  120908. /**
  120909. * Length of the distance animated by the transition when lower radius is reached
  120910. */
  120911. lowerRadiusTransitionRange: number;
  120912. /**
  120913. * Length of the distance animated by the transition when upper radius is reached
  120914. */
  120915. upperRadiusTransitionRange: number;
  120916. private _autoTransitionRange;
  120917. /**
  120918. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120919. */
  120920. get autoTransitionRange(): boolean;
  120921. /**
  120922. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120923. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  120924. */
  120925. set autoTransitionRange(value: boolean);
  120926. private _attachedCamera;
  120927. private _onAfterCheckInputsObserver;
  120928. private _onMeshTargetChangedObserver;
  120929. /**
  120930. * Initializes the behavior.
  120931. */
  120932. init(): void;
  120933. /**
  120934. * Attaches the behavior to its arc rotate camera.
  120935. * @param camera Defines the camera to attach the behavior to
  120936. */
  120937. attach(camera: ArcRotateCamera): void;
  120938. /**
  120939. * Detaches the behavior from its current arc rotate camera.
  120940. */
  120941. detach(): void;
  120942. private _radiusIsAnimating;
  120943. private _radiusBounceTransition;
  120944. private _animatables;
  120945. private _cachedWheelPrecision;
  120946. /**
  120947. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  120948. * @param radiusLimit The limit to check against.
  120949. * @return Bool to indicate if at limit.
  120950. */
  120951. private _isRadiusAtLimit;
  120952. /**
  120953. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  120954. * @param radiusDelta The delta by which to animate to. Can be negative.
  120955. */
  120956. private _applyBoundRadiusAnimation;
  120957. /**
  120958. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  120959. */
  120960. protected _clearAnimationLocks(): void;
  120961. /**
  120962. * Stops and removes all animations that have been applied to the camera
  120963. */
  120964. stopAllAnimations(): void;
  120965. }
  120966. }
  120967. declare module BABYLON {
  120968. /**
  120969. * 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.
  120970. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120971. */
  120972. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  120973. /**
  120974. * Gets the name of the behavior.
  120975. */
  120976. get name(): string;
  120977. private _mode;
  120978. private _radiusScale;
  120979. private _positionScale;
  120980. private _defaultElevation;
  120981. private _elevationReturnTime;
  120982. private _elevationReturnWaitTime;
  120983. private _zoomStopsAnimation;
  120984. private _framingTime;
  120985. /**
  120986. * The easing function used by animations
  120987. */
  120988. static EasingFunction: ExponentialEase;
  120989. /**
  120990. * The easing mode used by animations
  120991. */
  120992. static EasingMode: number;
  120993. /**
  120994. * Sets the current mode used by the behavior
  120995. */
  120996. set mode(mode: number);
  120997. /**
  120998. * Gets current mode used by the behavior.
  120999. */
  121000. get mode(): number;
  121001. /**
  121002. * Sets the scale applied to the radius (1 by default)
  121003. */
  121004. set radiusScale(radius: number);
  121005. /**
  121006. * Gets the scale applied to the radius
  121007. */
  121008. get radiusScale(): number;
  121009. /**
  121010. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121011. */
  121012. set positionScale(scale: number);
  121013. /**
  121014. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121015. */
  121016. get positionScale(): number;
  121017. /**
  121018. * Sets 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. set defaultElevation(elevation: number);
  121022. /**
  121023. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121024. * behaviour is triggered, in radians.
  121025. */
  121026. get defaultElevation(): number;
  121027. /**
  121028. * Sets the time (in milliseconds) taken to return to the default beta position.
  121029. * Negative value indicates camera should not return to default.
  121030. */
  121031. set elevationReturnTime(speed: number);
  121032. /**
  121033. * Gets the time (in milliseconds) taken to return to the default beta position.
  121034. * Negative value indicates camera should not return to default.
  121035. */
  121036. get elevationReturnTime(): number;
  121037. /**
  121038. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121039. */
  121040. set elevationReturnWaitTime(time: number);
  121041. /**
  121042. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121043. */
  121044. get elevationReturnWaitTime(): number;
  121045. /**
  121046. * Sets the flag that indicates if user zooming should stop animation.
  121047. */
  121048. set zoomStopsAnimation(flag: boolean);
  121049. /**
  121050. * Gets the flag that indicates if user zooming should stop animation.
  121051. */
  121052. get zoomStopsAnimation(): boolean;
  121053. /**
  121054. * Sets the transition time when framing the mesh, in milliseconds
  121055. */
  121056. set framingTime(time: number);
  121057. /**
  121058. * Gets the transition time when framing the mesh, in milliseconds
  121059. */
  121060. get framingTime(): number;
  121061. /**
  121062. * Define if the behavior should automatically change the configured
  121063. * camera limits and sensibilities.
  121064. */
  121065. autoCorrectCameraLimitsAndSensibility: boolean;
  121066. private _onPrePointerObservableObserver;
  121067. private _onAfterCheckInputsObserver;
  121068. private _onMeshTargetChangedObserver;
  121069. private _attachedCamera;
  121070. private _isPointerDown;
  121071. private _lastInteractionTime;
  121072. /**
  121073. * Initializes the behavior.
  121074. */
  121075. init(): void;
  121076. /**
  121077. * Attaches the behavior to its arc rotate camera.
  121078. * @param camera Defines the camera to attach the behavior to
  121079. */
  121080. attach(camera: ArcRotateCamera): void;
  121081. /**
  121082. * Detaches the behavior from its current arc rotate camera.
  121083. */
  121084. detach(): void;
  121085. private _animatables;
  121086. private _betaIsAnimating;
  121087. private _betaTransition;
  121088. private _radiusTransition;
  121089. private _vectorTransition;
  121090. /**
  121091. * Targets the given mesh and updates zoom level accordingly.
  121092. * @param mesh The mesh to target.
  121093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121095. */
  121096. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121097. /**
  121098. * Targets the given mesh with its children and updates zoom level accordingly.
  121099. * @param mesh The mesh to target.
  121100. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121101. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121102. */
  121103. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121104. /**
  121105. * Targets the given meshes with their children and updates zoom level accordingly.
  121106. * @param meshes The mesh to target.
  121107. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121108. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121109. */
  121110. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121111. /**
  121112. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  121113. * @param minimumWorld Determines the smaller position of the bounding box extend
  121114. * @param maximumWorld Determines the bigger position of the bounding box extend
  121115. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121116. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121117. */
  121118. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121119. /**
  121120. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  121121. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  121122. * frustum width.
  121123. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  121124. * to fully enclose the mesh in the viewing frustum.
  121125. */
  121126. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  121127. /**
  121128. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  121129. * is automatically returned to its default position (expected to be above ground plane).
  121130. */
  121131. private _maintainCameraAboveGround;
  121132. /**
  121133. * Returns the frustum slope based on the canvas ratio and camera FOV
  121134. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  121135. */
  121136. private _getFrustumSlope;
  121137. /**
  121138. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  121139. */
  121140. private _clearAnimationLocks;
  121141. /**
  121142. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121143. */
  121144. private _applyUserInteraction;
  121145. /**
  121146. * Stops and removes all animations that have been applied to the camera
  121147. */
  121148. stopAllAnimations(): void;
  121149. /**
  121150. * Gets a value indicating if the user is moving the camera
  121151. */
  121152. get isUserIsMoving(): boolean;
  121153. /**
  121154. * The camera can move all the way towards the mesh.
  121155. */
  121156. static IgnoreBoundsSizeMode: number;
  121157. /**
  121158. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  121159. */
  121160. static FitFrustumSidesMode: number;
  121161. }
  121162. }
  121163. declare module BABYLON {
  121164. /**
  121165. * Base class for Camera Pointer Inputs.
  121166. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  121167. * for example usage.
  121168. */
  121169. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  121170. /**
  121171. * Defines the camera the input is attached to.
  121172. */
  121173. abstract camera: Camera;
  121174. /**
  121175. * Whether keyboard modifier keys are pressed at time of last mouse event.
  121176. */
  121177. protected _altKey: boolean;
  121178. protected _ctrlKey: boolean;
  121179. protected _metaKey: boolean;
  121180. protected _shiftKey: boolean;
  121181. /**
  121182. * Which mouse buttons were pressed at time of last mouse event.
  121183. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  121184. */
  121185. protected _buttonsPressed: number;
  121186. /**
  121187. * Defines the buttons associated with the input to handle camera move.
  121188. */
  121189. buttons: number[];
  121190. /**
  121191. * Attach the input controls to a specific dom element to get the input from.
  121192. * @param element Defines the element the controls should be listened from
  121193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121194. */
  121195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121196. /**
  121197. * Detach the current controls from the specified dom element.
  121198. * @param element Defines the element to stop listening the inputs from
  121199. */
  121200. detachControl(element: Nullable<HTMLElement>): void;
  121201. /**
  121202. * Gets the class name of the current input.
  121203. * @returns the class name
  121204. */
  121205. getClassName(): string;
  121206. /**
  121207. * Get the friendly name associated with the input class.
  121208. * @returns the input friendly name
  121209. */
  121210. getSimpleName(): string;
  121211. /**
  121212. * Called on pointer POINTERDOUBLETAP event.
  121213. * Override this method to provide functionality on POINTERDOUBLETAP event.
  121214. */
  121215. protected onDoubleTap(type: string): void;
  121216. /**
  121217. * Called on pointer POINTERMOVE event if only a single touch is active.
  121218. * Override this method to provide functionality.
  121219. */
  121220. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121221. /**
  121222. * Called on pointer POINTERMOVE event if multiple touches are active.
  121223. * Override this method to provide functionality.
  121224. */
  121225. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121226. /**
  121227. * Called on JS contextmenu event.
  121228. * Override this method to provide functionality.
  121229. */
  121230. protected onContextMenu(evt: PointerEvent): void;
  121231. /**
  121232. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121233. * press.
  121234. * Override this method to provide functionality.
  121235. */
  121236. protected onButtonDown(evt: PointerEvent): void;
  121237. /**
  121238. * Called each time a new POINTERUP event occurs. Ie, for each button
  121239. * release.
  121240. * Override this method to provide functionality.
  121241. */
  121242. protected onButtonUp(evt: PointerEvent): void;
  121243. /**
  121244. * Called when window becomes inactive.
  121245. * Override this method to provide functionality.
  121246. */
  121247. protected onLostFocus(): void;
  121248. private _pointerInput;
  121249. private _observer;
  121250. private _onLostFocus;
  121251. private pointA;
  121252. private pointB;
  121253. }
  121254. }
  121255. declare module BABYLON {
  121256. /**
  121257. * Manage the pointers inputs to control an arc rotate camera.
  121258. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121259. */
  121260. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  121261. /**
  121262. * Defines the camera the input is attached to.
  121263. */
  121264. camera: ArcRotateCamera;
  121265. /**
  121266. * Gets the class name of the current input.
  121267. * @returns the class name
  121268. */
  121269. getClassName(): string;
  121270. /**
  121271. * Defines the buttons associated with the input to handle camera move.
  121272. */
  121273. buttons: number[];
  121274. /**
  121275. * Defines the pointer angular sensibility along the X axis or how fast is
  121276. * the camera rotating.
  121277. */
  121278. angularSensibilityX: number;
  121279. /**
  121280. * Defines the pointer angular sensibility along the Y axis or how fast is
  121281. * the camera rotating.
  121282. */
  121283. angularSensibilityY: number;
  121284. /**
  121285. * Defines the pointer pinch precision or how fast is the camera zooming.
  121286. */
  121287. pinchPrecision: number;
  121288. /**
  121289. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121290. * from 0.
  121291. * It defines the percentage of current camera.radius to use as delta when
  121292. * pinch zoom is used.
  121293. */
  121294. pinchDeltaPercentage: number;
  121295. /**
  121296. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121297. * that any object in the plane at the camera's target point will scale
  121298. * perfectly with finger motion.
  121299. * Overrides pinchDeltaPercentage and pinchPrecision.
  121300. */
  121301. useNaturalPinchZoom: boolean;
  121302. /**
  121303. * Defines the pointer panning sensibility or how fast is the camera moving.
  121304. */
  121305. panningSensibility: number;
  121306. /**
  121307. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  121308. */
  121309. multiTouchPanning: boolean;
  121310. /**
  121311. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  121312. * zoom (pinch) through multitouch.
  121313. */
  121314. multiTouchPanAndZoom: boolean;
  121315. /**
  121316. * Revers pinch action direction.
  121317. */
  121318. pinchInwards: boolean;
  121319. private _isPanClick;
  121320. private _twoFingerActivityCount;
  121321. private _isPinching;
  121322. /**
  121323. * Called on pointer POINTERMOVE event if only a single touch is active.
  121324. */
  121325. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121326. /**
  121327. * Called on pointer POINTERDOUBLETAP event.
  121328. */
  121329. protected onDoubleTap(type: string): void;
  121330. /**
  121331. * Called on pointer POINTERMOVE event if multiple touches are active.
  121332. */
  121333. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121334. /**
  121335. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121336. * press.
  121337. */
  121338. protected onButtonDown(evt: PointerEvent): void;
  121339. /**
  121340. * Called each time a new POINTERUP event occurs. Ie, for each button
  121341. * release.
  121342. */
  121343. protected onButtonUp(evt: PointerEvent): void;
  121344. /**
  121345. * Called when window becomes inactive.
  121346. */
  121347. protected onLostFocus(): void;
  121348. }
  121349. }
  121350. declare module BABYLON {
  121351. /**
  121352. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  121353. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121354. */
  121355. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  121356. /**
  121357. * Defines the camera the input is attached to.
  121358. */
  121359. camera: ArcRotateCamera;
  121360. /**
  121361. * Defines the list of key codes associated with the up action (increase alpha)
  121362. */
  121363. keysUp: number[];
  121364. /**
  121365. * Defines the list of key codes associated with the down action (decrease alpha)
  121366. */
  121367. keysDown: number[];
  121368. /**
  121369. * Defines the list of key codes associated with the left action (increase beta)
  121370. */
  121371. keysLeft: number[];
  121372. /**
  121373. * Defines the list of key codes associated with the right action (decrease beta)
  121374. */
  121375. keysRight: number[];
  121376. /**
  121377. * Defines the list of key codes associated with the reset action.
  121378. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121379. */
  121380. keysReset: number[];
  121381. /**
  121382. * Defines the panning sensibility of the inputs.
  121383. * (How fast is the camera panning)
  121384. */
  121385. panningSensibility: number;
  121386. /**
  121387. * Defines the zooming sensibility of the inputs.
  121388. * (How fast is the camera zooming)
  121389. */
  121390. zoomingSensibility: number;
  121391. /**
  121392. * Defines whether maintaining the alt key down switch the movement mode from
  121393. * orientation to zoom.
  121394. */
  121395. useAltToZoom: boolean;
  121396. /**
  121397. * Rotation speed of the camera
  121398. */
  121399. angularSpeed: number;
  121400. private _keys;
  121401. private _ctrlPressed;
  121402. private _altPressed;
  121403. private _onCanvasBlurObserver;
  121404. private _onKeyboardObserver;
  121405. private _engine;
  121406. private _scene;
  121407. /**
  121408. * Attach the input controls to a specific dom element to get the input from.
  121409. * @param element Defines the element the controls should be listened from
  121410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121411. */
  121412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121413. /**
  121414. * Detach the current controls from the specified dom element.
  121415. * @param element Defines the element to stop listening the inputs from
  121416. */
  121417. detachControl(element: Nullable<HTMLElement>): void;
  121418. /**
  121419. * Update the current camera state depending on the inputs that have been used this frame.
  121420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121421. */
  121422. checkInputs(): void;
  121423. /**
  121424. * Gets the class name of the current intput.
  121425. * @returns the class name
  121426. */
  121427. getClassName(): string;
  121428. /**
  121429. * Get the friendly name associated with the input class.
  121430. * @returns the input friendly name
  121431. */
  121432. getSimpleName(): string;
  121433. }
  121434. }
  121435. declare module BABYLON {
  121436. /**
  121437. * Manage the mouse wheel inputs to control an arc rotate camera.
  121438. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121439. */
  121440. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121441. /**
  121442. * Defines the camera the input is attached to.
  121443. */
  121444. camera: ArcRotateCamera;
  121445. /**
  121446. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121447. */
  121448. wheelPrecision: number;
  121449. /**
  121450. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121451. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121452. */
  121453. wheelDeltaPercentage: number;
  121454. private _wheel;
  121455. private _observer;
  121456. private computeDeltaFromMouseWheelLegacyEvent;
  121457. /**
  121458. * Attach the input controls to a specific dom element to get the input from.
  121459. * @param element Defines the element the controls should be listened from
  121460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121461. */
  121462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121463. /**
  121464. * Detach the current controls from the specified dom element.
  121465. * @param element Defines the element to stop listening the inputs from
  121466. */
  121467. detachControl(element: Nullable<HTMLElement>): void;
  121468. /**
  121469. * Gets the class name of the current intput.
  121470. * @returns the class name
  121471. */
  121472. getClassName(): string;
  121473. /**
  121474. * Get the friendly name associated with the input class.
  121475. * @returns the input friendly name
  121476. */
  121477. getSimpleName(): string;
  121478. }
  121479. }
  121480. declare module BABYLON {
  121481. /**
  121482. * Default Inputs manager for the ArcRotateCamera.
  121483. * It groups all the default supported inputs for ease of use.
  121484. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121485. */
  121486. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  121487. /**
  121488. * Instantiates a new ArcRotateCameraInputsManager.
  121489. * @param camera Defines the camera the inputs belong to
  121490. */
  121491. constructor(camera: ArcRotateCamera);
  121492. /**
  121493. * Add mouse wheel input support to the input manager.
  121494. * @returns the current input manager
  121495. */
  121496. addMouseWheel(): ArcRotateCameraInputsManager;
  121497. /**
  121498. * Add pointers input support to the input manager.
  121499. * @returns the current input manager
  121500. */
  121501. addPointers(): ArcRotateCameraInputsManager;
  121502. /**
  121503. * Add keyboard input support to the input manager.
  121504. * @returns the current input manager
  121505. */
  121506. addKeyboard(): ArcRotateCameraInputsManager;
  121507. }
  121508. }
  121509. declare module BABYLON {
  121510. /**
  121511. * This represents an orbital type of camera.
  121512. *
  121513. * 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.
  121514. * 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.
  121515. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  121516. */
  121517. export class ArcRotateCamera extends TargetCamera {
  121518. /**
  121519. * Defines the rotation angle of the camera along the longitudinal axis.
  121520. */
  121521. alpha: number;
  121522. /**
  121523. * Defines the rotation angle of the camera along the latitudinal axis.
  121524. */
  121525. beta: number;
  121526. /**
  121527. * Defines the radius of the camera from it s target point.
  121528. */
  121529. radius: number;
  121530. protected _target: Vector3;
  121531. protected _targetHost: Nullable<AbstractMesh>;
  121532. /**
  121533. * Defines the target point of the camera.
  121534. * The camera looks towards it form the radius distance.
  121535. */
  121536. get target(): Vector3;
  121537. set target(value: Vector3);
  121538. /**
  121539. * Define the current local position of the camera in the scene
  121540. */
  121541. get position(): Vector3;
  121542. set position(newPosition: Vector3);
  121543. protected _upVector: Vector3;
  121544. protected _upToYMatrix: Matrix;
  121545. protected _YToUpMatrix: Matrix;
  121546. /**
  121547. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  121548. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  121549. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  121550. */
  121551. set upVector(vec: Vector3);
  121552. get upVector(): Vector3;
  121553. /**
  121554. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  121555. */
  121556. setMatUp(): void;
  121557. /**
  121558. * Current inertia value on the longitudinal axis.
  121559. * The bigger this number the longer it will take for the camera to stop.
  121560. */
  121561. inertialAlphaOffset: number;
  121562. /**
  121563. * Current inertia value on the latitudinal axis.
  121564. * The bigger this number the longer it will take for the camera to stop.
  121565. */
  121566. inertialBetaOffset: number;
  121567. /**
  121568. * Current inertia value on the radius axis.
  121569. * The bigger this number the longer it will take for the camera to stop.
  121570. */
  121571. inertialRadiusOffset: number;
  121572. /**
  121573. * Minimum allowed angle on the longitudinal axis.
  121574. * This can help limiting how the Camera is able to move in the scene.
  121575. */
  121576. lowerAlphaLimit: Nullable<number>;
  121577. /**
  121578. * Maximum allowed angle on the longitudinal axis.
  121579. * This can help limiting how the Camera is able to move in the scene.
  121580. */
  121581. upperAlphaLimit: Nullable<number>;
  121582. /**
  121583. * Minimum allowed angle on the latitudinal axis.
  121584. * This can help limiting how the Camera is able to move in the scene.
  121585. */
  121586. lowerBetaLimit: number;
  121587. /**
  121588. * Maximum allowed angle on the latitudinal axis.
  121589. * This can help limiting how the Camera is able to move in the scene.
  121590. */
  121591. upperBetaLimit: number;
  121592. /**
  121593. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  121594. * This can help limiting how the Camera is able to move in the scene.
  121595. */
  121596. lowerRadiusLimit: Nullable<number>;
  121597. /**
  121598. * Maximum allowed distance of the camera to the target (The camera can not get further).
  121599. * This can help limiting how the Camera is able to move in the scene.
  121600. */
  121601. upperRadiusLimit: Nullable<number>;
  121602. /**
  121603. * Defines the current inertia value used during panning of the camera along the X axis.
  121604. */
  121605. inertialPanningX: number;
  121606. /**
  121607. * Defines the current inertia value used during panning of the camera along the Y axis.
  121608. */
  121609. inertialPanningY: number;
  121610. /**
  121611. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  121612. * Basically if your fingers moves away from more than this distance you will be considered
  121613. * in pinch mode.
  121614. */
  121615. pinchToPanMaxDistance: number;
  121616. /**
  121617. * Defines the maximum distance the camera can pan.
  121618. * This could help keeping the cammera always in your scene.
  121619. */
  121620. panningDistanceLimit: Nullable<number>;
  121621. /**
  121622. * Defines the target of the camera before paning.
  121623. */
  121624. panningOriginTarget: Vector3;
  121625. /**
  121626. * Defines the value of the inertia used during panning.
  121627. * 0 would mean stop inertia and one would mean no decelleration at all.
  121628. */
  121629. panningInertia: number;
  121630. /**
  121631. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  121632. */
  121633. get angularSensibilityX(): number;
  121634. set angularSensibilityX(value: number);
  121635. /**
  121636. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  121637. */
  121638. get angularSensibilityY(): number;
  121639. set angularSensibilityY(value: number);
  121640. /**
  121641. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  121642. */
  121643. get pinchPrecision(): number;
  121644. set pinchPrecision(value: number);
  121645. /**
  121646. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  121647. * It will be used instead of pinchDeltaPrecision if different from 0.
  121648. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121649. */
  121650. get pinchDeltaPercentage(): number;
  121651. set pinchDeltaPercentage(value: number);
  121652. /**
  121653. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  121654. * and pinch delta percentage.
  121655. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121656. * that any object in the plane at the camera's target point will scale
  121657. * perfectly with finger motion.
  121658. */
  121659. get useNaturalPinchZoom(): boolean;
  121660. set useNaturalPinchZoom(value: boolean);
  121661. /**
  121662. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  121663. */
  121664. get panningSensibility(): number;
  121665. set panningSensibility(value: number);
  121666. /**
  121667. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  121668. */
  121669. get keysUp(): number[];
  121670. set keysUp(value: number[]);
  121671. /**
  121672. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  121673. */
  121674. get keysDown(): number[];
  121675. set keysDown(value: number[]);
  121676. /**
  121677. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  121678. */
  121679. get keysLeft(): number[];
  121680. set keysLeft(value: number[]);
  121681. /**
  121682. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  121683. */
  121684. get keysRight(): number[];
  121685. set keysRight(value: number[]);
  121686. /**
  121687. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121688. */
  121689. get wheelPrecision(): number;
  121690. set wheelPrecision(value: number);
  121691. /**
  121692. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  121693. * It will be used instead of pinchDeltaPrecision if different from 0.
  121694. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121695. */
  121696. get wheelDeltaPercentage(): number;
  121697. set wheelDeltaPercentage(value: number);
  121698. /**
  121699. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  121700. */
  121701. zoomOnFactor: number;
  121702. /**
  121703. * Defines a screen offset for the camera position.
  121704. */
  121705. targetScreenOffset: Vector2;
  121706. /**
  121707. * Allows the camera to be completely reversed.
  121708. * If false the camera can not arrive upside down.
  121709. */
  121710. allowUpsideDown: boolean;
  121711. /**
  121712. * Define if double tap/click is used to restore the previously saved state of the camera.
  121713. */
  121714. useInputToRestoreState: boolean;
  121715. /** @hidden */
  121716. _viewMatrix: Matrix;
  121717. /** @hidden */
  121718. _useCtrlForPanning: boolean;
  121719. /** @hidden */
  121720. _panningMouseButton: number;
  121721. /**
  121722. * Defines the input associated to the camera.
  121723. */
  121724. inputs: ArcRotateCameraInputsManager;
  121725. /** @hidden */
  121726. _reset: () => void;
  121727. /**
  121728. * Defines the allowed panning axis.
  121729. */
  121730. panningAxis: Vector3;
  121731. protected _localDirection: Vector3;
  121732. protected _transformedDirection: Vector3;
  121733. private _bouncingBehavior;
  121734. /**
  121735. * Gets the bouncing behavior of the camera if it has been enabled.
  121736. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121737. */
  121738. get bouncingBehavior(): Nullable<BouncingBehavior>;
  121739. /**
  121740. * Defines if the bouncing behavior of the camera is enabled on the camera.
  121741. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121742. */
  121743. get useBouncingBehavior(): boolean;
  121744. set useBouncingBehavior(value: boolean);
  121745. private _framingBehavior;
  121746. /**
  121747. * Gets the framing behavior of the camera if it has been enabled.
  121748. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121749. */
  121750. get framingBehavior(): Nullable<FramingBehavior>;
  121751. /**
  121752. * Defines if the framing behavior of the camera is enabled on the camera.
  121753. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121754. */
  121755. get useFramingBehavior(): boolean;
  121756. set useFramingBehavior(value: boolean);
  121757. private _autoRotationBehavior;
  121758. /**
  121759. * Gets the auto rotation behavior of the camera if it has been enabled.
  121760. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121761. */
  121762. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  121763. /**
  121764. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  121765. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121766. */
  121767. get useAutoRotationBehavior(): boolean;
  121768. set useAutoRotationBehavior(value: boolean);
  121769. /**
  121770. * Observable triggered when the mesh target has been changed on the camera.
  121771. */
  121772. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  121773. /**
  121774. * Event raised when the camera is colliding with a mesh.
  121775. */
  121776. onCollide: (collidedMesh: AbstractMesh) => void;
  121777. /**
  121778. * Defines whether the camera should check collision with the objects oh the scene.
  121779. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  121780. */
  121781. checkCollisions: boolean;
  121782. /**
  121783. * Defines the collision radius of the camera.
  121784. * This simulates a sphere around the camera.
  121785. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121786. */
  121787. collisionRadius: Vector3;
  121788. protected _collider: Collider;
  121789. protected _previousPosition: Vector3;
  121790. protected _collisionVelocity: Vector3;
  121791. protected _newPosition: Vector3;
  121792. protected _previousAlpha: number;
  121793. protected _previousBeta: number;
  121794. protected _previousRadius: number;
  121795. protected _collisionTriggered: boolean;
  121796. protected _targetBoundingCenter: Nullable<Vector3>;
  121797. private _computationVector;
  121798. /**
  121799. * Instantiates a new ArcRotateCamera in a given scene
  121800. * @param name Defines the name of the camera
  121801. * @param alpha Defines the camera rotation along the logitudinal axis
  121802. * @param beta Defines the camera rotation along the latitudinal axis
  121803. * @param radius Defines the camera distance from its target
  121804. * @param target Defines the camera target
  121805. * @param scene Defines the scene the camera belongs to
  121806. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  121807. */
  121808. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121809. /** @hidden */
  121810. _initCache(): void;
  121811. /** @hidden */
  121812. _updateCache(ignoreParentClass?: boolean): void;
  121813. protected _getTargetPosition(): Vector3;
  121814. private _storedAlpha;
  121815. private _storedBeta;
  121816. private _storedRadius;
  121817. private _storedTarget;
  121818. private _storedTargetScreenOffset;
  121819. /**
  121820. * Stores the current state of the camera (alpha, beta, radius and target)
  121821. * @returns the camera itself
  121822. */
  121823. storeState(): Camera;
  121824. /**
  121825. * @hidden
  121826. * Restored camera state. You must call storeState() first
  121827. */
  121828. _restoreStateValues(): boolean;
  121829. /** @hidden */
  121830. _isSynchronizedViewMatrix(): boolean;
  121831. /**
  121832. * Attached controls to the current camera.
  121833. * @param element Defines the element the controls should be listened from
  121834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121835. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  121836. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  121837. */
  121838. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  121839. /**
  121840. * Detach the current controls from the camera.
  121841. * The camera will stop reacting to inputs.
  121842. * @param element Defines the element to stop listening the inputs from
  121843. */
  121844. detachControl(element: HTMLElement): void;
  121845. /** @hidden */
  121846. _checkInputs(): void;
  121847. protected _checkLimits(): void;
  121848. /**
  121849. * Rebuilds angles (alpha, beta) and radius from the give position and target
  121850. */
  121851. rebuildAnglesAndRadius(): void;
  121852. /**
  121853. * Use a position to define the current camera related information like alpha, beta and radius
  121854. * @param position Defines the position to set the camera at
  121855. */
  121856. setPosition(position: Vector3): void;
  121857. /**
  121858. * Defines the target the camera should look at.
  121859. * This will automatically adapt alpha beta and radius to fit within the new target.
  121860. * @param target Defines the new target as a Vector or a mesh
  121861. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  121862. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  121863. */
  121864. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  121865. /** @hidden */
  121866. _getViewMatrix(): Matrix;
  121867. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  121868. /**
  121869. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  121870. * @param meshes Defines the mesh to zoom on
  121871. * @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)
  121872. */
  121873. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  121874. /**
  121875. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  121876. * The target will be changed but the radius
  121877. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  121878. * @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)
  121879. */
  121880. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  121881. min: Vector3;
  121882. max: Vector3;
  121883. distance: number;
  121884. }, doNotUpdateMaxZ?: boolean): void;
  121885. /**
  121886. * @override
  121887. * Override Camera.createRigCamera
  121888. */
  121889. createRigCamera(name: string, cameraIndex: number): Camera;
  121890. /**
  121891. * @hidden
  121892. * @override
  121893. * Override Camera._updateRigCameras
  121894. */
  121895. _updateRigCameras(): void;
  121896. /**
  121897. * Destroy the camera and release the current resources hold by it.
  121898. */
  121899. dispose(): void;
  121900. /**
  121901. * Gets the current object class name.
  121902. * @return the class name
  121903. */
  121904. getClassName(): string;
  121905. }
  121906. }
  121907. declare module BABYLON {
  121908. /**
  121909. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  121910. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121911. */
  121912. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  121913. /**
  121914. * Gets the name of the behavior.
  121915. */
  121916. get name(): string;
  121917. private _zoomStopsAnimation;
  121918. private _idleRotationSpeed;
  121919. private _idleRotationWaitTime;
  121920. private _idleRotationSpinupTime;
  121921. /**
  121922. * Sets the flag that indicates if user zooming should stop animation.
  121923. */
  121924. set zoomStopsAnimation(flag: boolean);
  121925. /**
  121926. * Gets the flag that indicates if user zooming should stop animation.
  121927. */
  121928. get zoomStopsAnimation(): boolean;
  121929. /**
  121930. * Sets the default speed at which the camera rotates around the model.
  121931. */
  121932. set idleRotationSpeed(speed: number);
  121933. /**
  121934. * Gets the default speed at which the camera rotates around the model.
  121935. */
  121936. get idleRotationSpeed(): number;
  121937. /**
  121938. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  121939. */
  121940. set idleRotationWaitTime(time: number);
  121941. /**
  121942. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  121943. */
  121944. get idleRotationWaitTime(): number;
  121945. /**
  121946. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121947. */
  121948. set idleRotationSpinupTime(time: number);
  121949. /**
  121950. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121951. */
  121952. get idleRotationSpinupTime(): number;
  121953. /**
  121954. * Gets a value indicating if the camera is currently rotating because of this behavior
  121955. */
  121956. get rotationInProgress(): boolean;
  121957. private _onPrePointerObservableObserver;
  121958. private _onAfterCheckInputsObserver;
  121959. private _attachedCamera;
  121960. private _isPointerDown;
  121961. private _lastFrameTime;
  121962. private _lastInteractionTime;
  121963. private _cameraRotationSpeed;
  121964. /**
  121965. * Initializes the behavior.
  121966. */
  121967. init(): void;
  121968. /**
  121969. * Attaches the behavior to its arc rotate camera.
  121970. * @param camera Defines the camera to attach the behavior to
  121971. */
  121972. attach(camera: ArcRotateCamera): void;
  121973. /**
  121974. * Detaches the behavior from its current arc rotate camera.
  121975. */
  121976. detach(): void;
  121977. /**
  121978. * Returns true if user is scrolling.
  121979. * @return true if user is scrolling.
  121980. */
  121981. private _userIsZooming;
  121982. private _lastFrameRadius;
  121983. private _shouldAnimationStopForInteraction;
  121984. /**
  121985. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121986. */
  121987. private _applyUserInteraction;
  121988. private _userIsMoving;
  121989. }
  121990. }
  121991. declare module BABYLON {
  121992. /**
  121993. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  121994. */
  121995. export class AttachToBoxBehavior implements Behavior<Mesh> {
  121996. private ui;
  121997. /**
  121998. * The name of the behavior
  121999. */
  122000. name: string;
  122001. /**
  122002. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  122003. */
  122004. distanceAwayFromFace: number;
  122005. /**
  122006. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  122007. */
  122008. distanceAwayFromBottomOfFace: number;
  122009. private _faceVectors;
  122010. private _target;
  122011. private _scene;
  122012. private _onRenderObserver;
  122013. private _tmpMatrix;
  122014. private _tmpVector;
  122015. /**
  122016. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  122017. * @param ui The transform node that should be attched to the mesh
  122018. */
  122019. constructor(ui: TransformNode);
  122020. /**
  122021. * Initializes the behavior
  122022. */
  122023. init(): void;
  122024. private _closestFace;
  122025. private _zeroVector;
  122026. private _lookAtTmpMatrix;
  122027. private _lookAtToRef;
  122028. /**
  122029. * Attaches the AttachToBoxBehavior to the passed in mesh
  122030. * @param target The mesh that the specified node will be attached to
  122031. */
  122032. attach(target: Mesh): void;
  122033. /**
  122034. * Detaches the behavior from the mesh
  122035. */
  122036. detach(): void;
  122037. }
  122038. }
  122039. declare module BABYLON {
  122040. /**
  122041. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  122042. */
  122043. export class FadeInOutBehavior implements Behavior<Mesh> {
  122044. /**
  122045. * Time in milliseconds to delay before fading in (Default: 0)
  122046. */
  122047. delay: number;
  122048. /**
  122049. * Time in milliseconds for the mesh to fade in (Default: 300)
  122050. */
  122051. fadeInTime: number;
  122052. private _millisecondsPerFrame;
  122053. private _hovered;
  122054. private _hoverValue;
  122055. private _ownerNode;
  122056. /**
  122057. * Instatiates the FadeInOutBehavior
  122058. */
  122059. constructor();
  122060. /**
  122061. * The name of the behavior
  122062. */
  122063. get name(): string;
  122064. /**
  122065. * Initializes the behavior
  122066. */
  122067. init(): void;
  122068. /**
  122069. * Attaches the fade behavior on the passed in mesh
  122070. * @param ownerNode The mesh that will be faded in/out once attached
  122071. */
  122072. attach(ownerNode: Mesh): void;
  122073. /**
  122074. * Detaches the behavior from the mesh
  122075. */
  122076. detach(): void;
  122077. /**
  122078. * Triggers the mesh to begin fading in or out
  122079. * @param value if the object should fade in or out (true to fade in)
  122080. */
  122081. fadeIn(value: boolean): void;
  122082. private _update;
  122083. private _setAllVisibility;
  122084. }
  122085. }
  122086. declare module BABYLON {
  122087. /**
  122088. * Class containing a set of static utilities functions for managing Pivots
  122089. * @hidden
  122090. */
  122091. export class PivotTools {
  122092. private static _PivotCached;
  122093. private static _OldPivotPoint;
  122094. private static _PivotTranslation;
  122095. private static _PivotTmpVector;
  122096. /** @hidden */
  122097. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  122098. /** @hidden */
  122099. static _RestorePivotPoint(mesh: AbstractMesh): void;
  122100. }
  122101. }
  122102. declare module BABYLON {
  122103. /**
  122104. * Class containing static functions to help procedurally build meshes
  122105. */
  122106. export class PlaneBuilder {
  122107. /**
  122108. * Creates a plane mesh
  122109. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122110. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122111. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122115. * @param name defines the name of the mesh
  122116. * @param options defines the options used to create the mesh
  122117. * @param scene defines the hosting scene
  122118. * @returns the plane mesh
  122119. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122120. */
  122121. static CreatePlane(name: string, options: {
  122122. size?: number;
  122123. width?: number;
  122124. height?: number;
  122125. sideOrientation?: number;
  122126. frontUVs?: Vector4;
  122127. backUVs?: Vector4;
  122128. updatable?: boolean;
  122129. sourcePlane?: Plane;
  122130. }, scene?: Nullable<Scene>): Mesh;
  122131. }
  122132. }
  122133. declare module BABYLON {
  122134. /**
  122135. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  122136. */
  122137. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  122138. private static _AnyMouseID;
  122139. /**
  122140. * Abstract mesh the behavior is set on
  122141. */
  122142. attachedNode: AbstractMesh;
  122143. private _dragPlane;
  122144. private _scene;
  122145. private _pointerObserver;
  122146. private _beforeRenderObserver;
  122147. private static _planeScene;
  122148. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  122149. /**
  122150. * 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)
  122151. */
  122152. maxDragAngle: number;
  122153. /**
  122154. * @hidden
  122155. */
  122156. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  122157. /**
  122158. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122159. */
  122160. currentDraggingPointerID: number;
  122161. /**
  122162. * The last position where the pointer hit the drag plane in world space
  122163. */
  122164. lastDragPosition: Vector3;
  122165. /**
  122166. * If the behavior is currently in a dragging state
  122167. */
  122168. dragging: boolean;
  122169. /**
  122170. * 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)
  122171. */
  122172. dragDeltaRatio: number;
  122173. /**
  122174. * If the drag plane orientation should be updated during the dragging (Default: true)
  122175. */
  122176. updateDragPlane: boolean;
  122177. private _debugMode;
  122178. private _moving;
  122179. /**
  122180. * Fires each time the attached mesh is dragged with the pointer
  122181. * * delta between last drag position and current drag position in world space
  122182. * * dragDistance along the drag axis
  122183. * * dragPlaneNormal normal of the current drag plane used during the drag
  122184. * * dragPlanePoint in world space where the drag intersects the drag plane
  122185. */
  122186. onDragObservable: Observable<{
  122187. delta: Vector3;
  122188. dragPlanePoint: Vector3;
  122189. dragPlaneNormal: Vector3;
  122190. dragDistance: number;
  122191. pointerId: number;
  122192. }>;
  122193. /**
  122194. * Fires each time a drag begins (eg. mouse down on mesh)
  122195. */
  122196. onDragStartObservable: Observable<{
  122197. dragPlanePoint: Vector3;
  122198. pointerId: number;
  122199. }>;
  122200. /**
  122201. * Fires each time a drag ends (eg. mouse release after drag)
  122202. */
  122203. onDragEndObservable: Observable<{
  122204. dragPlanePoint: Vector3;
  122205. pointerId: number;
  122206. }>;
  122207. /**
  122208. * If the attached mesh should be moved when dragged
  122209. */
  122210. moveAttached: boolean;
  122211. /**
  122212. * If the drag behavior will react to drag events (Default: true)
  122213. */
  122214. enabled: boolean;
  122215. /**
  122216. * If pointer events should start and release the drag (Default: true)
  122217. */
  122218. startAndReleaseDragOnPointerEvents: boolean;
  122219. /**
  122220. * If camera controls should be detached during the drag
  122221. */
  122222. detachCameraControls: boolean;
  122223. /**
  122224. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  122225. */
  122226. useObjectOrientationForDragging: boolean;
  122227. private _options;
  122228. /**
  122229. * Gets the options used by the behavior
  122230. */
  122231. get options(): {
  122232. dragAxis?: Vector3;
  122233. dragPlaneNormal?: Vector3;
  122234. };
  122235. /**
  122236. * Sets the options used by the behavior
  122237. */
  122238. set options(options: {
  122239. dragAxis?: Vector3;
  122240. dragPlaneNormal?: Vector3;
  122241. });
  122242. /**
  122243. * Creates a pointer drag behavior that can be attached to a mesh
  122244. * @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)
  122245. */
  122246. constructor(options?: {
  122247. dragAxis?: Vector3;
  122248. dragPlaneNormal?: Vector3;
  122249. });
  122250. /**
  122251. * Predicate to determine if it is valid to move the object to a new position when it is moved
  122252. */
  122253. validateDrag: (targetPosition: Vector3) => boolean;
  122254. /**
  122255. * The name of the behavior
  122256. */
  122257. get name(): string;
  122258. /**
  122259. * Initializes the behavior
  122260. */
  122261. init(): void;
  122262. private _tmpVector;
  122263. private _alternatePickedPoint;
  122264. private _worldDragAxis;
  122265. private _targetPosition;
  122266. private _attachedElement;
  122267. /**
  122268. * Attaches the drag behavior the passed in mesh
  122269. * @param ownerNode The mesh that will be dragged around once attached
  122270. * @param predicate Predicate to use for pick filtering
  122271. */
  122272. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  122273. /**
  122274. * Force relase the drag action by code.
  122275. */
  122276. releaseDrag(): void;
  122277. private _startDragRay;
  122278. private _lastPointerRay;
  122279. /**
  122280. * Simulates the start of a pointer drag event on the behavior
  122281. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  122282. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  122283. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  122284. */
  122285. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  122286. private _startDrag;
  122287. private _dragDelta;
  122288. private _moveDrag;
  122289. private _pickWithRayOnDragPlane;
  122290. private _pointA;
  122291. private _pointC;
  122292. private _localAxis;
  122293. private _lookAt;
  122294. private _updateDragPlanePosition;
  122295. /**
  122296. * Detaches the behavior from the mesh
  122297. */
  122298. detach(): void;
  122299. }
  122300. }
  122301. declare module BABYLON {
  122302. /**
  122303. * A behavior that when attached to a mesh will allow the mesh to be scaled
  122304. */
  122305. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  122306. private _dragBehaviorA;
  122307. private _dragBehaviorB;
  122308. private _startDistance;
  122309. private _initialScale;
  122310. private _targetScale;
  122311. private _ownerNode;
  122312. private _sceneRenderObserver;
  122313. /**
  122314. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  122315. */
  122316. constructor();
  122317. /**
  122318. * The name of the behavior
  122319. */
  122320. get name(): string;
  122321. /**
  122322. * Initializes the behavior
  122323. */
  122324. init(): void;
  122325. private _getCurrentDistance;
  122326. /**
  122327. * Attaches the scale behavior the passed in mesh
  122328. * @param ownerNode The mesh that will be scaled around once attached
  122329. */
  122330. attach(ownerNode: Mesh): void;
  122331. /**
  122332. * Detaches the behavior from the mesh
  122333. */
  122334. detach(): void;
  122335. }
  122336. }
  122337. declare module BABYLON {
  122338. /**
  122339. * 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
  122340. */
  122341. export class SixDofDragBehavior implements Behavior<Mesh> {
  122342. private static _virtualScene;
  122343. private _ownerNode;
  122344. private _sceneRenderObserver;
  122345. private _scene;
  122346. private _targetPosition;
  122347. private _virtualOriginMesh;
  122348. private _virtualDragMesh;
  122349. private _pointerObserver;
  122350. private _moving;
  122351. private _startingOrientation;
  122352. private _attachedElement;
  122353. /**
  122354. * 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)
  122355. */
  122356. private zDragFactor;
  122357. /**
  122358. * If the object should rotate to face the drag origin
  122359. */
  122360. rotateDraggedObject: boolean;
  122361. /**
  122362. * If the behavior is currently in a dragging state
  122363. */
  122364. dragging: boolean;
  122365. /**
  122366. * 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)
  122367. */
  122368. dragDeltaRatio: number;
  122369. /**
  122370. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122371. */
  122372. currentDraggingPointerID: number;
  122373. /**
  122374. * If camera controls should be detached during the drag
  122375. */
  122376. detachCameraControls: boolean;
  122377. /**
  122378. * Fires each time a drag starts
  122379. */
  122380. onDragStartObservable: Observable<{}>;
  122381. /**
  122382. * Fires each time a drag ends (eg. mouse release after drag)
  122383. */
  122384. onDragEndObservable: Observable<{}>;
  122385. /**
  122386. * 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
  122387. */
  122388. constructor();
  122389. /**
  122390. * The name of the behavior
  122391. */
  122392. get name(): string;
  122393. /**
  122394. * Initializes the behavior
  122395. */
  122396. init(): void;
  122397. /**
  122398. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122399. */
  122400. private get _pointerCamera();
  122401. /**
  122402. * Attaches the scale behavior the passed in mesh
  122403. * @param ownerNode The mesh that will be scaled around once attached
  122404. */
  122405. attach(ownerNode: Mesh): void;
  122406. /**
  122407. * Detaches the behavior from the mesh
  122408. */
  122409. detach(): void;
  122410. }
  122411. }
  122412. declare module BABYLON {
  122413. /**
  122414. * Class used to apply inverse kinematics to bones
  122415. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122416. */
  122417. export class BoneIKController {
  122418. private static _tmpVecs;
  122419. private static _tmpQuat;
  122420. private static _tmpMats;
  122421. /**
  122422. * Gets or sets the target mesh
  122423. */
  122424. targetMesh: AbstractMesh;
  122425. /** Gets or sets the mesh used as pole */
  122426. poleTargetMesh: AbstractMesh;
  122427. /**
  122428. * Gets or sets the bone used as pole
  122429. */
  122430. poleTargetBone: Nullable<Bone>;
  122431. /**
  122432. * Gets or sets the target position
  122433. */
  122434. targetPosition: Vector3;
  122435. /**
  122436. * Gets or sets the pole target position
  122437. */
  122438. poleTargetPosition: Vector3;
  122439. /**
  122440. * Gets or sets the pole target local offset
  122441. */
  122442. poleTargetLocalOffset: Vector3;
  122443. /**
  122444. * Gets or sets the pole angle
  122445. */
  122446. poleAngle: number;
  122447. /**
  122448. * Gets or sets the mesh associated with the controller
  122449. */
  122450. mesh: AbstractMesh;
  122451. /**
  122452. * 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)
  122453. */
  122454. slerpAmount: number;
  122455. private _bone1Quat;
  122456. private _bone1Mat;
  122457. private _bone2Ang;
  122458. private _bone1;
  122459. private _bone2;
  122460. private _bone1Length;
  122461. private _bone2Length;
  122462. private _maxAngle;
  122463. private _maxReach;
  122464. private _rightHandedSystem;
  122465. private _bendAxis;
  122466. private _slerping;
  122467. private _adjustRoll;
  122468. /**
  122469. * Gets or sets maximum allowed angle
  122470. */
  122471. get maxAngle(): number;
  122472. set maxAngle(value: number);
  122473. /**
  122474. * Creates a new BoneIKController
  122475. * @param mesh defines the mesh to control
  122476. * @param bone defines the bone to control
  122477. * @param options defines options to set up the controller
  122478. */
  122479. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  122480. targetMesh?: AbstractMesh;
  122481. poleTargetMesh?: AbstractMesh;
  122482. poleTargetBone?: Bone;
  122483. poleTargetLocalOffset?: Vector3;
  122484. poleAngle?: number;
  122485. bendAxis?: Vector3;
  122486. maxAngle?: number;
  122487. slerpAmount?: number;
  122488. });
  122489. private _setMaxAngle;
  122490. /**
  122491. * Force the controller to update the bones
  122492. */
  122493. update(): void;
  122494. }
  122495. }
  122496. declare module BABYLON {
  122497. /**
  122498. * Class used to make a bone look toward a point in space
  122499. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  122500. */
  122501. export class BoneLookController {
  122502. private static _tmpVecs;
  122503. private static _tmpQuat;
  122504. private static _tmpMats;
  122505. /**
  122506. * The target Vector3 that the bone will look at
  122507. */
  122508. target: Vector3;
  122509. /**
  122510. * The mesh that the bone is attached to
  122511. */
  122512. mesh: AbstractMesh;
  122513. /**
  122514. * The bone that will be looking to the target
  122515. */
  122516. bone: Bone;
  122517. /**
  122518. * The up axis of the coordinate system that is used when the bone is rotated
  122519. */
  122520. upAxis: Vector3;
  122521. /**
  122522. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  122523. */
  122524. upAxisSpace: Space;
  122525. /**
  122526. * Used to make an adjustment to the yaw of the bone
  122527. */
  122528. adjustYaw: number;
  122529. /**
  122530. * Used to make an adjustment to the pitch of the bone
  122531. */
  122532. adjustPitch: number;
  122533. /**
  122534. * Used to make an adjustment to the roll of the bone
  122535. */
  122536. adjustRoll: number;
  122537. /**
  122538. * 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)
  122539. */
  122540. slerpAmount: number;
  122541. private _minYaw;
  122542. private _maxYaw;
  122543. private _minPitch;
  122544. private _maxPitch;
  122545. private _minYawSin;
  122546. private _minYawCos;
  122547. private _maxYawSin;
  122548. private _maxYawCos;
  122549. private _midYawConstraint;
  122550. private _minPitchTan;
  122551. private _maxPitchTan;
  122552. private _boneQuat;
  122553. private _slerping;
  122554. private _transformYawPitch;
  122555. private _transformYawPitchInv;
  122556. private _firstFrameSkipped;
  122557. private _yawRange;
  122558. private _fowardAxis;
  122559. /**
  122560. * Gets or sets the minimum yaw angle that the bone can look to
  122561. */
  122562. get minYaw(): number;
  122563. set minYaw(value: number);
  122564. /**
  122565. * Gets or sets the maximum yaw angle that the bone can look to
  122566. */
  122567. get maxYaw(): number;
  122568. set maxYaw(value: number);
  122569. /**
  122570. * Gets or sets the minimum pitch angle that the bone can look to
  122571. */
  122572. get minPitch(): number;
  122573. set minPitch(value: number);
  122574. /**
  122575. * Gets or sets the maximum pitch angle that the bone can look to
  122576. */
  122577. get maxPitch(): number;
  122578. set maxPitch(value: number);
  122579. /**
  122580. * Create a BoneLookController
  122581. * @param mesh the mesh that the bone belongs to
  122582. * @param bone the bone that will be looking to the target
  122583. * @param target the target Vector3 to look at
  122584. * @param options optional settings:
  122585. * * maxYaw: the maximum angle the bone will yaw to
  122586. * * minYaw: the minimum angle the bone will yaw to
  122587. * * maxPitch: the maximum angle the bone will pitch to
  122588. * * minPitch: the minimum angle the bone will yaw to
  122589. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  122590. * * upAxis: the up axis of the coordinate system
  122591. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  122592. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  122593. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  122594. * * adjustYaw: used to make an adjustment to the yaw of the bone
  122595. * * adjustPitch: used to make an adjustment to the pitch of the bone
  122596. * * adjustRoll: used to make an adjustment to the roll of the bone
  122597. **/
  122598. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  122599. maxYaw?: number;
  122600. minYaw?: number;
  122601. maxPitch?: number;
  122602. minPitch?: number;
  122603. slerpAmount?: number;
  122604. upAxis?: Vector3;
  122605. upAxisSpace?: Space;
  122606. yawAxis?: Vector3;
  122607. pitchAxis?: Vector3;
  122608. adjustYaw?: number;
  122609. adjustPitch?: number;
  122610. adjustRoll?: number;
  122611. });
  122612. /**
  122613. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  122614. */
  122615. update(): void;
  122616. private _getAngleDiff;
  122617. private _getAngleBetween;
  122618. private _isAngleBetween;
  122619. }
  122620. }
  122621. declare module BABYLON {
  122622. /**
  122623. * Manage the gamepad inputs to control an arc rotate camera.
  122624. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122625. */
  122626. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  122627. /**
  122628. * Defines the camera the input is attached to.
  122629. */
  122630. camera: ArcRotateCamera;
  122631. /**
  122632. * Defines the gamepad the input is gathering event from.
  122633. */
  122634. gamepad: Nullable<Gamepad>;
  122635. /**
  122636. * Defines the gamepad rotation sensiblity.
  122637. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122638. */
  122639. gamepadRotationSensibility: number;
  122640. /**
  122641. * Defines the gamepad move sensiblity.
  122642. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122643. */
  122644. gamepadMoveSensibility: number;
  122645. private _yAxisScale;
  122646. /**
  122647. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122648. */
  122649. get invertYAxis(): boolean;
  122650. set invertYAxis(value: boolean);
  122651. private _onGamepadConnectedObserver;
  122652. private _onGamepadDisconnectedObserver;
  122653. /**
  122654. * Attach the input controls to a specific dom element to get the input from.
  122655. * @param element Defines the element the controls should be listened from
  122656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122657. */
  122658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122659. /**
  122660. * Detach the current controls from the specified dom element.
  122661. * @param element Defines the element to stop listening the inputs from
  122662. */
  122663. detachControl(element: Nullable<HTMLElement>): void;
  122664. /**
  122665. * Update the current camera state depending on the inputs that have been used this frame.
  122666. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122667. */
  122668. checkInputs(): void;
  122669. /**
  122670. * Gets the class name of the current intput.
  122671. * @returns the class name
  122672. */
  122673. getClassName(): string;
  122674. /**
  122675. * Get the friendly name associated with the input class.
  122676. * @returns the input friendly name
  122677. */
  122678. getSimpleName(): string;
  122679. }
  122680. }
  122681. declare module BABYLON {
  122682. interface ArcRotateCameraInputsManager {
  122683. /**
  122684. * Add orientation input support to the input manager.
  122685. * @returns the current input manager
  122686. */
  122687. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  122688. }
  122689. /**
  122690. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  122691. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122692. */
  122693. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  122694. /**
  122695. * Defines the camera the input is attached to.
  122696. */
  122697. camera: ArcRotateCamera;
  122698. /**
  122699. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  122700. */
  122701. alphaCorrection: number;
  122702. /**
  122703. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  122704. */
  122705. gammaCorrection: number;
  122706. private _alpha;
  122707. private _gamma;
  122708. private _dirty;
  122709. private _deviceOrientationHandler;
  122710. /**
  122711. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  122712. */
  122713. constructor();
  122714. /**
  122715. * Attach the input controls to a specific dom element to get the input from.
  122716. * @param element Defines the element the controls should be listened from
  122717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122718. */
  122719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122720. /** @hidden */
  122721. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  122722. /**
  122723. * Update the current camera state depending on the inputs that have been used this frame.
  122724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122725. */
  122726. checkInputs(): void;
  122727. /**
  122728. * Detach the current controls from the specified dom element.
  122729. * @param element Defines the element to stop listening the inputs from
  122730. */
  122731. detachControl(element: Nullable<HTMLElement>): void;
  122732. /**
  122733. * Gets the class name of the current intput.
  122734. * @returns the class name
  122735. */
  122736. getClassName(): string;
  122737. /**
  122738. * Get the friendly name associated with the input class.
  122739. * @returns the input friendly name
  122740. */
  122741. getSimpleName(): string;
  122742. }
  122743. }
  122744. declare module BABYLON {
  122745. /**
  122746. * Listen to mouse events to control the camera.
  122747. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122748. */
  122749. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  122750. /**
  122751. * Defines the camera the input is attached to.
  122752. */
  122753. camera: FlyCamera;
  122754. /**
  122755. * Defines if touch is enabled. (Default is true.)
  122756. */
  122757. touchEnabled: boolean;
  122758. /**
  122759. * Defines the buttons associated with the input to handle camera rotation.
  122760. */
  122761. buttons: number[];
  122762. /**
  122763. * Assign buttons for Yaw control.
  122764. */
  122765. buttonsYaw: number[];
  122766. /**
  122767. * Assign buttons for Pitch control.
  122768. */
  122769. buttonsPitch: number[];
  122770. /**
  122771. * Assign buttons for Roll control.
  122772. */
  122773. buttonsRoll: number[];
  122774. /**
  122775. * Detect if any button is being pressed while mouse is moved.
  122776. * -1 = Mouse locked.
  122777. * 0 = Left button.
  122778. * 1 = Middle Button.
  122779. * 2 = Right Button.
  122780. */
  122781. activeButton: number;
  122782. /**
  122783. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  122784. * Higher values reduce its sensitivity.
  122785. */
  122786. angularSensibility: number;
  122787. private _mousemoveCallback;
  122788. private _observer;
  122789. private _rollObserver;
  122790. private previousPosition;
  122791. private noPreventDefault;
  122792. private element;
  122793. /**
  122794. * Listen to mouse events to control the camera.
  122795. * @param touchEnabled Define if touch is enabled. (Default is true.)
  122796. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122797. */
  122798. constructor(touchEnabled?: boolean);
  122799. /**
  122800. * Attach the mouse control to the HTML DOM element.
  122801. * @param element Defines the element that listens to the input events.
  122802. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  122803. */
  122804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122805. /**
  122806. * Detach the current controls from the specified dom element.
  122807. * @param element Defines the element to stop listening the inputs from
  122808. */
  122809. detachControl(element: Nullable<HTMLElement>): void;
  122810. /**
  122811. * Gets the class name of the current input.
  122812. * @returns the class name.
  122813. */
  122814. getClassName(): string;
  122815. /**
  122816. * Get the friendly name associated with the input class.
  122817. * @returns the input's friendly name.
  122818. */
  122819. getSimpleName(): string;
  122820. private _pointerInput;
  122821. private _onMouseMove;
  122822. /**
  122823. * Rotate camera by mouse offset.
  122824. */
  122825. private rotateCamera;
  122826. }
  122827. }
  122828. declare module BABYLON {
  122829. /**
  122830. * Default Inputs manager for the FlyCamera.
  122831. * It groups all the default supported inputs for ease of use.
  122832. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122833. */
  122834. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  122835. /**
  122836. * Instantiates a new FlyCameraInputsManager.
  122837. * @param camera Defines the camera the inputs belong to.
  122838. */
  122839. constructor(camera: FlyCamera);
  122840. /**
  122841. * Add keyboard input support to the input manager.
  122842. * @returns the new FlyCameraKeyboardMoveInput().
  122843. */
  122844. addKeyboard(): FlyCameraInputsManager;
  122845. /**
  122846. * Add mouse input support to the input manager.
  122847. * @param touchEnabled Enable touch screen support.
  122848. * @returns the new FlyCameraMouseInput().
  122849. */
  122850. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  122851. }
  122852. }
  122853. declare module BABYLON {
  122854. /**
  122855. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122856. * such as in a 3D Space Shooter or a Flight Simulator.
  122857. */
  122858. export class FlyCamera extends TargetCamera {
  122859. /**
  122860. * Define the collision ellipsoid of the camera.
  122861. * This is helpful for simulating a camera body, like a player's body.
  122862. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122863. */
  122864. ellipsoid: Vector3;
  122865. /**
  122866. * Define an offset for the position of the ellipsoid around the camera.
  122867. * This can be helpful if the camera is attached away from the player's body center,
  122868. * such as at its head.
  122869. */
  122870. ellipsoidOffset: Vector3;
  122871. /**
  122872. * Enable or disable collisions of the camera with the rest of the scene objects.
  122873. */
  122874. checkCollisions: boolean;
  122875. /**
  122876. * Enable or disable gravity on the camera.
  122877. */
  122878. applyGravity: boolean;
  122879. /**
  122880. * Define the current direction the camera is moving to.
  122881. */
  122882. cameraDirection: Vector3;
  122883. /**
  122884. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  122885. * This overrides and empties cameraRotation.
  122886. */
  122887. rotationQuaternion: Quaternion;
  122888. /**
  122889. * Track Roll to maintain the wanted Rolling when looking around.
  122890. */
  122891. _trackRoll: number;
  122892. /**
  122893. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  122894. */
  122895. rollCorrect: number;
  122896. /**
  122897. * Mimic a banked turn, Rolling the camera when Yawing.
  122898. * It's recommended to use rollCorrect = 10 for faster banking correction.
  122899. */
  122900. bankedTurn: boolean;
  122901. /**
  122902. * Limit in radians for how much Roll banking will add. (Default: 90°)
  122903. */
  122904. bankedTurnLimit: number;
  122905. /**
  122906. * Value of 0 disables the banked Roll.
  122907. * Value of 1 is equal to the Yaw angle in radians.
  122908. */
  122909. bankedTurnMultiplier: number;
  122910. /**
  122911. * The inputs manager loads all the input sources, such as keyboard and mouse.
  122912. */
  122913. inputs: FlyCameraInputsManager;
  122914. /**
  122915. * Gets the input sensibility for mouse input.
  122916. * Higher values reduce sensitivity.
  122917. */
  122918. get angularSensibility(): number;
  122919. /**
  122920. * Sets the input sensibility for a mouse input.
  122921. * Higher values reduce sensitivity.
  122922. */
  122923. set angularSensibility(value: number);
  122924. /**
  122925. * Get the keys for camera movement forward.
  122926. */
  122927. get keysForward(): number[];
  122928. /**
  122929. * Set the keys for camera movement forward.
  122930. */
  122931. set keysForward(value: number[]);
  122932. /**
  122933. * Get the keys for camera movement backward.
  122934. */
  122935. get keysBackward(): number[];
  122936. set keysBackward(value: number[]);
  122937. /**
  122938. * Get the keys for camera movement up.
  122939. */
  122940. get keysUp(): number[];
  122941. /**
  122942. * Set the keys for camera movement up.
  122943. */
  122944. set keysUp(value: number[]);
  122945. /**
  122946. * Get the keys for camera movement down.
  122947. */
  122948. get keysDown(): number[];
  122949. /**
  122950. * Set the keys for camera movement down.
  122951. */
  122952. set keysDown(value: number[]);
  122953. /**
  122954. * Get the keys for camera movement left.
  122955. */
  122956. get keysLeft(): number[];
  122957. /**
  122958. * Set the keys for camera movement left.
  122959. */
  122960. set keysLeft(value: number[]);
  122961. /**
  122962. * Set the keys for camera movement right.
  122963. */
  122964. get keysRight(): number[];
  122965. /**
  122966. * Set the keys for camera movement right.
  122967. */
  122968. set keysRight(value: number[]);
  122969. /**
  122970. * Event raised when the camera collides with a mesh in the scene.
  122971. */
  122972. onCollide: (collidedMesh: AbstractMesh) => void;
  122973. private _collider;
  122974. private _needMoveForGravity;
  122975. private _oldPosition;
  122976. private _diffPosition;
  122977. private _newPosition;
  122978. /** @hidden */
  122979. _localDirection: Vector3;
  122980. /** @hidden */
  122981. _transformedDirection: Vector3;
  122982. /**
  122983. * Instantiates a FlyCamera.
  122984. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122985. * such as in a 3D Space Shooter or a Flight Simulator.
  122986. * @param name Define the name of the camera in the scene.
  122987. * @param position Define the starting position of the camera in the scene.
  122988. * @param scene Define the scene the camera belongs to.
  122989. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  122990. */
  122991. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122992. /**
  122993. * Attach a control to the HTML DOM element.
  122994. * @param element Defines the element that listens to the input events.
  122995. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  122996. */
  122997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122998. /**
  122999. * Detach a control from the HTML DOM element.
  123000. * The camera will stop reacting to that input.
  123001. * @param element Defines the element that listens to the input events.
  123002. */
  123003. detachControl(element: HTMLElement): void;
  123004. private _collisionMask;
  123005. /**
  123006. * Get the mask that the camera ignores in collision events.
  123007. */
  123008. get collisionMask(): number;
  123009. /**
  123010. * Set the mask that the camera ignores in collision events.
  123011. */
  123012. set collisionMask(mask: number);
  123013. /** @hidden */
  123014. _collideWithWorld(displacement: Vector3): void;
  123015. /** @hidden */
  123016. private _onCollisionPositionChange;
  123017. /** @hidden */
  123018. _checkInputs(): void;
  123019. /** @hidden */
  123020. _decideIfNeedsToMove(): boolean;
  123021. /** @hidden */
  123022. _updatePosition(): void;
  123023. /**
  123024. * Restore the Roll to its target value at the rate specified.
  123025. * @param rate - Higher means slower restoring.
  123026. * @hidden
  123027. */
  123028. restoreRoll(rate: number): void;
  123029. /**
  123030. * Destroy the camera and release the current resources held by it.
  123031. */
  123032. dispose(): void;
  123033. /**
  123034. * Get the current object class name.
  123035. * @returns the class name.
  123036. */
  123037. getClassName(): string;
  123038. }
  123039. }
  123040. declare module BABYLON {
  123041. /**
  123042. * Listen to keyboard events to control the camera.
  123043. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123044. */
  123045. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  123046. /**
  123047. * Defines the camera the input is attached to.
  123048. */
  123049. camera: FlyCamera;
  123050. /**
  123051. * The list of keyboard keys used to control the forward move of the camera.
  123052. */
  123053. keysForward: number[];
  123054. /**
  123055. * The list of keyboard keys used to control the backward move of the camera.
  123056. */
  123057. keysBackward: number[];
  123058. /**
  123059. * The list of keyboard keys used to control the forward move of the camera.
  123060. */
  123061. keysUp: number[];
  123062. /**
  123063. * The list of keyboard keys used to control the backward move of the camera.
  123064. */
  123065. keysDown: number[];
  123066. /**
  123067. * The list of keyboard keys used to control the right strafe move of the camera.
  123068. */
  123069. keysRight: number[];
  123070. /**
  123071. * The list of keyboard keys used to control the left strafe move of the camera.
  123072. */
  123073. keysLeft: number[];
  123074. private _keys;
  123075. private _onCanvasBlurObserver;
  123076. private _onKeyboardObserver;
  123077. private _engine;
  123078. private _scene;
  123079. /**
  123080. * Attach the input controls to a specific dom element to get the input from.
  123081. * @param element Defines the element the controls should be listened from
  123082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123083. */
  123084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123085. /**
  123086. * Detach the current controls from the specified dom element.
  123087. * @param element Defines the element to stop listening the inputs from
  123088. */
  123089. detachControl(element: Nullable<HTMLElement>): void;
  123090. /**
  123091. * Gets the class name of the current intput.
  123092. * @returns the class name
  123093. */
  123094. getClassName(): string;
  123095. /** @hidden */
  123096. _onLostFocus(e: FocusEvent): void;
  123097. /**
  123098. * Get the friendly name associated with the input class.
  123099. * @returns the input friendly name
  123100. */
  123101. getSimpleName(): string;
  123102. /**
  123103. * Update the current camera state depending on the inputs that have been used this frame.
  123104. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123105. */
  123106. checkInputs(): void;
  123107. }
  123108. }
  123109. declare module BABYLON {
  123110. /**
  123111. * Manage the mouse wheel inputs to control a follow camera.
  123112. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123113. */
  123114. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  123115. /**
  123116. * Defines the camera the input is attached to.
  123117. */
  123118. camera: FollowCamera;
  123119. /**
  123120. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  123121. */
  123122. axisControlRadius: boolean;
  123123. /**
  123124. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  123125. */
  123126. axisControlHeight: boolean;
  123127. /**
  123128. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  123129. */
  123130. axisControlRotation: boolean;
  123131. /**
  123132. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  123133. * relation to mouseWheel events.
  123134. */
  123135. wheelPrecision: number;
  123136. /**
  123137. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123138. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123139. */
  123140. wheelDeltaPercentage: number;
  123141. private _wheel;
  123142. private _observer;
  123143. /**
  123144. * Attach the input controls to a specific dom element to get the input from.
  123145. * @param element Defines the element the controls should be listened from
  123146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123147. */
  123148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123149. /**
  123150. * Detach the current controls from the specified dom element.
  123151. * @param element Defines the element to stop listening the inputs from
  123152. */
  123153. detachControl(element: Nullable<HTMLElement>): void;
  123154. /**
  123155. * Gets the class name of the current intput.
  123156. * @returns the class name
  123157. */
  123158. getClassName(): string;
  123159. /**
  123160. * Get the friendly name associated with the input class.
  123161. * @returns the input friendly name
  123162. */
  123163. getSimpleName(): string;
  123164. }
  123165. }
  123166. declare module BABYLON {
  123167. /**
  123168. * Manage the pointers inputs to control an follow camera.
  123169. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123170. */
  123171. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  123172. /**
  123173. * Defines the camera the input is attached to.
  123174. */
  123175. camera: FollowCamera;
  123176. /**
  123177. * Gets the class name of the current input.
  123178. * @returns the class name
  123179. */
  123180. getClassName(): string;
  123181. /**
  123182. * Defines the pointer angular sensibility along the X axis or how fast is
  123183. * the camera rotating.
  123184. * A negative number will reverse the axis direction.
  123185. */
  123186. angularSensibilityX: number;
  123187. /**
  123188. * Defines the pointer angular sensibility along the Y axis or how fast is
  123189. * the camera rotating.
  123190. * A negative number will reverse the axis direction.
  123191. */
  123192. angularSensibilityY: number;
  123193. /**
  123194. * Defines the pointer pinch precision or how fast is the camera zooming.
  123195. * A negative number will reverse the axis direction.
  123196. */
  123197. pinchPrecision: number;
  123198. /**
  123199. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123200. * from 0.
  123201. * It defines the percentage of current camera.radius to use as delta when
  123202. * pinch zoom is used.
  123203. */
  123204. pinchDeltaPercentage: number;
  123205. /**
  123206. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  123207. */
  123208. axisXControlRadius: boolean;
  123209. /**
  123210. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  123211. */
  123212. axisXControlHeight: boolean;
  123213. /**
  123214. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  123215. */
  123216. axisXControlRotation: boolean;
  123217. /**
  123218. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  123219. */
  123220. axisYControlRadius: boolean;
  123221. /**
  123222. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  123223. */
  123224. axisYControlHeight: boolean;
  123225. /**
  123226. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  123227. */
  123228. axisYControlRotation: boolean;
  123229. /**
  123230. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  123231. */
  123232. axisPinchControlRadius: boolean;
  123233. /**
  123234. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  123235. */
  123236. axisPinchControlHeight: boolean;
  123237. /**
  123238. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  123239. */
  123240. axisPinchControlRotation: boolean;
  123241. /**
  123242. * Log error messages if basic misconfiguration has occurred.
  123243. */
  123244. warningEnable: boolean;
  123245. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123246. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123247. private _warningCounter;
  123248. private _warning;
  123249. }
  123250. }
  123251. declare module BABYLON {
  123252. /**
  123253. * Default Inputs manager for the FollowCamera.
  123254. * It groups all the default supported inputs for ease of use.
  123255. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123256. */
  123257. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  123258. /**
  123259. * Instantiates a new FollowCameraInputsManager.
  123260. * @param camera Defines the camera the inputs belong to
  123261. */
  123262. constructor(camera: FollowCamera);
  123263. /**
  123264. * Add keyboard input support to the input manager.
  123265. * @returns the current input manager
  123266. */
  123267. addKeyboard(): FollowCameraInputsManager;
  123268. /**
  123269. * Add mouse wheel input support to the input manager.
  123270. * @returns the current input manager
  123271. */
  123272. addMouseWheel(): FollowCameraInputsManager;
  123273. /**
  123274. * Add pointers input support to the input manager.
  123275. * @returns the current input manager
  123276. */
  123277. addPointers(): FollowCameraInputsManager;
  123278. /**
  123279. * Add orientation input support to the input manager.
  123280. * @returns the current input manager
  123281. */
  123282. addVRDeviceOrientation(): FollowCameraInputsManager;
  123283. }
  123284. }
  123285. declare module BABYLON {
  123286. /**
  123287. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  123288. * an arc rotate version arcFollowCamera are available.
  123289. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123290. */
  123291. export class FollowCamera extends TargetCamera {
  123292. /**
  123293. * Distance the follow camera should follow an object at
  123294. */
  123295. radius: number;
  123296. /**
  123297. * Minimum allowed distance of the camera to the axis of rotation
  123298. * (The camera can not get closer).
  123299. * This can help limiting how the Camera is able to move in the scene.
  123300. */
  123301. lowerRadiusLimit: Nullable<number>;
  123302. /**
  123303. * Maximum allowed distance of the camera to the axis of rotation
  123304. * (The camera can not get further).
  123305. * This can help limiting how the Camera is able to move in the scene.
  123306. */
  123307. upperRadiusLimit: Nullable<number>;
  123308. /**
  123309. * Define a rotation offset between the camera and the object it follows
  123310. */
  123311. rotationOffset: number;
  123312. /**
  123313. * Minimum 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. lowerRotationOffsetLimit: Nullable<number>;
  123317. /**
  123318. * Maximum allowed angle to camera position relative to target object.
  123319. * This can help limiting how the Camera is able to move in the scene.
  123320. */
  123321. upperRotationOffsetLimit: Nullable<number>;
  123322. /**
  123323. * Define a height offset between the camera and the object it follows.
  123324. * It can help following an object from the top (like a car chaing a plane)
  123325. */
  123326. heightOffset: number;
  123327. /**
  123328. * Minimum 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. lowerHeightOffsetLimit: Nullable<number>;
  123332. /**
  123333. * Maximum allowed height of camera position relative to target object.
  123334. * This can help limiting how the Camera is able to move in the scene.
  123335. */
  123336. upperHeightOffsetLimit: Nullable<number>;
  123337. /**
  123338. * Define how fast the camera can accelerate to follow it s target.
  123339. */
  123340. cameraAcceleration: number;
  123341. /**
  123342. * Define the speed limit of the camera following an object.
  123343. */
  123344. maxCameraSpeed: number;
  123345. /**
  123346. * Define the target of the camera.
  123347. */
  123348. lockedTarget: Nullable<AbstractMesh>;
  123349. /**
  123350. * Defines the input associated with the camera.
  123351. */
  123352. inputs: FollowCameraInputsManager;
  123353. /**
  123354. * Instantiates the follow camera.
  123355. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123356. * @param name Define the name of the camera in the scene
  123357. * @param position Define the position of the camera
  123358. * @param scene Define the scene the camera belong to
  123359. * @param lockedTarget Define the target of the camera
  123360. */
  123361. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  123362. private _follow;
  123363. /**
  123364. * Attached controls to the current camera.
  123365. * @param element Defines the element the controls should be listened from
  123366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123367. */
  123368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123369. /**
  123370. * Detach the current controls from the camera.
  123371. * The camera will stop reacting to inputs.
  123372. * @param element Defines the element to stop listening the inputs from
  123373. */
  123374. detachControl(element: HTMLElement): void;
  123375. /** @hidden */
  123376. _checkInputs(): void;
  123377. private _checkLimits;
  123378. /**
  123379. * Gets the camera class name.
  123380. * @returns the class name
  123381. */
  123382. getClassName(): string;
  123383. }
  123384. /**
  123385. * Arc Rotate version of the follow camera.
  123386. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123387. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123388. */
  123389. export class ArcFollowCamera extends TargetCamera {
  123390. /** The longitudinal angle of the camera */
  123391. alpha: number;
  123392. /** The latitudinal angle of the camera */
  123393. beta: number;
  123394. /** The radius of the camera from its target */
  123395. radius: number;
  123396. /** Define the camera target (the mesh it should follow) */
  123397. target: Nullable<AbstractMesh>;
  123398. private _cartesianCoordinates;
  123399. /**
  123400. * Instantiates a new ArcFollowCamera
  123401. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123402. * @param name Define the name of the camera
  123403. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123404. * @param beta Define the rotation angle of the camera around the elevation axis
  123405. * @param radius Define the radius of the camera from its target point
  123406. * @param target Define the target of the camera
  123407. * @param scene Define the scene the camera belongs to
  123408. */
  123409. constructor(name: string,
  123410. /** The longitudinal angle of the camera */
  123411. alpha: number,
  123412. /** The latitudinal angle of the camera */
  123413. beta: number,
  123414. /** The radius of the camera from its target */
  123415. radius: number,
  123416. /** Define the camera target (the mesh it should follow) */
  123417. target: Nullable<AbstractMesh>, scene: Scene);
  123418. private _follow;
  123419. /** @hidden */
  123420. _checkInputs(): void;
  123421. /**
  123422. * Returns the class name of the object.
  123423. * It is mostly used internally for serialization purposes.
  123424. */
  123425. getClassName(): string;
  123426. }
  123427. }
  123428. declare module BABYLON {
  123429. /**
  123430. * Manage the keyboard inputs to control the movement of a follow camera.
  123431. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123432. */
  123433. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123434. /**
  123435. * Defines the camera the input is attached to.
  123436. */
  123437. camera: FollowCamera;
  123438. /**
  123439. * Defines the list of key codes associated with the up action (increase heightOffset)
  123440. */
  123441. keysHeightOffsetIncr: number[];
  123442. /**
  123443. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123444. */
  123445. keysHeightOffsetDecr: number[];
  123446. /**
  123447. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123448. */
  123449. keysHeightOffsetModifierAlt: boolean;
  123450. /**
  123451. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123452. */
  123453. keysHeightOffsetModifierCtrl: boolean;
  123454. /**
  123455. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123456. */
  123457. keysHeightOffsetModifierShift: boolean;
  123458. /**
  123459. * Defines the list of key codes associated with the left action (increase rotationOffset)
  123460. */
  123461. keysRotationOffsetIncr: number[];
  123462. /**
  123463. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  123464. */
  123465. keysRotationOffsetDecr: number[];
  123466. /**
  123467. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  123468. */
  123469. keysRotationOffsetModifierAlt: boolean;
  123470. /**
  123471. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  123472. */
  123473. keysRotationOffsetModifierCtrl: boolean;
  123474. /**
  123475. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  123476. */
  123477. keysRotationOffsetModifierShift: boolean;
  123478. /**
  123479. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  123480. */
  123481. keysRadiusIncr: number[];
  123482. /**
  123483. * Defines the list of key codes associated with the zoom-out action (increase radius)
  123484. */
  123485. keysRadiusDecr: number[];
  123486. /**
  123487. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  123488. */
  123489. keysRadiusModifierAlt: boolean;
  123490. /**
  123491. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  123492. */
  123493. keysRadiusModifierCtrl: boolean;
  123494. /**
  123495. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  123496. */
  123497. keysRadiusModifierShift: boolean;
  123498. /**
  123499. * Defines the rate of change of heightOffset.
  123500. */
  123501. heightSensibility: number;
  123502. /**
  123503. * Defines the rate of change of rotationOffset.
  123504. */
  123505. rotationSensibility: number;
  123506. /**
  123507. * Defines the rate of change of radius.
  123508. */
  123509. radiusSensibility: number;
  123510. private _keys;
  123511. private _ctrlPressed;
  123512. private _altPressed;
  123513. private _shiftPressed;
  123514. private _onCanvasBlurObserver;
  123515. private _onKeyboardObserver;
  123516. private _engine;
  123517. private _scene;
  123518. /**
  123519. * Attach the input controls to a specific dom element to get the input from.
  123520. * @param element Defines the element the controls should be listened from
  123521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123522. */
  123523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123524. /**
  123525. * Detach the current controls from the specified dom element.
  123526. * @param element Defines the element to stop listening the inputs from
  123527. */
  123528. detachControl(element: Nullable<HTMLElement>): void;
  123529. /**
  123530. * Update the current camera state depending on the inputs that have been used this frame.
  123531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123532. */
  123533. checkInputs(): void;
  123534. /**
  123535. * Gets the class name of the current input.
  123536. * @returns the class name
  123537. */
  123538. getClassName(): string;
  123539. /**
  123540. * Get the friendly name associated with the input class.
  123541. * @returns the input friendly name
  123542. */
  123543. getSimpleName(): string;
  123544. /**
  123545. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123546. * allow modification of the heightOffset value.
  123547. */
  123548. private _modifierHeightOffset;
  123549. /**
  123550. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123551. * allow modification of the rotationOffset value.
  123552. */
  123553. private _modifierRotationOffset;
  123554. /**
  123555. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123556. * allow modification of the radius value.
  123557. */
  123558. private _modifierRadius;
  123559. }
  123560. }
  123561. declare module BABYLON {
  123562. interface FreeCameraInputsManager {
  123563. /**
  123564. * @hidden
  123565. */
  123566. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  123567. /**
  123568. * Add orientation input support to the input manager.
  123569. * @returns the current input manager
  123570. */
  123571. addDeviceOrientation(): FreeCameraInputsManager;
  123572. }
  123573. /**
  123574. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  123575. * Screen rotation is taken into account.
  123576. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123577. */
  123578. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  123579. private _camera;
  123580. private _screenOrientationAngle;
  123581. private _constantTranform;
  123582. private _screenQuaternion;
  123583. private _alpha;
  123584. private _beta;
  123585. private _gamma;
  123586. /**
  123587. * Can be used to detect if a device orientation sensor is available on a device
  123588. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  123589. * @returns a promise that will resolve on orientation change
  123590. */
  123591. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  123592. /**
  123593. * @hidden
  123594. */
  123595. _onDeviceOrientationChangedObservable: Observable<void>;
  123596. /**
  123597. * Instantiates a new input
  123598. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123599. */
  123600. constructor();
  123601. /**
  123602. * Define the camera controlled by the input.
  123603. */
  123604. get camera(): FreeCamera;
  123605. set camera(camera: FreeCamera);
  123606. /**
  123607. * Attach the input controls to a specific dom element to get the input from.
  123608. * @param element Defines the element the controls should be listened from
  123609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123610. */
  123611. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123612. private _orientationChanged;
  123613. private _deviceOrientation;
  123614. /**
  123615. * Detach the current controls from the specified dom element.
  123616. * @param element Defines the element to stop listening the inputs from
  123617. */
  123618. detachControl(element: Nullable<HTMLElement>): void;
  123619. /**
  123620. * Update the current camera state depending on the inputs that have been used this frame.
  123621. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123622. */
  123623. checkInputs(): void;
  123624. /**
  123625. * Gets the class name of the current intput.
  123626. * @returns the class name
  123627. */
  123628. getClassName(): string;
  123629. /**
  123630. * Get the friendly name associated with the input class.
  123631. * @returns the input friendly name
  123632. */
  123633. getSimpleName(): string;
  123634. }
  123635. }
  123636. declare module BABYLON {
  123637. /**
  123638. * Manage the gamepad inputs to control a free camera.
  123639. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123640. */
  123641. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  123642. /**
  123643. * Define the camera the input is attached to.
  123644. */
  123645. camera: FreeCamera;
  123646. /**
  123647. * Define the Gamepad controlling the input
  123648. */
  123649. gamepad: Nullable<Gamepad>;
  123650. /**
  123651. * Defines the gamepad rotation sensiblity.
  123652. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123653. */
  123654. gamepadAngularSensibility: number;
  123655. /**
  123656. * Defines the gamepad move sensiblity.
  123657. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123658. */
  123659. gamepadMoveSensibility: number;
  123660. private _yAxisScale;
  123661. /**
  123662. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123663. */
  123664. get invertYAxis(): boolean;
  123665. set invertYAxis(value: boolean);
  123666. private _onGamepadConnectedObserver;
  123667. private _onGamepadDisconnectedObserver;
  123668. private _cameraTransform;
  123669. private _deltaTransform;
  123670. private _vector3;
  123671. private _vector2;
  123672. /**
  123673. * Attach the input controls to a specific dom element to get the input from.
  123674. * @param element Defines the element the controls should be listened from
  123675. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123676. */
  123677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123678. /**
  123679. * Detach the current controls from the specified dom element.
  123680. * @param element Defines the element to stop listening the inputs from
  123681. */
  123682. detachControl(element: Nullable<HTMLElement>): void;
  123683. /**
  123684. * Update the current camera state depending on the inputs that have been used this frame.
  123685. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123686. */
  123687. checkInputs(): void;
  123688. /**
  123689. * Gets the class name of the current intput.
  123690. * @returns the class name
  123691. */
  123692. getClassName(): string;
  123693. /**
  123694. * Get the friendly name associated with the input class.
  123695. * @returns the input friendly name
  123696. */
  123697. getSimpleName(): string;
  123698. }
  123699. }
  123700. declare module BABYLON {
  123701. /**
  123702. * Defines the potential axis of a Joystick
  123703. */
  123704. export enum JoystickAxis {
  123705. /** X axis */
  123706. X = 0,
  123707. /** Y axis */
  123708. Y = 1,
  123709. /** Z axis */
  123710. Z = 2
  123711. }
  123712. /**
  123713. * Represents the different customization options available
  123714. * for VirtualJoystick
  123715. */
  123716. interface VirtualJoystickCustomizations {
  123717. /**
  123718. * Size of the joystick's puck
  123719. */
  123720. puckSize: number;
  123721. /**
  123722. * Size of the joystick's container
  123723. */
  123724. containerSize: number;
  123725. /**
  123726. * Color of the joystick && puck
  123727. */
  123728. color: string;
  123729. /**
  123730. * Image URL for the joystick's puck
  123731. */
  123732. puckImage?: string;
  123733. /**
  123734. * Image URL for the joystick's container
  123735. */
  123736. containerImage?: string;
  123737. /**
  123738. * Defines the unmoving position of the joystick container
  123739. */
  123740. position?: {
  123741. x: number;
  123742. y: number;
  123743. };
  123744. /**
  123745. * Defines whether or not the joystick container is always visible
  123746. */
  123747. alwaysVisible: boolean;
  123748. /**
  123749. * Defines whether or not to limit the movement of the puck to the joystick's container
  123750. */
  123751. limitToContainer: boolean;
  123752. }
  123753. /**
  123754. * Class used to define virtual joystick (used in touch mode)
  123755. */
  123756. export class VirtualJoystick {
  123757. /**
  123758. * Gets or sets a boolean indicating that left and right values must be inverted
  123759. */
  123760. reverseLeftRight: boolean;
  123761. /**
  123762. * Gets or sets a boolean indicating that up and down values must be inverted
  123763. */
  123764. reverseUpDown: boolean;
  123765. /**
  123766. * Gets the offset value for the position (ie. the change of the position value)
  123767. */
  123768. deltaPosition: Vector3;
  123769. /**
  123770. * Gets a boolean indicating if the virtual joystick was pressed
  123771. */
  123772. pressed: boolean;
  123773. /**
  123774. * Canvas the virtual joystick will render onto, default z-index of this is 5
  123775. */
  123776. static Canvas: Nullable<HTMLCanvasElement>;
  123777. /**
  123778. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  123779. */
  123780. limitToContainer: boolean;
  123781. private static _globalJoystickIndex;
  123782. private static _alwaysVisibleSticks;
  123783. private static vjCanvasContext;
  123784. private static vjCanvasWidth;
  123785. private static vjCanvasHeight;
  123786. private static halfWidth;
  123787. private static _GetDefaultOptions;
  123788. private _action;
  123789. private _axisTargetedByLeftAndRight;
  123790. private _axisTargetedByUpAndDown;
  123791. private _joystickSensibility;
  123792. private _inversedSensibility;
  123793. private _joystickPointerID;
  123794. private _joystickColor;
  123795. private _joystickPointerPos;
  123796. private _joystickPreviousPointerPos;
  123797. private _joystickPointerStartPos;
  123798. private _deltaJoystickVector;
  123799. private _leftJoystick;
  123800. private _touches;
  123801. private _joystickPosition;
  123802. private _alwaysVisible;
  123803. private _puckImage;
  123804. private _containerImage;
  123805. private _joystickPuckSize;
  123806. private _joystickContainerSize;
  123807. private _clearPuckSize;
  123808. private _clearContainerSize;
  123809. private _clearPuckSizeOffset;
  123810. private _clearContainerSizeOffset;
  123811. private _onPointerDownHandlerRef;
  123812. private _onPointerMoveHandlerRef;
  123813. private _onPointerUpHandlerRef;
  123814. private _onResize;
  123815. /**
  123816. * Creates a new virtual joystick
  123817. * @param leftJoystick defines that the joystick is for left hand (false by default)
  123818. * @param customizations Defines the options we want to customize the VirtualJoystick
  123819. */
  123820. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  123821. /**
  123822. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  123823. * @param newJoystickSensibility defines the new sensibility
  123824. */
  123825. setJoystickSensibility(newJoystickSensibility: number): void;
  123826. private _onPointerDown;
  123827. private _onPointerMove;
  123828. private _onPointerUp;
  123829. /**
  123830. * Change the color of the virtual joystick
  123831. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  123832. */
  123833. setJoystickColor(newColor: string): void;
  123834. /**
  123835. * Size of the joystick's container
  123836. */
  123837. set containerSize(newSize: number);
  123838. get containerSize(): number;
  123839. /**
  123840. * Size of the joystick's puck
  123841. */
  123842. set puckSize(newSize: number);
  123843. get puckSize(): number;
  123844. /**
  123845. * Clears the set position of the joystick
  123846. */
  123847. clearPosition(): void;
  123848. /**
  123849. * Defines whether or not the joystick container is always visible
  123850. */
  123851. set alwaysVisible(value: boolean);
  123852. get alwaysVisible(): boolean;
  123853. /**
  123854. * Sets the constant position of the Joystick container
  123855. * @param x X axis coordinate
  123856. * @param y Y axis coordinate
  123857. */
  123858. setPosition(x: number, y: number): void;
  123859. /**
  123860. * Defines a callback to call when the joystick is touched
  123861. * @param action defines the callback
  123862. */
  123863. setActionOnTouch(action: () => any): void;
  123864. /**
  123865. * Defines which axis you'd like to control for left & right
  123866. * @param axis defines the axis to use
  123867. */
  123868. setAxisForLeftRight(axis: JoystickAxis): void;
  123869. /**
  123870. * Defines which axis you'd like to control for up & down
  123871. * @param axis defines the axis to use
  123872. */
  123873. setAxisForUpDown(axis: JoystickAxis): void;
  123874. /**
  123875. * Clears the canvas from the previous puck / container draw
  123876. */
  123877. private _clearPreviousDraw;
  123878. /**
  123879. * Loads `urlPath` to be used for the container's image
  123880. * @param urlPath defines the urlPath of an image to use
  123881. */
  123882. setContainerImage(urlPath: string): void;
  123883. /**
  123884. * Loads `urlPath` to be used for the puck's image
  123885. * @param urlPath defines the urlPath of an image to use
  123886. */
  123887. setPuckImage(urlPath: string): void;
  123888. /**
  123889. * Draws the Virtual Joystick's container
  123890. */
  123891. private _drawContainer;
  123892. /**
  123893. * Draws the Virtual Joystick's puck
  123894. */
  123895. private _drawPuck;
  123896. private _drawVirtualJoystick;
  123897. /**
  123898. * Release internal HTML canvas
  123899. */
  123900. releaseCanvas(): void;
  123901. }
  123902. }
  123903. declare module BABYLON {
  123904. interface FreeCameraInputsManager {
  123905. /**
  123906. * Add virtual joystick input support to the input manager.
  123907. * @returns the current input manager
  123908. */
  123909. addVirtualJoystick(): FreeCameraInputsManager;
  123910. }
  123911. /**
  123912. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  123913. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123914. */
  123915. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  123916. /**
  123917. * Defines the camera the input is attached to.
  123918. */
  123919. camera: FreeCamera;
  123920. private _leftjoystick;
  123921. private _rightjoystick;
  123922. /**
  123923. * Gets the left stick of the virtual joystick.
  123924. * @returns The virtual Joystick
  123925. */
  123926. getLeftJoystick(): VirtualJoystick;
  123927. /**
  123928. * Gets the right stick of the virtual joystick.
  123929. * @returns The virtual Joystick
  123930. */
  123931. getRightJoystick(): VirtualJoystick;
  123932. /**
  123933. * Update the current camera state depending on the inputs that have been used this frame.
  123934. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123935. */
  123936. checkInputs(): void;
  123937. /**
  123938. * Attach the input controls to a specific dom element to get the input from.
  123939. * @param element Defines the element the controls should be listened from
  123940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123941. */
  123942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123943. /**
  123944. * Detach the current controls from the specified dom element.
  123945. * @param element Defines the element to stop listening the inputs from
  123946. */
  123947. detachControl(element: Nullable<HTMLElement>): void;
  123948. /**
  123949. * Gets the class name of the current intput.
  123950. * @returns the class name
  123951. */
  123952. getClassName(): string;
  123953. /**
  123954. * Get the friendly name associated with the input class.
  123955. * @returns the input friendly name
  123956. */
  123957. getSimpleName(): string;
  123958. }
  123959. }
  123960. declare module BABYLON {
  123961. /**
  123962. * This represents a FPS type of camera controlled by touch.
  123963. * This is like a universal camera minus the Gamepad controls.
  123964. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123965. */
  123966. export class TouchCamera extends FreeCamera {
  123967. /**
  123968. * Defines the touch sensibility for rotation.
  123969. * The higher the faster.
  123970. */
  123971. get touchAngularSensibility(): number;
  123972. set touchAngularSensibility(value: number);
  123973. /**
  123974. * Defines the touch sensibility for move.
  123975. * The higher the faster.
  123976. */
  123977. get touchMoveSensibility(): number;
  123978. set touchMoveSensibility(value: number);
  123979. /**
  123980. * Instantiates a new touch camera.
  123981. * This represents a FPS type of camera controlled by touch.
  123982. * This is like a universal camera minus the Gamepad controls.
  123983. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123984. * @param name Define the name of the camera in the scene
  123985. * @param position Define the start position of the camera in the scene
  123986. * @param scene Define the scene the camera belongs to
  123987. */
  123988. constructor(name: string, position: Vector3, scene: Scene);
  123989. /**
  123990. * Gets the current object class name.
  123991. * @return the class name
  123992. */
  123993. getClassName(): string;
  123994. /** @hidden */
  123995. _setupInputs(): void;
  123996. }
  123997. }
  123998. declare module BABYLON {
  123999. /**
  124000. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  124001. * being tilted forward or back and left or right.
  124002. */
  124003. export class DeviceOrientationCamera extends FreeCamera {
  124004. private _initialQuaternion;
  124005. private _quaternionCache;
  124006. private _tmpDragQuaternion;
  124007. private _disablePointerInputWhenUsingDeviceOrientation;
  124008. /**
  124009. * Creates a new device orientation camera
  124010. * @param name The name of the camera
  124011. * @param position The start position camera
  124012. * @param scene The scene the camera belongs to
  124013. */
  124014. constructor(name: string, position: Vector3, scene: Scene);
  124015. /**
  124016. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  124017. */
  124018. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  124019. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  124020. private _dragFactor;
  124021. /**
  124022. * Enabled turning on the y axis when the orientation sensor is active
  124023. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  124024. */
  124025. enableHorizontalDragging(dragFactor?: number): void;
  124026. /**
  124027. * Gets the current instance class name ("DeviceOrientationCamera").
  124028. * This helps avoiding instanceof at run time.
  124029. * @returns the class name
  124030. */
  124031. getClassName(): string;
  124032. /**
  124033. * @hidden
  124034. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  124035. */
  124036. _checkInputs(): void;
  124037. /**
  124038. * Reset the camera to its default orientation on the specified axis only.
  124039. * @param axis The axis to reset
  124040. */
  124041. resetToCurrentRotation(axis?: Axis): void;
  124042. }
  124043. }
  124044. declare module BABYLON {
  124045. /**
  124046. * Defines supported buttons for XBox360 compatible gamepads
  124047. */
  124048. export enum Xbox360Button {
  124049. /** A */
  124050. A = 0,
  124051. /** B */
  124052. B = 1,
  124053. /** X */
  124054. X = 2,
  124055. /** Y */
  124056. Y = 3,
  124057. /** Left button */
  124058. LB = 4,
  124059. /** Right button */
  124060. RB = 5,
  124061. /** Back */
  124062. Back = 8,
  124063. /** Start */
  124064. Start = 9,
  124065. /** Left stick */
  124066. LeftStick = 10,
  124067. /** Right stick */
  124068. RightStick = 11
  124069. }
  124070. /** Defines values for XBox360 DPad */
  124071. export enum Xbox360Dpad {
  124072. /** Up */
  124073. Up = 12,
  124074. /** Down */
  124075. Down = 13,
  124076. /** Left */
  124077. Left = 14,
  124078. /** Right */
  124079. Right = 15
  124080. }
  124081. /**
  124082. * Defines a XBox360 gamepad
  124083. */
  124084. export class Xbox360Pad extends Gamepad {
  124085. private _leftTrigger;
  124086. private _rightTrigger;
  124087. private _onlefttriggerchanged;
  124088. private _onrighttriggerchanged;
  124089. private _onbuttondown;
  124090. private _onbuttonup;
  124091. private _ondpaddown;
  124092. private _ondpadup;
  124093. /** Observable raised when a button is pressed */
  124094. onButtonDownObservable: Observable<Xbox360Button>;
  124095. /** Observable raised when a button is released */
  124096. onButtonUpObservable: Observable<Xbox360Button>;
  124097. /** Observable raised when a pad is pressed */
  124098. onPadDownObservable: Observable<Xbox360Dpad>;
  124099. /** Observable raised when a pad is released */
  124100. onPadUpObservable: Observable<Xbox360Dpad>;
  124101. private _buttonA;
  124102. private _buttonB;
  124103. private _buttonX;
  124104. private _buttonY;
  124105. private _buttonBack;
  124106. private _buttonStart;
  124107. private _buttonLB;
  124108. private _buttonRB;
  124109. private _buttonLeftStick;
  124110. private _buttonRightStick;
  124111. private _dPadUp;
  124112. private _dPadDown;
  124113. private _dPadLeft;
  124114. private _dPadRight;
  124115. private _isXboxOnePad;
  124116. /**
  124117. * Creates a new XBox360 gamepad object
  124118. * @param id defines the id of this gamepad
  124119. * @param index defines its index
  124120. * @param gamepad defines the internal HTML gamepad object
  124121. * @param xboxOne defines if it is a XBox One gamepad
  124122. */
  124123. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  124124. /**
  124125. * Defines the callback to call when left trigger is pressed
  124126. * @param callback defines the callback to use
  124127. */
  124128. onlefttriggerchanged(callback: (value: number) => void): void;
  124129. /**
  124130. * Defines the callback to call when right trigger is pressed
  124131. * @param callback defines the callback to use
  124132. */
  124133. onrighttriggerchanged(callback: (value: number) => void): void;
  124134. /**
  124135. * Gets the left trigger value
  124136. */
  124137. get leftTrigger(): number;
  124138. /**
  124139. * Sets the left trigger value
  124140. */
  124141. set leftTrigger(newValue: number);
  124142. /**
  124143. * Gets the right trigger value
  124144. */
  124145. get rightTrigger(): number;
  124146. /**
  124147. * Sets the right trigger value
  124148. */
  124149. set rightTrigger(newValue: number);
  124150. /**
  124151. * Defines the callback to call when a button is pressed
  124152. * @param callback defines the callback to use
  124153. */
  124154. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  124155. /**
  124156. * Defines the callback to call when a button is released
  124157. * @param callback defines the callback to use
  124158. */
  124159. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  124160. /**
  124161. * Defines the callback to call when a pad is pressed
  124162. * @param callback defines the callback to use
  124163. */
  124164. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  124165. /**
  124166. * Defines the callback to call when a pad is released
  124167. * @param callback defines the callback to use
  124168. */
  124169. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  124170. private _setButtonValue;
  124171. private _setDPadValue;
  124172. /**
  124173. * Gets the value of the `A` button
  124174. */
  124175. get buttonA(): number;
  124176. /**
  124177. * Sets the value of the `A` button
  124178. */
  124179. set buttonA(value: number);
  124180. /**
  124181. * Gets the value of the `B` button
  124182. */
  124183. get buttonB(): number;
  124184. /**
  124185. * Sets the value of the `B` button
  124186. */
  124187. set buttonB(value: number);
  124188. /**
  124189. * Gets the value of the `X` button
  124190. */
  124191. get buttonX(): number;
  124192. /**
  124193. * Sets the value of the `X` button
  124194. */
  124195. set buttonX(value: number);
  124196. /**
  124197. * Gets the value of the `Y` button
  124198. */
  124199. get buttonY(): number;
  124200. /**
  124201. * Sets the value of the `Y` button
  124202. */
  124203. set buttonY(value: number);
  124204. /**
  124205. * Gets the value of the `Start` button
  124206. */
  124207. get buttonStart(): number;
  124208. /**
  124209. * Sets the value of the `Start` button
  124210. */
  124211. set buttonStart(value: number);
  124212. /**
  124213. * Gets the value of the `Back` button
  124214. */
  124215. get buttonBack(): number;
  124216. /**
  124217. * Sets the value of the `Back` button
  124218. */
  124219. set buttonBack(value: number);
  124220. /**
  124221. * Gets the value of the `Left` button
  124222. */
  124223. get buttonLB(): number;
  124224. /**
  124225. * Sets the value of the `Left` button
  124226. */
  124227. set buttonLB(value: number);
  124228. /**
  124229. * Gets the value of the `Right` button
  124230. */
  124231. get buttonRB(): number;
  124232. /**
  124233. * Sets the value of the `Right` button
  124234. */
  124235. set buttonRB(value: number);
  124236. /**
  124237. * Gets the value of the Left joystick
  124238. */
  124239. get buttonLeftStick(): number;
  124240. /**
  124241. * Sets the value of the Left joystick
  124242. */
  124243. set buttonLeftStick(value: number);
  124244. /**
  124245. * Gets the value of the Right joystick
  124246. */
  124247. get buttonRightStick(): number;
  124248. /**
  124249. * Sets the value of the Right joystick
  124250. */
  124251. set buttonRightStick(value: number);
  124252. /**
  124253. * Gets the value of D-pad up
  124254. */
  124255. get dPadUp(): number;
  124256. /**
  124257. * Sets the value of D-pad up
  124258. */
  124259. set dPadUp(value: number);
  124260. /**
  124261. * Gets the value of D-pad down
  124262. */
  124263. get dPadDown(): number;
  124264. /**
  124265. * Sets the value of D-pad down
  124266. */
  124267. set dPadDown(value: number);
  124268. /**
  124269. * Gets the value of D-pad left
  124270. */
  124271. get dPadLeft(): number;
  124272. /**
  124273. * Sets the value of D-pad left
  124274. */
  124275. set dPadLeft(value: number);
  124276. /**
  124277. * Gets the value of D-pad right
  124278. */
  124279. get dPadRight(): number;
  124280. /**
  124281. * Sets the value of D-pad right
  124282. */
  124283. set dPadRight(value: number);
  124284. /**
  124285. * Force the gamepad to synchronize with device values
  124286. */
  124287. update(): void;
  124288. /**
  124289. * Disposes the gamepad
  124290. */
  124291. dispose(): void;
  124292. }
  124293. }
  124294. declare module BABYLON {
  124295. /**
  124296. * Defines supported buttons for DualShock compatible gamepads
  124297. */
  124298. export enum DualShockButton {
  124299. /** Cross */
  124300. Cross = 0,
  124301. /** Circle */
  124302. Circle = 1,
  124303. /** Square */
  124304. Square = 2,
  124305. /** Triangle */
  124306. Triangle = 3,
  124307. /** L1 */
  124308. L1 = 4,
  124309. /** R1 */
  124310. R1 = 5,
  124311. /** Share */
  124312. Share = 8,
  124313. /** Options */
  124314. Options = 9,
  124315. /** Left stick */
  124316. LeftStick = 10,
  124317. /** Right stick */
  124318. RightStick = 11
  124319. }
  124320. /** Defines values for DualShock DPad */
  124321. export enum DualShockDpad {
  124322. /** Up */
  124323. Up = 12,
  124324. /** Down */
  124325. Down = 13,
  124326. /** Left */
  124327. Left = 14,
  124328. /** Right */
  124329. Right = 15
  124330. }
  124331. /**
  124332. * Defines a DualShock gamepad
  124333. */
  124334. export class DualShockPad extends Gamepad {
  124335. private _leftTrigger;
  124336. private _rightTrigger;
  124337. private _onlefttriggerchanged;
  124338. private _onrighttriggerchanged;
  124339. private _onbuttondown;
  124340. private _onbuttonup;
  124341. private _ondpaddown;
  124342. private _ondpadup;
  124343. /** Observable raised when a button is pressed */
  124344. onButtonDownObservable: Observable<DualShockButton>;
  124345. /** Observable raised when a button is released */
  124346. onButtonUpObservable: Observable<DualShockButton>;
  124347. /** Observable raised when a pad is pressed */
  124348. onPadDownObservable: Observable<DualShockDpad>;
  124349. /** Observable raised when a pad is released */
  124350. onPadUpObservable: Observable<DualShockDpad>;
  124351. private _buttonCross;
  124352. private _buttonCircle;
  124353. private _buttonSquare;
  124354. private _buttonTriangle;
  124355. private _buttonShare;
  124356. private _buttonOptions;
  124357. private _buttonL1;
  124358. private _buttonR1;
  124359. private _buttonLeftStick;
  124360. private _buttonRightStick;
  124361. private _dPadUp;
  124362. private _dPadDown;
  124363. private _dPadLeft;
  124364. private _dPadRight;
  124365. /**
  124366. * Creates a new DualShock gamepad object
  124367. * @param id defines the id of this gamepad
  124368. * @param index defines its index
  124369. * @param gamepad defines the internal HTML gamepad object
  124370. */
  124371. constructor(id: string, index: number, gamepad: any);
  124372. /**
  124373. * Defines the callback to call when left trigger is pressed
  124374. * @param callback defines the callback to use
  124375. */
  124376. onlefttriggerchanged(callback: (value: number) => void): void;
  124377. /**
  124378. * Defines the callback to call when right trigger is pressed
  124379. * @param callback defines the callback to use
  124380. */
  124381. onrighttriggerchanged(callback: (value: number) => void): void;
  124382. /**
  124383. * Gets the left trigger value
  124384. */
  124385. get leftTrigger(): number;
  124386. /**
  124387. * Sets the left trigger value
  124388. */
  124389. set leftTrigger(newValue: number);
  124390. /**
  124391. * Gets the right trigger value
  124392. */
  124393. get rightTrigger(): number;
  124394. /**
  124395. * Sets the right trigger value
  124396. */
  124397. set rightTrigger(newValue: number);
  124398. /**
  124399. * Defines the callback to call when a button is pressed
  124400. * @param callback defines the callback to use
  124401. */
  124402. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124403. /**
  124404. * Defines the callback to call when a button is released
  124405. * @param callback defines the callback to use
  124406. */
  124407. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124408. /**
  124409. * Defines the callback to call when a pad is pressed
  124410. * @param callback defines the callback to use
  124411. */
  124412. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124413. /**
  124414. * Defines the callback to call when a pad is released
  124415. * @param callback defines the callback to use
  124416. */
  124417. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124418. private _setButtonValue;
  124419. private _setDPadValue;
  124420. /**
  124421. * Gets the value of the `Cross` button
  124422. */
  124423. get buttonCross(): number;
  124424. /**
  124425. * Sets the value of the `Cross` button
  124426. */
  124427. set buttonCross(value: number);
  124428. /**
  124429. * Gets the value of the `Circle` button
  124430. */
  124431. get buttonCircle(): number;
  124432. /**
  124433. * Sets the value of the `Circle` button
  124434. */
  124435. set buttonCircle(value: number);
  124436. /**
  124437. * Gets the value of the `Square` button
  124438. */
  124439. get buttonSquare(): number;
  124440. /**
  124441. * Sets the value of the `Square` button
  124442. */
  124443. set buttonSquare(value: number);
  124444. /**
  124445. * Gets the value of the `Triangle` button
  124446. */
  124447. get buttonTriangle(): number;
  124448. /**
  124449. * Sets the value of the `Triangle` button
  124450. */
  124451. set buttonTriangle(value: number);
  124452. /**
  124453. * Gets the value of the `Options` button
  124454. */
  124455. get buttonOptions(): number;
  124456. /**
  124457. * Sets the value of the `Options` button
  124458. */
  124459. set buttonOptions(value: number);
  124460. /**
  124461. * Gets the value of the `Share` button
  124462. */
  124463. get buttonShare(): number;
  124464. /**
  124465. * Sets the value of the `Share` button
  124466. */
  124467. set buttonShare(value: number);
  124468. /**
  124469. * Gets the value of the `L1` button
  124470. */
  124471. get buttonL1(): number;
  124472. /**
  124473. * Sets the value of the `L1` button
  124474. */
  124475. set buttonL1(value: number);
  124476. /**
  124477. * Gets the value of the `R1` button
  124478. */
  124479. get buttonR1(): number;
  124480. /**
  124481. * Sets the value of the `R1` button
  124482. */
  124483. set buttonR1(value: number);
  124484. /**
  124485. * Gets the value of the Left joystick
  124486. */
  124487. get buttonLeftStick(): number;
  124488. /**
  124489. * Sets the value of the Left joystick
  124490. */
  124491. set buttonLeftStick(value: number);
  124492. /**
  124493. * Gets the value of the Right joystick
  124494. */
  124495. get buttonRightStick(): number;
  124496. /**
  124497. * Sets the value of the Right joystick
  124498. */
  124499. set buttonRightStick(value: number);
  124500. /**
  124501. * Gets the value of D-pad up
  124502. */
  124503. get dPadUp(): number;
  124504. /**
  124505. * Sets the value of D-pad up
  124506. */
  124507. set dPadUp(value: number);
  124508. /**
  124509. * Gets the value of D-pad down
  124510. */
  124511. get dPadDown(): number;
  124512. /**
  124513. * Sets the value of D-pad down
  124514. */
  124515. set dPadDown(value: number);
  124516. /**
  124517. * Gets the value of D-pad left
  124518. */
  124519. get dPadLeft(): number;
  124520. /**
  124521. * Sets the value of D-pad left
  124522. */
  124523. set dPadLeft(value: number);
  124524. /**
  124525. * Gets the value of D-pad right
  124526. */
  124527. get dPadRight(): number;
  124528. /**
  124529. * Sets the value of D-pad right
  124530. */
  124531. set dPadRight(value: number);
  124532. /**
  124533. * Force the gamepad to synchronize with device values
  124534. */
  124535. update(): void;
  124536. /**
  124537. * Disposes the gamepad
  124538. */
  124539. dispose(): void;
  124540. }
  124541. }
  124542. declare module BABYLON {
  124543. /**
  124544. * Manager for handling gamepads
  124545. */
  124546. export class GamepadManager {
  124547. private _scene?;
  124548. private _babylonGamepads;
  124549. private _oneGamepadConnected;
  124550. /** @hidden */
  124551. _isMonitoring: boolean;
  124552. private _gamepadEventSupported;
  124553. private _gamepadSupport?;
  124554. /**
  124555. * observable to be triggered when the gamepad controller has been connected
  124556. */
  124557. onGamepadConnectedObservable: Observable<Gamepad>;
  124558. /**
  124559. * observable to be triggered when the gamepad controller has been disconnected
  124560. */
  124561. onGamepadDisconnectedObservable: Observable<Gamepad>;
  124562. private _onGamepadConnectedEvent;
  124563. private _onGamepadDisconnectedEvent;
  124564. /**
  124565. * Initializes the gamepad manager
  124566. * @param _scene BabylonJS scene
  124567. */
  124568. constructor(_scene?: Scene | undefined);
  124569. /**
  124570. * The gamepads in the game pad manager
  124571. */
  124572. get gamepads(): Gamepad[];
  124573. /**
  124574. * Get the gamepad controllers based on type
  124575. * @param type The type of gamepad controller
  124576. * @returns Nullable gamepad
  124577. */
  124578. getGamepadByType(type?: number): Nullable<Gamepad>;
  124579. /**
  124580. * Disposes the gamepad manager
  124581. */
  124582. dispose(): void;
  124583. private _addNewGamepad;
  124584. private _startMonitoringGamepads;
  124585. private _stopMonitoringGamepads;
  124586. /** @hidden */
  124587. _checkGamepadsStatus(): void;
  124588. private _updateGamepadObjects;
  124589. }
  124590. }
  124591. declare module BABYLON {
  124592. interface Scene {
  124593. /** @hidden */
  124594. _gamepadManager: Nullable<GamepadManager>;
  124595. /**
  124596. * Gets the gamepad manager associated with the scene
  124597. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  124598. */
  124599. gamepadManager: GamepadManager;
  124600. }
  124601. /**
  124602. * Interface representing a free camera inputs manager
  124603. */
  124604. interface FreeCameraInputsManager {
  124605. /**
  124606. * Adds gamepad input support to the FreeCameraInputsManager.
  124607. * @returns the FreeCameraInputsManager
  124608. */
  124609. addGamepad(): FreeCameraInputsManager;
  124610. }
  124611. /**
  124612. * Interface representing an arc rotate camera inputs manager
  124613. */
  124614. interface ArcRotateCameraInputsManager {
  124615. /**
  124616. * Adds gamepad input support to the ArcRotateCamera InputManager.
  124617. * @returns the camera inputs manager
  124618. */
  124619. addGamepad(): ArcRotateCameraInputsManager;
  124620. }
  124621. /**
  124622. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  124623. */
  124624. export class GamepadSystemSceneComponent implements ISceneComponent {
  124625. /**
  124626. * The component name helpfull to identify the component in the list of scene components.
  124627. */
  124628. readonly name: string;
  124629. /**
  124630. * The scene the component belongs to.
  124631. */
  124632. scene: Scene;
  124633. /**
  124634. * Creates a new instance of the component for the given scene
  124635. * @param scene Defines the scene to register the component in
  124636. */
  124637. constructor(scene: Scene);
  124638. /**
  124639. * Registers the component in a given scene
  124640. */
  124641. register(): void;
  124642. /**
  124643. * Rebuilds the elements related to this component in case of
  124644. * context lost for instance.
  124645. */
  124646. rebuild(): void;
  124647. /**
  124648. * Disposes the component and the associated ressources
  124649. */
  124650. dispose(): void;
  124651. private _beforeCameraUpdate;
  124652. }
  124653. }
  124654. declare module BABYLON {
  124655. /**
  124656. * 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,
  124657. * which still works and will still be found in many Playgrounds.
  124658. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124659. */
  124660. export class UniversalCamera extends TouchCamera {
  124661. /**
  124662. * Defines the gamepad rotation sensiblity.
  124663. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124664. */
  124665. get gamepadAngularSensibility(): number;
  124666. set gamepadAngularSensibility(value: number);
  124667. /**
  124668. * Defines the gamepad move sensiblity.
  124669. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124670. */
  124671. get gamepadMoveSensibility(): number;
  124672. set gamepadMoveSensibility(value: number);
  124673. /**
  124674. * 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,
  124675. * which still works and will still be found in many Playgrounds.
  124676. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124677. * @param name Define the name of the camera in the scene
  124678. * @param position Define the start position of the camera in the scene
  124679. * @param scene Define the scene the camera belongs to
  124680. */
  124681. constructor(name: string, position: Vector3, scene: Scene);
  124682. /**
  124683. * Gets the current object class name.
  124684. * @return the class name
  124685. */
  124686. getClassName(): string;
  124687. }
  124688. }
  124689. declare module BABYLON {
  124690. /**
  124691. * This represents a FPS type of camera. This is only here for back compat purpose.
  124692. * Please use the UniversalCamera instead as both are identical.
  124693. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124694. */
  124695. export class GamepadCamera extends UniversalCamera {
  124696. /**
  124697. * Instantiates a new Gamepad Camera
  124698. * This represents a FPS type of camera. This is only here for back compat purpose.
  124699. * Please use the UniversalCamera instead as both are identical.
  124700. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124701. * @param name Define the name of the camera in the scene
  124702. * @param position Define the start position of the camera in the scene
  124703. * @param scene Define the scene the camera belongs to
  124704. */
  124705. constructor(name: string, position: Vector3, scene: Scene);
  124706. /**
  124707. * Gets the current object class name.
  124708. * @return the class name
  124709. */
  124710. getClassName(): string;
  124711. }
  124712. }
  124713. declare module BABYLON {
  124714. /** @hidden */
  124715. export var passPixelShader: {
  124716. name: string;
  124717. shader: string;
  124718. };
  124719. }
  124720. declare module BABYLON {
  124721. /** @hidden */
  124722. export var passCubePixelShader: {
  124723. name: string;
  124724. shader: string;
  124725. };
  124726. }
  124727. declare module BABYLON {
  124728. /**
  124729. * PassPostProcess which produces an output the same as it's input
  124730. */
  124731. export class PassPostProcess extends PostProcess {
  124732. /**
  124733. * Creates the PassPostProcess
  124734. * @param name The name of the effect.
  124735. * @param options The required width/height ratio to downsize to before computing the render pass.
  124736. * @param camera The camera to apply the render pass to.
  124737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124738. * @param engine The engine which the post process will be applied. (default: current engine)
  124739. * @param reusable If the post process can be reused on the same frame. (default: false)
  124740. * @param textureType The type of texture to be used when performing the post processing.
  124741. * @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)
  124742. */
  124743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124744. }
  124745. /**
  124746. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124747. */
  124748. export class PassCubePostProcess extends PostProcess {
  124749. private _face;
  124750. /**
  124751. * Gets or sets the cube face to display.
  124752. * * 0 is +X
  124753. * * 1 is -X
  124754. * * 2 is +Y
  124755. * * 3 is -Y
  124756. * * 4 is +Z
  124757. * * 5 is -Z
  124758. */
  124759. get face(): number;
  124760. set face(value: number);
  124761. /**
  124762. * Creates the PassCubePostProcess
  124763. * @param name The name of the effect.
  124764. * @param options The required width/height ratio to downsize to before computing the render pass.
  124765. * @param camera The camera to apply the render pass to.
  124766. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124767. * @param engine The engine which the post process will be applied. (default: current engine)
  124768. * @param reusable If the post process can be reused on the same frame. (default: false)
  124769. * @param textureType The type of texture to be used when performing the post processing.
  124770. * @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)
  124771. */
  124772. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124773. }
  124774. }
  124775. declare module BABYLON {
  124776. /** @hidden */
  124777. export var anaglyphPixelShader: {
  124778. name: string;
  124779. shader: string;
  124780. };
  124781. }
  124782. declare module BABYLON {
  124783. /**
  124784. * Postprocess used to generate anaglyphic rendering
  124785. */
  124786. export class AnaglyphPostProcess extends PostProcess {
  124787. private _passedProcess;
  124788. /**
  124789. * Creates a new AnaglyphPostProcess
  124790. * @param name defines postprocess name
  124791. * @param options defines creation options or target ratio scale
  124792. * @param rigCameras defines cameras using this postprocess
  124793. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  124794. * @param engine defines hosting engine
  124795. * @param reusable defines if the postprocess will be reused multiple times per frame
  124796. */
  124797. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  124798. }
  124799. }
  124800. declare module BABYLON {
  124801. /**
  124802. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  124803. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124804. */
  124805. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  124806. /**
  124807. * Creates a new AnaglyphArcRotateCamera
  124808. * @param name defines camera name
  124809. * @param alpha defines alpha angle (in radians)
  124810. * @param beta defines beta angle (in radians)
  124811. * @param radius defines radius
  124812. * @param target defines camera target
  124813. * @param interaxialDistance defines distance between each color axis
  124814. * @param scene defines the hosting scene
  124815. */
  124816. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  124817. /**
  124818. * Gets camera class name
  124819. * @returns AnaglyphArcRotateCamera
  124820. */
  124821. getClassName(): string;
  124822. }
  124823. }
  124824. declare module BABYLON {
  124825. /**
  124826. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  124827. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124828. */
  124829. export class AnaglyphFreeCamera extends FreeCamera {
  124830. /**
  124831. * Creates a new AnaglyphFreeCamera
  124832. * @param name defines camera name
  124833. * @param position defines initial position
  124834. * @param interaxialDistance defines distance between each color axis
  124835. * @param scene defines the hosting scene
  124836. */
  124837. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124838. /**
  124839. * Gets camera class name
  124840. * @returns AnaglyphFreeCamera
  124841. */
  124842. getClassName(): string;
  124843. }
  124844. }
  124845. declare module BABYLON {
  124846. /**
  124847. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  124848. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124849. */
  124850. export class AnaglyphGamepadCamera extends GamepadCamera {
  124851. /**
  124852. * Creates a new AnaglyphGamepadCamera
  124853. * @param name defines camera name
  124854. * @param position defines initial position
  124855. * @param interaxialDistance defines distance between each color axis
  124856. * @param scene defines the hosting scene
  124857. */
  124858. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124859. /**
  124860. * Gets camera class name
  124861. * @returns AnaglyphGamepadCamera
  124862. */
  124863. getClassName(): string;
  124864. }
  124865. }
  124866. declare module BABYLON {
  124867. /**
  124868. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  124869. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124870. */
  124871. export class AnaglyphUniversalCamera extends UniversalCamera {
  124872. /**
  124873. * Creates a new AnaglyphUniversalCamera
  124874. * @param name defines camera name
  124875. * @param position defines initial position
  124876. * @param interaxialDistance defines distance between each color axis
  124877. * @param scene defines the hosting scene
  124878. */
  124879. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124880. /**
  124881. * Gets camera class name
  124882. * @returns AnaglyphUniversalCamera
  124883. */
  124884. getClassName(): string;
  124885. }
  124886. }
  124887. declare module BABYLON {
  124888. /**
  124889. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  124890. * @see https://doc.babylonjs.com/features/cameras
  124891. */
  124892. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  124893. /**
  124894. * Creates a new StereoscopicArcRotateCamera
  124895. * @param name defines camera name
  124896. * @param alpha defines alpha angle (in radians)
  124897. * @param beta defines beta angle (in radians)
  124898. * @param radius defines radius
  124899. * @param target defines camera target
  124900. * @param interaxialDistance defines distance between each color axis
  124901. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124902. * @param scene defines the hosting scene
  124903. */
  124904. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124905. /**
  124906. * Gets camera class name
  124907. * @returns StereoscopicArcRotateCamera
  124908. */
  124909. getClassName(): string;
  124910. }
  124911. }
  124912. declare module BABYLON {
  124913. /**
  124914. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  124915. * @see https://doc.babylonjs.com/features/cameras
  124916. */
  124917. export class StereoscopicFreeCamera extends FreeCamera {
  124918. /**
  124919. * Creates a new StereoscopicFreeCamera
  124920. * @param name defines camera name
  124921. * @param position defines initial position
  124922. * @param interaxialDistance defines distance between each color axis
  124923. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124924. * @param scene defines the hosting scene
  124925. */
  124926. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124927. /**
  124928. * Gets camera class name
  124929. * @returns StereoscopicFreeCamera
  124930. */
  124931. getClassName(): string;
  124932. }
  124933. }
  124934. declare module BABYLON {
  124935. /**
  124936. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  124937. * @see https://doc.babylonjs.com/features/cameras
  124938. */
  124939. export class StereoscopicGamepadCamera extends GamepadCamera {
  124940. /**
  124941. * Creates a new StereoscopicGamepadCamera
  124942. * @param name defines camera name
  124943. * @param position defines initial position
  124944. * @param interaxialDistance defines distance between each color axis
  124945. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124946. * @param scene defines the hosting scene
  124947. */
  124948. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124949. /**
  124950. * Gets camera class name
  124951. * @returns StereoscopicGamepadCamera
  124952. */
  124953. getClassName(): string;
  124954. }
  124955. }
  124956. declare module BABYLON {
  124957. /**
  124958. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  124959. * @see https://doc.babylonjs.com/features/cameras
  124960. */
  124961. export class StereoscopicUniversalCamera extends UniversalCamera {
  124962. /**
  124963. * Creates a new StereoscopicUniversalCamera
  124964. * @param name defines camera name
  124965. * @param position defines initial position
  124966. * @param interaxialDistance defines distance between each color axis
  124967. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124968. * @param scene defines the hosting scene
  124969. */
  124970. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124971. /**
  124972. * Gets camera class name
  124973. * @returns StereoscopicUniversalCamera
  124974. */
  124975. getClassName(): string;
  124976. }
  124977. }
  124978. declare module BABYLON {
  124979. /**
  124980. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  124981. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124982. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124983. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124984. */
  124985. export class VirtualJoysticksCamera extends FreeCamera {
  124986. /**
  124987. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  124988. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124989. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124990. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124991. * @param name Define the name of the camera in the scene
  124992. * @param position Define the start position of the camera in the scene
  124993. * @param scene Define the scene the camera belongs to
  124994. */
  124995. constructor(name: string, position: Vector3, scene: Scene);
  124996. /**
  124997. * Gets the current object class name.
  124998. * @return the class name
  124999. */
  125000. getClassName(): string;
  125001. }
  125002. }
  125003. declare module BABYLON {
  125004. /**
  125005. * This represents all the required metrics to create a VR camera.
  125006. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  125007. */
  125008. export class VRCameraMetrics {
  125009. /**
  125010. * Define the horizontal resolution off the screen.
  125011. */
  125012. hResolution: number;
  125013. /**
  125014. * Define the vertical resolution off the screen.
  125015. */
  125016. vResolution: number;
  125017. /**
  125018. * Define the horizontal screen size.
  125019. */
  125020. hScreenSize: number;
  125021. /**
  125022. * Define the vertical screen size.
  125023. */
  125024. vScreenSize: number;
  125025. /**
  125026. * Define the vertical screen center position.
  125027. */
  125028. vScreenCenter: number;
  125029. /**
  125030. * Define the distance of the eyes to the screen.
  125031. */
  125032. eyeToScreenDistance: number;
  125033. /**
  125034. * Define the distance between both lenses
  125035. */
  125036. lensSeparationDistance: number;
  125037. /**
  125038. * Define the distance between both viewer's eyes.
  125039. */
  125040. interpupillaryDistance: number;
  125041. /**
  125042. * Define the distortion factor of the VR postprocess.
  125043. * Please, touch with care.
  125044. */
  125045. distortionK: number[];
  125046. /**
  125047. * Define the chromatic aberration correction factors for the VR post process.
  125048. */
  125049. chromaAbCorrection: number[];
  125050. /**
  125051. * Define the scale factor of the post process.
  125052. * The smaller the better but the slower.
  125053. */
  125054. postProcessScaleFactor: number;
  125055. /**
  125056. * Define an offset for the lens center.
  125057. */
  125058. lensCenterOffset: number;
  125059. /**
  125060. * Define if the current vr camera should compensate the distortion of the lense or not.
  125061. */
  125062. compensateDistortion: boolean;
  125063. /**
  125064. * Defines if multiview should be enabled when rendering (Default: false)
  125065. */
  125066. multiviewEnabled: boolean;
  125067. /**
  125068. * Gets the rendering aspect ratio based on the provided resolutions.
  125069. */
  125070. get aspectRatio(): number;
  125071. /**
  125072. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  125073. */
  125074. get aspectRatioFov(): number;
  125075. /**
  125076. * @hidden
  125077. */
  125078. get leftHMatrix(): Matrix;
  125079. /**
  125080. * @hidden
  125081. */
  125082. get rightHMatrix(): Matrix;
  125083. /**
  125084. * @hidden
  125085. */
  125086. get leftPreViewMatrix(): Matrix;
  125087. /**
  125088. * @hidden
  125089. */
  125090. get rightPreViewMatrix(): Matrix;
  125091. /**
  125092. * Get the default VRMetrics based on the most generic setup.
  125093. * @returns the default vr metrics
  125094. */
  125095. static GetDefault(): VRCameraMetrics;
  125096. }
  125097. }
  125098. declare module BABYLON {
  125099. /** @hidden */
  125100. export var vrDistortionCorrectionPixelShader: {
  125101. name: string;
  125102. shader: string;
  125103. };
  125104. }
  125105. declare module BABYLON {
  125106. /**
  125107. * VRDistortionCorrectionPostProcess used for mobile VR
  125108. */
  125109. export class VRDistortionCorrectionPostProcess extends PostProcess {
  125110. private _isRightEye;
  125111. private _distortionFactors;
  125112. private _postProcessScaleFactor;
  125113. private _lensCenterOffset;
  125114. private _scaleIn;
  125115. private _scaleFactor;
  125116. private _lensCenter;
  125117. /**
  125118. * Initializes the VRDistortionCorrectionPostProcess
  125119. * @param name The name of the effect.
  125120. * @param camera The camera to apply the render pass to.
  125121. * @param isRightEye If this is for the right eye distortion
  125122. * @param vrMetrics All the required metrics for the VR camera
  125123. */
  125124. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  125125. }
  125126. }
  125127. declare module BABYLON {
  125128. /**
  125129. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  125130. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125131. */
  125132. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  125133. /**
  125134. * Creates a new VRDeviceOrientationArcRotateCamera
  125135. * @param name defines camera name
  125136. * @param alpha defines the camera rotation along the logitudinal axis
  125137. * @param beta defines the camera rotation along the latitudinal axis
  125138. * @param radius defines the camera distance from its target
  125139. * @param target defines the camera target
  125140. * @param scene defines the scene the camera belongs to
  125141. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125142. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125143. */
  125144. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125145. /**
  125146. * Gets camera class name
  125147. * @returns VRDeviceOrientationArcRotateCamera
  125148. */
  125149. getClassName(): string;
  125150. }
  125151. }
  125152. declare module BABYLON {
  125153. /**
  125154. * Camera used to simulate VR rendering (based on FreeCamera)
  125155. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125156. */
  125157. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  125158. /**
  125159. * Creates a new VRDeviceOrientationFreeCamera
  125160. * @param name defines camera name
  125161. * @param position defines the start position of the camera
  125162. * @param scene defines the scene the camera belongs to
  125163. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125164. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125165. */
  125166. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125167. /**
  125168. * Gets camera class name
  125169. * @returns VRDeviceOrientationFreeCamera
  125170. */
  125171. getClassName(): string;
  125172. }
  125173. }
  125174. declare module BABYLON {
  125175. /**
  125176. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  125177. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125178. */
  125179. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  125180. /**
  125181. * Creates a new VRDeviceOrientationGamepadCamera
  125182. * @param name defines camera name
  125183. * @param position defines the start position of the camera
  125184. * @param scene defines the scene the camera belongs to
  125185. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125186. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125187. */
  125188. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125189. /**
  125190. * Gets camera class name
  125191. * @returns VRDeviceOrientationGamepadCamera
  125192. */
  125193. getClassName(): string;
  125194. }
  125195. }
  125196. declare module BABYLON {
  125197. /**
  125198. * A class extending Texture allowing drawing on a texture
  125199. * @see https://doc.babylonjs.com/how_to/dynamictexture
  125200. */
  125201. export class DynamicTexture extends Texture {
  125202. private _generateMipMaps;
  125203. private _canvas;
  125204. private _context;
  125205. /**
  125206. * Creates a DynamicTexture
  125207. * @param name defines the name of the texture
  125208. * @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
  125209. * @param scene defines the scene where you want the texture
  125210. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  125211. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125212. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  125213. */
  125214. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  125215. /**
  125216. * Get the current class name of the texture useful for serialization or dynamic coding.
  125217. * @returns "DynamicTexture"
  125218. */
  125219. getClassName(): string;
  125220. /**
  125221. * Gets the current state of canRescale
  125222. */
  125223. get canRescale(): boolean;
  125224. private _recreate;
  125225. /**
  125226. * Scales the texture
  125227. * @param ratio the scale factor to apply to both width and height
  125228. */
  125229. scale(ratio: number): void;
  125230. /**
  125231. * Resizes the texture
  125232. * @param width the new width
  125233. * @param height the new height
  125234. */
  125235. scaleTo(width: number, height: number): void;
  125236. /**
  125237. * Gets the context of the canvas used by the texture
  125238. * @returns the canvas context of the dynamic texture
  125239. */
  125240. getContext(): CanvasRenderingContext2D;
  125241. /**
  125242. * Clears the texture
  125243. */
  125244. clear(): void;
  125245. /**
  125246. * Updates the texture
  125247. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125248. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  125249. */
  125250. update(invertY?: boolean, premulAlpha?: boolean): void;
  125251. /**
  125252. * Draws text onto the texture
  125253. * @param text defines the text to be drawn
  125254. * @param x defines the placement of the text from the left
  125255. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  125256. * @param font defines the font to be used with font-style, font-size, font-name
  125257. * @param color defines the color used for the text
  125258. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  125259. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125260. * @param update defines whether texture is immediately update (default is true)
  125261. */
  125262. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  125263. /**
  125264. * Clones the texture
  125265. * @returns the clone of the texture.
  125266. */
  125267. clone(): DynamicTexture;
  125268. /**
  125269. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  125270. * @returns a serialized dynamic texture object
  125271. */
  125272. serialize(): any;
  125273. private _IsCanvasElement;
  125274. /** @hidden */
  125275. _rebuild(): void;
  125276. }
  125277. }
  125278. declare module BABYLON {
  125279. /**
  125280. * Class containing static functions to help procedurally build meshes
  125281. */
  125282. export class GroundBuilder {
  125283. /**
  125284. * Creates a ground mesh
  125285. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125286. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125288. * @param name defines the name of the mesh
  125289. * @param options defines the options used to create the mesh
  125290. * @param scene defines the hosting scene
  125291. * @returns the ground mesh
  125292. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125293. */
  125294. static CreateGround(name: string, options: {
  125295. width?: number;
  125296. height?: number;
  125297. subdivisions?: number;
  125298. subdivisionsX?: number;
  125299. subdivisionsY?: number;
  125300. updatable?: boolean;
  125301. }, scene: any): Mesh;
  125302. /**
  125303. * Creates a tiled ground mesh
  125304. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125305. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125306. * * 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
  125307. * * 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
  125308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125309. * @param name defines the name of the mesh
  125310. * @param options defines the options used to create the mesh
  125311. * @param scene defines the hosting scene
  125312. * @returns the tiled ground mesh
  125313. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125314. */
  125315. static CreateTiledGround(name: string, options: {
  125316. xmin: number;
  125317. zmin: number;
  125318. xmax: number;
  125319. zmax: number;
  125320. subdivisions?: {
  125321. w: number;
  125322. h: number;
  125323. };
  125324. precision?: {
  125325. w: number;
  125326. h: number;
  125327. };
  125328. updatable?: boolean;
  125329. }, scene?: Nullable<Scene>): Mesh;
  125330. /**
  125331. * Creates a ground mesh from a height map
  125332. * * The parameter `url` sets the URL of the height map image resource.
  125333. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125334. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125335. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125336. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125337. * * 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.
  125338. * * 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).
  125339. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125341. * @param name defines the name of the mesh
  125342. * @param url defines the url to the height map
  125343. * @param options defines the options used to create the mesh
  125344. * @param scene defines the hosting scene
  125345. * @returns the ground mesh
  125346. * @see https://doc.babylonjs.com/babylon101/height_map
  125347. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125348. */
  125349. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125350. width?: number;
  125351. height?: number;
  125352. subdivisions?: number;
  125353. minHeight?: number;
  125354. maxHeight?: number;
  125355. colorFilter?: Color3;
  125356. alphaFilter?: number;
  125357. updatable?: boolean;
  125358. onReady?: (mesh: GroundMesh) => void;
  125359. }, scene?: Nullable<Scene>): GroundMesh;
  125360. }
  125361. }
  125362. declare module BABYLON {
  125363. /**
  125364. * Class containing static functions to help procedurally build meshes
  125365. */
  125366. export class TorusBuilder {
  125367. /**
  125368. * Creates a torus mesh
  125369. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125370. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125371. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125375. * @param name defines the name of the mesh
  125376. * @param options defines the options used to create the mesh
  125377. * @param scene defines the hosting scene
  125378. * @returns the torus mesh
  125379. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125380. */
  125381. static CreateTorus(name: string, options: {
  125382. diameter?: number;
  125383. thickness?: number;
  125384. tessellation?: number;
  125385. updatable?: boolean;
  125386. sideOrientation?: number;
  125387. frontUVs?: Vector4;
  125388. backUVs?: Vector4;
  125389. }, scene: any): Mesh;
  125390. }
  125391. }
  125392. declare module BABYLON {
  125393. /**
  125394. * Class containing static functions to help procedurally build meshes
  125395. */
  125396. export class CylinderBuilder {
  125397. /**
  125398. * Creates a cylinder or a cone mesh
  125399. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125400. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125401. * * 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.
  125402. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125403. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125404. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125405. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125406. * * 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).
  125407. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125408. * * 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).
  125409. * * 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
  125410. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125411. * * 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
  125412. * * 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.
  125413. * * If `enclose` is false, a ring surface is one element.
  125414. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125415. * * 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
  125416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125419. * @param name defines the name of the mesh
  125420. * @param options defines the options used to create the mesh
  125421. * @param scene defines the hosting scene
  125422. * @returns the cylinder mesh
  125423. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125424. */
  125425. static CreateCylinder(name: string, options: {
  125426. height?: number;
  125427. diameterTop?: number;
  125428. diameterBottom?: number;
  125429. diameter?: number;
  125430. tessellation?: number;
  125431. subdivisions?: number;
  125432. arc?: number;
  125433. faceColors?: Color4[];
  125434. faceUV?: Vector4[];
  125435. updatable?: boolean;
  125436. hasRings?: boolean;
  125437. enclose?: boolean;
  125438. cap?: number;
  125439. sideOrientation?: number;
  125440. frontUVs?: Vector4;
  125441. backUVs?: Vector4;
  125442. }, scene: any): Mesh;
  125443. }
  125444. }
  125445. declare module BABYLON {
  125446. /**
  125447. * States of the webXR experience
  125448. */
  125449. export enum WebXRState {
  125450. /**
  125451. * Transitioning to being in XR mode
  125452. */
  125453. ENTERING_XR = 0,
  125454. /**
  125455. * Transitioning to non XR mode
  125456. */
  125457. EXITING_XR = 1,
  125458. /**
  125459. * In XR mode and presenting
  125460. */
  125461. IN_XR = 2,
  125462. /**
  125463. * Not entered XR mode
  125464. */
  125465. NOT_IN_XR = 3
  125466. }
  125467. /**
  125468. * Abstraction of the XR render target
  125469. */
  125470. export interface WebXRRenderTarget extends IDisposable {
  125471. /**
  125472. * xrpresent context of the canvas which can be used to display/mirror xr content
  125473. */
  125474. canvasContext: WebGLRenderingContext;
  125475. /**
  125476. * xr layer for the canvas
  125477. */
  125478. xrLayer: Nullable<XRWebGLLayer>;
  125479. /**
  125480. * Initializes the xr layer for the session
  125481. * @param xrSession xr session
  125482. * @returns a promise that will resolve once the XR Layer has been created
  125483. */
  125484. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125485. }
  125486. }
  125487. declare module BABYLON {
  125488. /**
  125489. * COnfiguration object for WebXR output canvas
  125490. */
  125491. export class WebXRManagedOutputCanvasOptions {
  125492. /**
  125493. * An optional canvas in case you wish to create it yourself and provide it here.
  125494. * If not provided, a new canvas will be created
  125495. */
  125496. canvasElement?: HTMLCanvasElement;
  125497. /**
  125498. * Options for this XR Layer output
  125499. */
  125500. canvasOptions?: XRWebGLLayerOptions;
  125501. /**
  125502. * CSS styling for a newly created canvas (if not provided)
  125503. */
  125504. newCanvasCssStyle?: string;
  125505. /**
  125506. * Get the default values of the configuration object
  125507. * @returns default values of this configuration object
  125508. */
  125509. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  125510. }
  125511. /**
  125512. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  125513. */
  125514. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  125515. private _options;
  125516. private _canvas;
  125517. private _engine;
  125518. private _originalCanvasSize;
  125519. /**
  125520. * Rendering context of the canvas which can be used to display/mirror xr content
  125521. */
  125522. canvasContext: WebGLRenderingContext;
  125523. /**
  125524. * xr layer for the canvas
  125525. */
  125526. xrLayer: Nullable<XRWebGLLayer>;
  125527. /**
  125528. * Obseervers registered here will be triggered when the xr layer was initialized
  125529. */
  125530. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  125531. /**
  125532. * Initializes the canvas to be added/removed upon entering/exiting xr
  125533. * @param _xrSessionManager The XR Session manager
  125534. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  125535. */
  125536. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  125537. /**
  125538. * Disposes of the object
  125539. */
  125540. dispose(): void;
  125541. /**
  125542. * Initializes the xr layer for the session
  125543. * @param xrSession xr session
  125544. * @returns a promise that will resolve once the XR Layer has been created
  125545. */
  125546. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125547. private _addCanvas;
  125548. private _removeCanvas;
  125549. private _setCanvasSize;
  125550. private _setManagedOutputCanvas;
  125551. }
  125552. }
  125553. declare module BABYLON {
  125554. /**
  125555. * Manages an XRSession to work with Babylon's engine
  125556. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  125557. */
  125558. export class WebXRSessionManager implements IDisposable {
  125559. /** The scene which the session should be created for */
  125560. scene: Scene;
  125561. private _referenceSpace;
  125562. private _rttProvider;
  125563. private _sessionEnded;
  125564. private _xrNavigator;
  125565. private baseLayer;
  125566. /**
  125567. * The base reference space from which the session started. good if you want to reset your
  125568. * reference space
  125569. */
  125570. baseReferenceSpace: XRReferenceSpace;
  125571. /**
  125572. * Current XR frame
  125573. */
  125574. currentFrame: Nullable<XRFrame>;
  125575. /** WebXR timestamp updated every frame */
  125576. currentTimestamp: number;
  125577. /**
  125578. * Used just in case of a failure to initialize an immersive session.
  125579. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  125580. */
  125581. defaultHeightCompensation: number;
  125582. /**
  125583. * Fires every time a new xrFrame arrives which can be used to update the camera
  125584. */
  125585. onXRFrameObservable: Observable<XRFrame>;
  125586. /**
  125587. * Fires when the reference space changed
  125588. */
  125589. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  125590. /**
  125591. * Fires when the xr session is ended either by the device or manually done
  125592. */
  125593. onXRSessionEnded: Observable<any>;
  125594. /**
  125595. * Fires when the xr session is ended either by the device or manually done
  125596. */
  125597. onXRSessionInit: Observable<XRSession>;
  125598. /**
  125599. * Underlying xr session
  125600. */
  125601. session: XRSession;
  125602. /**
  125603. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  125604. * or get the offset the player is currently at.
  125605. */
  125606. viewerReferenceSpace: XRReferenceSpace;
  125607. /**
  125608. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  125609. * @param scene The scene which the session should be created for
  125610. */
  125611. constructor(
  125612. /** The scene which the session should be created for */
  125613. scene: Scene);
  125614. /**
  125615. * The current reference space used in this session. This reference space can constantly change!
  125616. * It is mainly used to offset the camera's position.
  125617. */
  125618. get referenceSpace(): XRReferenceSpace;
  125619. /**
  125620. * Set a new reference space and triggers the observable
  125621. */
  125622. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  125623. /**
  125624. * Disposes of the session manager
  125625. */
  125626. dispose(): void;
  125627. /**
  125628. * Stops the xrSession and restores the render loop
  125629. * @returns Promise which resolves after it exits XR
  125630. */
  125631. exitXRAsync(): Promise<void>;
  125632. /**
  125633. * Gets the correct render target texture to be rendered this frame for this eye
  125634. * @param eye the eye for which to get the render target
  125635. * @returns the render target for the specified eye
  125636. */
  125637. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  125638. /**
  125639. * Creates a WebXRRenderTarget object for the XR session
  125640. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  125641. * @param options optional options to provide when creating a new render target
  125642. * @returns a WebXR render target to which the session can render
  125643. */
  125644. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  125645. /**
  125646. * Initializes the manager
  125647. * After initialization enterXR can be called to start an XR session
  125648. * @returns Promise which resolves after it is initialized
  125649. */
  125650. initializeAsync(): Promise<void>;
  125651. /**
  125652. * Initializes an xr session
  125653. * @param xrSessionMode mode to initialize
  125654. * @param xrSessionInit defines optional and required values to pass to the session builder
  125655. * @returns a promise which will resolve once the session has been initialized
  125656. */
  125657. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  125658. /**
  125659. * Checks if a session would be supported for the creation options specified
  125660. * @param sessionMode session mode to check if supported eg. immersive-vr
  125661. * @returns A Promise that resolves to true if supported and false if not
  125662. */
  125663. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125664. /**
  125665. * Resets the reference space to the one started the session
  125666. */
  125667. resetReferenceSpace(): void;
  125668. /**
  125669. * Starts rendering to the xr layer
  125670. */
  125671. runXRRenderLoop(): void;
  125672. /**
  125673. * Sets the reference space on the xr session
  125674. * @param referenceSpaceType space to set
  125675. * @returns a promise that will resolve once the reference space has been set
  125676. */
  125677. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125678. /**
  125679. * Updates the render state of the session
  125680. * @param state state to set
  125681. * @returns a promise that resolves once the render state has been updated
  125682. */
  125683. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  125684. /**
  125685. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  125686. * @param sessionMode defines the session to test
  125687. * @returns a promise with boolean as final value
  125688. */
  125689. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125690. private _createRenderTargetTexture;
  125691. }
  125692. }
  125693. declare module BABYLON {
  125694. /**
  125695. * WebXR Camera which holds the views for the xrSession
  125696. * @see https://doc.babylonjs.com/how_to/webxr_camera
  125697. */
  125698. export class WebXRCamera extends FreeCamera {
  125699. private _xrSessionManager;
  125700. private _firstFrame;
  125701. private _referenceQuaternion;
  125702. private _referencedPosition;
  125703. private _xrInvPositionCache;
  125704. private _xrInvQuaternionCache;
  125705. /**
  125706. * Should position compensation execute on first frame.
  125707. * This is used when copying the position from a native (non XR) camera
  125708. */
  125709. compensateOnFirstFrame: boolean;
  125710. /**
  125711. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  125712. * @param name the name of the camera
  125713. * @param scene the scene to add the camera to
  125714. * @param _xrSessionManager a constructed xr session manager
  125715. */
  125716. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  125717. /**
  125718. * Return the user's height, unrelated to the current ground.
  125719. * This will be the y position of this camera, when ground level is 0.
  125720. */
  125721. get realWorldHeight(): number;
  125722. /** @hidden */
  125723. _updateForDualEyeDebugging(): void;
  125724. /**
  125725. * Sets this camera's transformation based on a non-vr camera
  125726. * @param otherCamera the non-vr camera to copy the transformation from
  125727. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  125728. */
  125729. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  125730. /**
  125731. * Gets the current instance class name ("WebXRCamera").
  125732. * @returns the class name
  125733. */
  125734. getClassName(): string;
  125735. private _rotate180;
  125736. private _updateFromXRSession;
  125737. private _updateNumberOfRigCameras;
  125738. private _updateReferenceSpace;
  125739. private _updateReferenceSpaceOffset;
  125740. }
  125741. }
  125742. declare module BABYLON {
  125743. /**
  125744. * Defining the interface required for a (webxr) feature
  125745. */
  125746. export interface IWebXRFeature extends IDisposable {
  125747. /**
  125748. * Is this feature attached
  125749. */
  125750. attached: boolean;
  125751. /**
  125752. * Should auto-attach be disabled?
  125753. */
  125754. disableAutoAttach: boolean;
  125755. /**
  125756. * Attach the feature to the session
  125757. * Will usually be called by the features manager
  125758. *
  125759. * @param force should attachment be forced (even when already attached)
  125760. * @returns true if successful.
  125761. */
  125762. attach(force?: boolean): boolean;
  125763. /**
  125764. * Detach the feature from the session
  125765. * Will usually be called by the features manager
  125766. *
  125767. * @returns true if successful.
  125768. */
  125769. detach(): boolean;
  125770. /**
  125771. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  125772. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  125773. *
  125774. * @returns whether or not the feature is compatible in this environment
  125775. */
  125776. isCompatible(): boolean;
  125777. /**
  125778. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  125779. */
  125780. xrNativeFeatureName?: string;
  125781. }
  125782. /**
  125783. * A list of the currently available features without referencing them
  125784. */
  125785. export class WebXRFeatureName {
  125786. /**
  125787. * The name of the anchor system feature
  125788. */
  125789. static ANCHOR_SYSTEM: string;
  125790. /**
  125791. * The name of the background remover feature
  125792. */
  125793. static BACKGROUND_REMOVER: string;
  125794. /**
  125795. * The name of the hit test feature
  125796. */
  125797. static HIT_TEST: string;
  125798. /**
  125799. * physics impostors for xr controllers feature
  125800. */
  125801. static PHYSICS_CONTROLLERS: string;
  125802. /**
  125803. * The name of the plane detection feature
  125804. */
  125805. static PLANE_DETECTION: string;
  125806. /**
  125807. * The name of the pointer selection feature
  125808. */
  125809. static POINTER_SELECTION: string;
  125810. /**
  125811. * The name of the teleportation feature
  125812. */
  125813. static TELEPORTATION: string;
  125814. }
  125815. /**
  125816. * Defining the constructor of a feature. Used to register the modules.
  125817. */
  125818. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  125819. /**
  125820. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  125821. * It is mainly used in AR sessions.
  125822. *
  125823. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  125824. */
  125825. export class WebXRFeaturesManager implements IDisposable {
  125826. private _xrSessionManager;
  125827. private static readonly _AvailableFeatures;
  125828. private _features;
  125829. /**
  125830. * constructs a new features manages.
  125831. *
  125832. * @param _xrSessionManager an instance of WebXRSessionManager
  125833. */
  125834. constructor(_xrSessionManager: WebXRSessionManager);
  125835. /**
  125836. * Used to register a module. After calling this function a developer can use this feature in the scene.
  125837. * Mainly used internally.
  125838. *
  125839. * @param featureName the name of the feature to register
  125840. * @param constructorFunction the function used to construct the module
  125841. * @param version the (babylon) version of the module
  125842. * @param stable is that a stable version of this module
  125843. */
  125844. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  125845. /**
  125846. * Returns a constructor of a specific feature.
  125847. *
  125848. * @param featureName the name of the feature to construct
  125849. * @param version the version of the feature to load
  125850. * @param xrSessionManager the xrSessionManager. Used to construct the module
  125851. * @param options optional options provided to the module.
  125852. * @returns a function that, when called, will return a new instance of this feature
  125853. */
  125854. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  125855. /**
  125856. * Can be used to return the list of features currently registered
  125857. *
  125858. * @returns an Array of available features
  125859. */
  125860. static GetAvailableFeatures(): string[];
  125861. /**
  125862. * Gets the versions available for a specific feature
  125863. * @param featureName the name of the feature
  125864. * @returns an array with the available versions
  125865. */
  125866. static GetAvailableVersions(featureName: string): string[];
  125867. /**
  125868. * Return the latest unstable version of this feature
  125869. * @param featureName the name of the feature to search
  125870. * @returns the version number. if not found will return -1
  125871. */
  125872. static GetLatestVersionOfFeature(featureName: string): number;
  125873. /**
  125874. * Return the latest stable version of this feature
  125875. * @param featureName the name of the feature to search
  125876. * @returns the version number. if not found will return -1
  125877. */
  125878. static GetStableVersionOfFeature(featureName: string): number;
  125879. /**
  125880. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  125881. * Can be used during a session to start a feature
  125882. * @param featureName the name of feature to attach
  125883. */
  125884. attachFeature(featureName: string): void;
  125885. /**
  125886. * Can be used inside a session or when the session ends to detach a specific feature
  125887. * @param featureName the name of the feature to detach
  125888. */
  125889. detachFeature(featureName: string): void;
  125890. /**
  125891. * Used to disable an already-enabled feature
  125892. * The feature will be disposed and will be recreated once enabled.
  125893. * @param featureName the feature to disable
  125894. * @returns true if disable was successful
  125895. */
  125896. disableFeature(featureName: string | {
  125897. Name: string;
  125898. }): boolean;
  125899. /**
  125900. * dispose this features manager
  125901. */
  125902. dispose(): void;
  125903. /**
  125904. * 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.
  125905. * 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.
  125906. *
  125907. * @param featureName the name of the feature to load or the class of the feature
  125908. * @param version optional version to load. if not provided the latest version will be enabled
  125909. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  125910. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  125911. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  125912. * @returns a new constructed feature or throws an error if feature not found.
  125913. */
  125914. enableFeature(featureName: string | {
  125915. Name: string;
  125916. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  125917. /**
  125918. * get the implementation of an enabled feature.
  125919. * @param featureName the name of the feature to load
  125920. * @returns the feature class, if found
  125921. */
  125922. getEnabledFeature(featureName: string): IWebXRFeature;
  125923. /**
  125924. * Get the list of enabled features
  125925. * @returns an array of enabled features
  125926. */
  125927. getEnabledFeatures(): string[];
  125928. /**
  125929. * This function will exten the session creation configuration object with enabled features.
  125930. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  125931. * according to the defined "required" variable, provided during enableFeature call
  125932. * @param xrSessionInit the xr Session init object to extend
  125933. *
  125934. * @returns an extended XRSessionInit object
  125935. */
  125936. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  125937. }
  125938. }
  125939. declare module BABYLON {
  125940. /**
  125941. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  125942. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  125943. */
  125944. export class WebXRExperienceHelper implements IDisposable {
  125945. private scene;
  125946. private _nonVRCamera;
  125947. private _originalSceneAutoClear;
  125948. private _supported;
  125949. /**
  125950. * Camera used to render xr content
  125951. */
  125952. camera: WebXRCamera;
  125953. /** A features manager for this xr session */
  125954. featuresManager: WebXRFeaturesManager;
  125955. /**
  125956. * Observers registered here will be triggered after the camera's initial transformation is set
  125957. * This can be used to set a different ground level or an extra rotation.
  125958. *
  125959. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  125960. * to the position set after this observable is done executing.
  125961. */
  125962. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  125963. /**
  125964. * Fires when the state of the experience helper has changed
  125965. */
  125966. onStateChangedObservable: Observable<WebXRState>;
  125967. /** Session manager used to keep track of xr session */
  125968. sessionManager: WebXRSessionManager;
  125969. /**
  125970. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  125971. */
  125972. state: WebXRState;
  125973. /**
  125974. * Creates a WebXRExperienceHelper
  125975. * @param scene The scene the helper should be created in
  125976. */
  125977. private constructor();
  125978. /**
  125979. * Creates the experience helper
  125980. * @param scene the scene to attach the experience helper to
  125981. * @returns a promise for the experience helper
  125982. */
  125983. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  125984. /**
  125985. * Disposes of the experience helper
  125986. */
  125987. dispose(): void;
  125988. /**
  125989. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  125990. * @param sessionMode options for the XR session
  125991. * @param referenceSpaceType frame of reference of the XR session
  125992. * @param renderTarget the output canvas that will be used to enter XR mode
  125993. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  125994. * @returns promise that resolves after xr mode has entered
  125995. */
  125996. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  125997. /**
  125998. * Exits XR mode and returns the scene to its original state
  125999. * @returns promise that resolves after xr mode has exited
  126000. */
  126001. exitXRAsync(): Promise<void>;
  126002. private _nonXRToXRCamera;
  126003. private _setState;
  126004. }
  126005. }
  126006. declare module BABYLON {
  126007. /**
  126008. * X-Y values for axes in WebXR
  126009. */
  126010. export interface IWebXRMotionControllerAxesValue {
  126011. /**
  126012. * The value of the x axis
  126013. */
  126014. x: number;
  126015. /**
  126016. * The value of the y-axis
  126017. */
  126018. y: number;
  126019. }
  126020. /**
  126021. * changed / previous values for the values of this component
  126022. */
  126023. export interface IWebXRMotionControllerComponentChangesValues<T> {
  126024. /**
  126025. * current (this frame) value
  126026. */
  126027. current: T;
  126028. /**
  126029. * previous (last change) value
  126030. */
  126031. previous: T;
  126032. }
  126033. /**
  126034. * Represents changes in the component between current frame and last values recorded
  126035. */
  126036. export interface IWebXRMotionControllerComponentChanges {
  126037. /**
  126038. * will be populated with previous and current values if axes changed
  126039. */
  126040. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  126041. /**
  126042. * will be populated with previous and current values if pressed changed
  126043. */
  126044. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126045. /**
  126046. * will be populated with previous and current values if touched changed
  126047. */
  126048. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126049. /**
  126050. * will be populated with previous and current values if value changed
  126051. */
  126052. value?: IWebXRMotionControllerComponentChangesValues<number>;
  126053. }
  126054. /**
  126055. * This class represents a single component (for example button or thumbstick) of a motion controller
  126056. */
  126057. export class WebXRControllerComponent implements IDisposable {
  126058. /**
  126059. * the id of this component
  126060. */
  126061. id: string;
  126062. /**
  126063. * the type of the component
  126064. */
  126065. type: MotionControllerComponentType;
  126066. private _buttonIndex;
  126067. private _axesIndices;
  126068. private _axes;
  126069. private _changes;
  126070. private _currentValue;
  126071. private _hasChanges;
  126072. private _pressed;
  126073. private _touched;
  126074. /**
  126075. * button component type
  126076. */
  126077. static BUTTON_TYPE: MotionControllerComponentType;
  126078. /**
  126079. * squeeze component type
  126080. */
  126081. static SQUEEZE_TYPE: MotionControllerComponentType;
  126082. /**
  126083. * Thumbstick component type
  126084. */
  126085. static THUMBSTICK_TYPE: MotionControllerComponentType;
  126086. /**
  126087. * Touchpad component type
  126088. */
  126089. static TOUCHPAD_TYPE: MotionControllerComponentType;
  126090. /**
  126091. * trigger component type
  126092. */
  126093. static TRIGGER_TYPE: MotionControllerComponentType;
  126094. /**
  126095. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  126096. * the axes data changes
  126097. */
  126098. onAxisValueChangedObservable: Observable<{
  126099. x: number;
  126100. y: number;
  126101. }>;
  126102. /**
  126103. * Observers registered here will be triggered when the state of a button changes
  126104. * State change is either pressed / touched / value
  126105. */
  126106. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  126107. /**
  126108. * Creates a new component for a motion controller.
  126109. * It is created by the motion controller itself
  126110. *
  126111. * @param id the id of this component
  126112. * @param type the type of the component
  126113. * @param _buttonIndex index in the buttons array of the gamepad
  126114. * @param _axesIndices indices of the values in the axes array of the gamepad
  126115. */
  126116. constructor(
  126117. /**
  126118. * the id of this component
  126119. */
  126120. id: string,
  126121. /**
  126122. * the type of the component
  126123. */
  126124. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  126125. /**
  126126. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  126127. */
  126128. get axes(): IWebXRMotionControllerAxesValue;
  126129. /**
  126130. * Get the changes. Elements will be populated only if they changed with their previous and current value
  126131. */
  126132. get changes(): IWebXRMotionControllerComponentChanges;
  126133. /**
  126134. * Return whether or not the component changed the last frame
  126135. */
  126136. get hasChanges(): boolean;
  126137. /**
  126138. * is the button currently pressed
  126139. */
  126140. get pressed(): boolean;
  126141. /**
  126142. * is the button currently touched
  126143. */
  126144. get touched(): boolean;
  126145. /**
  126146. * Get the current value of this component
  126147. */
  126148. get value(): number;
  126149. /**
  126150. * Dispose this component
  126151. */
  126152. dispose(): void;
  126153. /**
  126154. * Are there axes correlating to this component
  126155. * @return true is axes data is available
  126156. */
  126157. isAxes(): boolean;
  126158. /**
  126159. * Is this component a button (hence - pressable)
  126160. * @returns true if can be pressed
  126161. */
  126162. isButton(): boolean;
  126163. /**
  126164. * update this component using the gamepad object it is in. Called on every frame
  126165. * @param nativeController the native gamepad controller object
  126166. */
  126167. update(nativeController: IMinimalMotionControllerObject): void;
  126168. }
  126169. }
  126170. declare module BABYLON {
  126171. /**
  126172. * Interface used to represent data loading progression
  126173. */
  126174. export interface ISceneLoaderProgressEvent {
  126175. /**
  126176. * Defines if data length to load can be evaluated
  126177. */
  126178. readonly lengthComputable: boolean;
  126179. /**
  126180. * Defines the loaded data length
  126181. */
  126182. readonly loaded: number;
  126183. /**
  126184. * Defines the data length to load
  126185. */
  126186. readonly total: number;
  126187. }
  126188. /**
  126189. * Interface used by SceneLoader plugins to define supported file extensions
  126190. */
  126191. export interface ISceneLoaderPluginExtensions {
  126192. /**
  126193. * Defines the list of supported extensions
  126194. */
  126195. [extension: string]: {
  126196. isBinary: boolean;
  126197. };
  126198. }
  126199. /**
  126200. * Interface used by SceneLoader plugin factory
  126201. */
  126202. export interface ISceneLoaderPluginFactory {
  126203. /**
  126204. * Defines the name of the factory
  126205. */
  126206. name: string;
  126207. /**
  126208. * Function called to create a new plugin
  126209. * @return the new plugin
  126210. */
  126211. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  126212. /**
  126213. * The callback that returns true if the data can be directly loaded.
  126214. * @param data string containing the file data
  126215. * @returns if the data can be loaded directly
  126216. */
  126217. canDirectLoad?(data: string): boolean;
  126218. }
  126219. /**
  126220. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  126221. */
  126222. export interface ISceneLoaderPluginBase {
  126223. /**
  126224. * The friendly name of this plugin.
  126225. */
  126226. name: string;
  126227. /**
  126228. * The file extensions supported by this plugin.
  126229. */
  126230. extensions: string | ISceneLoaderPluginExtensions;
  126231. /**
  126232. * The callback called when loading from a url.
  126233. * @param scene scene loading this url
  126234. * @param url url to load
  126235. * @param onSuccess callback called when the file successfully loads
  126236. * @param onProgress callback called while file is loading (if the server supports this mode)
  126237. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126238. * @param onError callback called when the file fails to load
  126239. * @returns a file request object
  126240. */
  126241. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126242. /**
  126243. * The callback called when loading from a file object.
  126244. * @param scene scene loading this file
  126245. * @param file defines the file to load
  126246. * @param onSuccess defines the callback to call when data is loaded
  126247. * @param onProgress defines the callback to call during loading process
  126248. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  126249. * @param onError defines the callback to call when an error occurs
  126250. * @returns a file request object
  126251. */
  126252. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126253. /**
  126254. * The callback that returns true if the data can be directly loaded.
  126255. * @param data string containing the file data
  126256. * @returns if the data can be loaded directly
  126257. */
  126258. canDirectLoad?(data: string): boolean;
  126259. /**
  126260. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  126261. * @param scene scene loading this data
  126262. * @param data string containing the data
  126263. * @returns data to pass to the plugin
  126264. */
  126265. directLoad?(scene: Scene, data: string): any;
  126266. /**
  126267. * The callback that allows custom handling of the root url based on the response url.
  126268. * @param rootUrl the original root url
  126269. * @param responseURL the response url if available
  126270. * @returns the new root url
  126271. */
  126272. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  126273. }
  126274. /**
  126275. * Interface used to define a SceneLoader plugin
  126276. */
  126277. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  126278. /**
  126279. * Import meshes into a scene.
  126280. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126281. * @param scene The scene to import into
  126282. * @param data The data to import
  126283. * @param rootUrl The root url for scene and resources
  126284. * @param meshes The meshes array to import into
  126285. * @param particleSystems The particle systems array to import into
  126286. * @param skeletons The skeletons array to import into
  126287. * @param onError The callback when import fails
  126288. * @returns True if successful or false otherwise
  126289. */
  126290. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  126291. /**
  126292. * Load into a scene.
  126293. * @param scene The scene to load into
  126294. * @param data The data to import
  126295. * @param rootUrl The root url for scene and resources
  126296. * @param onError The callback when import fails
  126297. * @returns True if successful or false otherwise
  126298. */
  126299. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  126300. /**
  126301. * Load into an asset container.
  126302. * @param scene The scene to load into
  126303. * @param data The data to import
  126304. * @param rootUrl The root url for scene and resources
  126305. * @param onError The callback when import fails
  126306. * @returns The loaded asset container
  126307. */
  126308. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  126309. }
  126310. /**
  126311. * Interface used to define an async SceneLoader plugin
  126312. */
  126313. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  126314. /**
  126315. * Import meshes into a scene.
  126316. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126317. * @param scene The scene to import into
  126318. * @param data The data to import
  126319. * @param rootUrl The root url for scene and resources
  126320. * @param onProgress The callback when the load progresses
  126321. * @param fileName Defines the name of the file to load
  126322. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  126323. */
  126324. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  126325. meshes: AbstractMesh[];
  126326. particleSystems: IParticleSystem[];
  126327. skeletons: Skeleton[];
  126328. animationGroups: AnimationGroup[];
  126329. }>;
  126330. /**
  126331. * Load into a scene.
  126332. * @param scene The scene to load into
  126333. * @param data The data to import
  126334. * @param rootUrl The root url for scene and resources
  126335. * @param onProgress The callback when the load progresses
  126336. * @param fileName Defines the name of the file to load
  126337. * @returns Nothing
  126338. */
  126339. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  126340. /**
  126341. * Load into an asset container.
  126342. * @param scene The scene to load into
  126343. * @param data The data to import
  126344. * @param rootUrl The root url for scene and resources
  126345. * @param onProgress The callback when the load progresses
  126346. * @param fileName Defines the name of the file to load
  126347. * @returns The loaded asset container
  126348. */
  126349. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  126350. }
  126351. /**
  126352. * Mode that determines how to handle old animation groups before loading new ones.
  126353. */
  126354. export enum SceneLoaderAnimationGroupLoadingMode {
  126355. /**
  126356. * Reset all old animations to initial state then dispose them.
  126357. */
  126358. Clean = 0,
  126359. /**
  126360. * Stop all old animations.
  126361. */
  126362. Stop = 1,
  126363. /**
  126364. * Restart old animations from first frame.
  126365. */
  126366. Sync = 2,
  126367. /**
  126368. * Old animations remains untouched.
  126369. */
  126370. NoSync = 3
  126371. }
  126372. /**
  126373. * Defines a plugin registered by the SceneLoader
  126374. */
  126375. interface IRegisteredPlugin {
  126376. /**
  126377. * Defines the plugin to use
  126378. */
  126379. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126380. /**
  126381. * Defines if the plugin supports binary data
  126382. */
  126383. isBinary: boolean;
  126384. }
  126385. /**
  126386. * Class used to load scene from various file formats using registered plugins
  126387. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  126388. */
  126389. export class SceneLoader {
  126390. /**
  126391. * No logging while loading
  126392. */
  126393. static readonly NO_LOGGING: number;
  126394. /**
  126395. * Minimal logging while loading
  126396. */
  126397. static readonly MINIMAL_LOGGING: number;
  126398. /**
  126399. * Summary logging while loading
  126400. */
  126401. static readonly SUMMARY_LOGGING: number;
  126402. /**
  126403. * Detailled logging while loading
  126404. */
  126405. static readonly DETAILED_LOGGING: number;
  126406. /**
  126407. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126408. */
  126409. static get ForceFullSceneLoadingForIncremental(): boolean;
  126410. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126411. /**
  126412. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126413. */
  126414. static get ShowLoadingScreen(): boolean;
  126415. static set ShowLoadingScreen(value: boolean);
  126416. /**
  126417. * Defines the current logging level (while loading the scene)
  126418. * @ignorenaming
  126419. */
  126420. static get loggingLevel(): number;
  126421. static set loggingLevel(value: number);
  126422. /**
  126423. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126424. */
  126425. static get CleanBoneMatrixWeights(): boolean;
  126426. static set CleanBoneMatrixWeights(value: boolean);
  126427. /**
  126428. * Event raised when a plugin is used to load a scene
  126429. */
  126430. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126431. private static _registeredPlugins;
  126432. private static _showingLoadingScreen;
  126433. /**
  126434. * Gets the default plugin (used to load Babylon files)
  126435. * @returns the .babylon plugin
  126436. */
  126437. static GetDefaultPlugin(): IRegisteredPlugin;
  126438. private static _GetPluginForExtension;
  126439. private static _GetPluginForDirectLoad;
  126440. private static _GetPluginForFilename;
  126441. private static _GetDirectLoad;
  126442. private static _LoadData;
  126443. private static _GetFileInfo;
  126444. /**
  126445. * Gets a plugin that can load the given extension
  126446. * @param extension defines the extension to load
  126447. * @returns a plugin or null if none works
  126448. */
  126449. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126450. /**
  126451. * Gets a boolean indicating that the given extension can be loaded
  126452. * @param extension defines the extension to load
  126453. * @returns true if the extension is supported
  126454. */
  126455. static IsPluginForExtensionAvailable(extension: string): boolean;
  126456. /**
  126457. * Adds a new plugin to the list of registered plugins
  126458. * @param plugin defines the plugin to add
  126459. */
  126460. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  126461. /**
  126462. * Import meshes into a scene
  126463. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126464. * @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)
  126465. * @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)
  126466. * @param scene the instance of BABYLON.Scene to append to
  126467. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  126468. * @param onProgress a callback with a progress event for each file being loaded
  126469. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126470. * @param pluginExtension the extension used to determine the plugin
  126471. * @returns The loaded plugin
  126472. */
  126473. 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>;
  126474. /**
  126475. * Import meshes into a scene
  126476. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126477. * @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)
  126478. * @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)
  126479. * @param scene the instance of BABYLON.Scene to append to
  126480. * @param onProgress a callback with a progress event for each file being loaded
  126481. * @param pluginExtension the extension used to determine the plugin
  126482. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  126483. */
  126484. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  126485. meshes: AbstractMesh[];
  126486. particleSystems: IParticleSystem[];
  126487. skeletons: Skeleton[];
  126488. animationGroups: AnimationGroup[];
  126489. }>;
  126490. /**
  126491. * Load a scene
  126492. * @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)
  126493. * @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)
  126494. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126495. * @param onSuccess a callback with the scene when import succeeds
  126496. * @param onProgress a callback with a progress event for each file being loaded
  126497. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126498. * @param pluginExtension the extension used to determine the plugin
  126499. * @returns The loaded plugin
  126500. */
  126501. 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>;
  126502. /**
  126503. * Load a scene
  126504. * @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)
  126505. * @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)
  126506. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126507. * @param onProgress a callback with a progress event for each file being loaded
  126508. * @param pluginExtension the extension used to determine the plugin
  126509. * @returns The loaded scene
  126510. */
  126511. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126512. /**
  126513. * Append a scene
  126514. * @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)
  126515. * @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)
  126516. * @param scene is the instance of BABYLON.Scene to append to
  126517. * @param onSuccess a callback with the scene when import succeeds
  126518. * @param onProgress a callback with a progress event for each file being loaded
  126519. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126520. * @param pluginExtension the extension used to determine the plugin
  126521. * @returns The loaded plugin
  126522. */
  126523. 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>;
  126524. /**
  126525. * Append a scene
  126526. * @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)
  126527. * @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)
  126528. * @param scene is the instance of BABYLON.Scene to append to
  126529. * @param onProgress a callback with a progress event for each file being loaded
  126530. * @param pluginExtension the extension used to determine the plugin
  126531. * @returns The given scene
  126532. */
  126533. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126534. /**
  126535. * Load a scene into an asset container
  126536. * @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)
  126537. * @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)
  126538. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126539. * @param onSuccess a callback with the scene when import succeeds
  126540. * @param onProgress a callback with a progress event for each file being loaded
  126541. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126542. * @param pluginExtension the extension used to determine the plugin
  126543. * @returns The loaded plugin
  126544. */
  126545. 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>;
  126546. /**
  126547. * Load a scene into an asset container
  126548. * @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)
  126549. * @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)
  126550. * @param scene is the instance of Scene to append to
  126551. * @param onProgress a callback with a progress event for each file being loaded
  126552. * @param pluginExtension the extension used to determine the plugin
  126553. * @returns The loaded asset container
  126554. */
  126555. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  126556. /**
  126557. * Import animations from a file into a scene
  126558. * @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)
  126559. * @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)
  126560. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126561. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126562. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126563. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126564. * @param onSuccess a callback with the scene when import succeeds
  126565. * @param onProgress a callback with a progress event for each file being loaded
  126566. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126567. * @param pluginExtension the extension used to determine the plugin
  126568. */
  126569. 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;
  126570. /**
  126571. * Import animations from a file into a scene
  126572. * @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)
  126573. * @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)
  126574. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126575. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126576. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126577. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126578. * @param onSuccess a callback with the scene when import succeeds
  126579. * @param onProgress a callback with a progress event for each file being loaded
  126580. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126581. * @param pluginExtension the extension used to determine the plugin
  126582. * @returns the updated scene with imported animations
  126583. */
  126584. 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>;
  126585. }
  126586. }
  126587. declare module BABYLON {
  126588. /**
  126589. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  126590. */
  126591. export type MotionControllerHandedness = "none" | "left" | "right";
  126592. /**
  126593. * The type of components available in motion controllers.
  126594. * This is not the name of the component.
  126595. */
  126596. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  126597. /**
  126598. * The state of a controller component
  126599. */
  126600. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  126601. /**
  126602. * The schema of motion controller layout.
  126603. * No object will be initialized using this interface
  126604. * This is used just to define the profile.
  126605. */
  126606. export interface IMotionControllerLayout {
  126607. /**
  126608. * Path to load the assets. Usually relative to the base path
  126609. */
  126610. assetPath: string;
  126611. /**
  126612. * Available components (unsorted)
  126613. */
  126614. components: {
  126615. /**
  126616. * A map of component Ids
  126617. */
  126618. [componentId: string]: {
  126619. /**
  126620. * The type of input the component outputs
  126621. */
  126622. type: MotionControllerComponentType;
  126623. /**
  126624. * The indices of this component in the gamepad object
  126625. */
  126626. gamepadIndices: {
  126627. /**
  126628. * Index of button
  126629. */
  126630. button?: number;
  126631. /**
  126632. * If available, index of x-axis
  126633. */
  126634. xAxis?: number;
  126635. /**
  126636. * If available, index of y-axis
  126637. */
  126638. yAxis?: number;
  126639. };
  126640. /**
  126641. * The mesh's root node name
  126642. */
  126643. rootNodeName: string;
  126644. /**
  126645. * Animation definitions for this model
  126646. */
  126647. visualResponses: {
  126648. [stateKey: string]: {
  126649. /**
  126650. * What property will be animated
  126651. */
  126652. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  126653. /**
  126654. * What states influence this visual response
  126655. */
  126656. states: MotionControllerComponentStateType[];
  126657. /**
  126658. * Type of animation - movement or visibility
  126659. */
  126660. valueNodeProperty: "transform" | "visibility";
  126661. /**
  126662. * Base node name to move. Its position will be calculated according to the min and max nodes
  126663. */
  126664. valueNodeName?: string;
  126665. /**
  126666. * Minimum movement node
  126667. */
  126668. minNodeName?: string;
  126669. /**
  126670. * Max movement node
  126671. */
  126672. maxNodeName?: string;
  126673. };
  126674. };
  126675. /**
  126676. * If touch enabled, what is the name of node to display user feedback
  126677. */
  126678. touchPointNodeName?: string;
  126679. };
  126680. };
  126681. /**
  126682. * Is it xr standard mapping or not
  126683. */
  126684. gamepadMapping: "" | "xr-standard";
  126685. /**
  126686. * Base root node of this entire model
  126687. */
  126688. rootNodeName: string;
  126689. /**
  126690. * Defines the main button component id
  126691. */
  126692. selectComponentId: string;
  126693. }
  126694. /**
  126695. * A definition for the layout map in the input profile
  126696. */
  126697. export interface IMotionControllerLayoutMap {
  126698. /**
  126699. * Layouts with handedness type as a key
  126700. */
  126701. [handedness: string]: IMotionControllerLayout;
  126702. }
  126703. /**
  126704. * The XR Input profile schema
  126705. * Profiles can be found here:
  126706. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  126707. */
  126708. export interface IMotionControllerProfile {
  126709. /**
  126710. * fallback profiles for this profileId
  126711. */
  126712. fallbackProfileIds: string[];
  126713. /**
  126714. * The layout map, with handedness as key
  126715. */
  126716. layouts: IMotionControllerLayoutMap;
  126717. /**
  126718. * The id of this profile
  126719. * correlates to the profile(s) in the xrInput.profiles array
  126720. */
  126721. profileId: string;
  126722. }
  126723. /**
  126724. * A helper-interface for the 3 meshes needed for controller button animation
  126725. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  126726. */
  126727. export interface IMotionControllerButtonMeshMap {
  126728. /**
  126729. * the mesh that defines the pressed value mesh position.
  126730. * This is used to find the max-position of this button
  126731. */
  126732. pressedMesh: AbstractMesh;
  126733. /**
  126734. * the mesh that defines the unpressed value mesh position.
  126735. * This is used to find the min (or initial) position of this button
  126736. */
  126737. unpressedMesh: AbstractMesh;
  126738. /**
  126739. * The mesh that will be changed when value changes
  126740. */
  126741. valueMesh: AbstractMesh;
  126742. }
  126743. /**
  126744. * A helper-interface for the 3 meshes needed for controller axis animation.
  126745. * This will be expanded when touchpad animations are fully supported
  126746. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  126747. */
  126748. export interface IMotionControllerMeshMap {
  126749. /**
  126750. * the mesh that defines the maximum value mesh position.
  126751. */
  126752. maxMesh?: AbstractMesh;
  126753. /**
  126754. * the mesh that defines the minimum value mesh position.
  126755. */
  126756. minMesh?: AbstractMesh;
  126757. /**
  126758. * The mesh that will be changed when axis value changes
  126759. */
  126760. valueMesh: AbstractMesh;
  126761. }
  126762. /**
  126763. * The elements needed for change-detection of the gamepad objects in motion controllers
  126764. */
  126765. export interface IMinimalMotionControllerObject {
  126766. /**
  126767. * Available axes of this controller
  126768. */
  126769. axes: number[];
  126770. /**
  126771. * An array of available buttons
  126772. */
  126773. buttons: Array<{
  126774. /**
  126775. * Value of the button/trigger
  126776. */
  126777. value: number;
  126778. /**
  126779. * If the button/trigger is currently touched
  126780. */
  126781. touched: boolean;
  126782. /**
  126783. * If the button/trigger is currently pressed
  126784. */
  126785. pressed: boolean;
  126786. }>;
  126787. /**
  126788. * EXPERIMENTAL haptic support.
  126789. */
  126790. hapticActuators?: Array<{
  126791. pulse: (value: number, duration: number) => Promise<boolean>;
  126792. }>;
  126793. }
  126794. /**
  126795. * An Abstract Motion controller
  126796. * This class receives an xrInput and a profile layout and uses those to initialize the components
  126797. * Each component has an observable to check for changes in value and state
  126798. */
  126799. export abstract class WebXRAbstractMotionController implements IDisposable {
  126800. protected scene: Scene;
  126801. protected layout: IMotionControllerLayout;
  126802. /**
  126803. * The gamepad object correlating to this controller
  126804. */
  126805. gamepadObject: IMinimalMotionControllerObject;
  126806. /**
  126807. * handedness (left/right/none) of this controller
  126808. */
  126809. handedness: MotionControllerHandedness;
  126810. private _initComponent;
  126811. private _modelReady;
  126812. /**
  126813. * A map of components (WebXRControllerComponent) in this motion controller
  126814. * Components have a ComponentType and can also have both button and axis definitions
  126815. */
  126816. readonly components: {
  126817. [id: string]: WebXRControllerComponent;
  126818. };
  126819. /**
  126820. * Disable the model's animation. Can be set at any time.
  126821. */
  126822. disableAnimation: boolean;
  126823. /**
  126824. * Observers registered here will be triggered when the model of this controller is done loading
  126825. */
  126826. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  126827. /**
  126828. * The profile id of this motion controller
  126829. */
  126830. abstract profileId: string;
  126831. /**
  126832. * The root mesh of the model. It is null if the model was not yet initialized
  126833. */
  126834. rootMesh: Nullable<AbstractMesh>;
  126835. /**
  126836. * constructs a new abstract motion controller
  126837. * @param scene the scene to which the model of the controller will be added
  126838. * @param layout The profile layout to load
  126839. * @param gamepadObject The gamepad object correlating to this controller
  126840. * @param handedness handedness (left/right/none) of this controller
  126841. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  126842. */
  126843. constructor(scene: Scene, layout: IMotionControllerLayout,
  126844. /**
  126845. * The gamepad object correlating to this controller
  126846. */
  126847. gamepadObject: IMinimalMotionControllerObject,
  126848. /**
  126849. * handedness (left/right/none) of this controller
  126850. */
  126851. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  126852. /**
  126853. * Dispose this controller, the model mesh and all its components
  126854. */
  126855. dispose(): void;
  126856. /**
  126857. * Returns all components of specific type
  126858. * @param type the type to search for
  126859. * @return an array of components with this type
  126860. */
  126861. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  126862. /**
  126863. * get a component based an its component id as defined in layout.components
  126864. * @param id the id of the component
  126865. * @returns the component correlates to the id or undefined if not found
  126866. */
  126867. getComponent(id: string): WebXRControllerComponent;
  126868. /**
  126869. * Get the list of components available in this motion controller
  126870. * @returns an array of strings correlating to available components
  126871. */
  126872. getComponentIds(): string[];
  126873. /**
  126874. * Get the first component of specific type
  126875. * @param type type of component to find
  126876. * @return a controller component or null if not found
  126877. */
  126878. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  126879. /**
  126880. * Get the main (Select) component of this controller as defined in the layout
  126881. * @returns the main component of this controller
  126882. */
  126883. getMainComponent(): WebXRControllerComponent;
  126884. /**
  126885. * Loads the model correlating to this controller
  126886. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  126887. * @returns A promise fulfilled with the result of the model loading
  126888. */
  126889. loadModel(): Promise<boolean>;
  126890. /**
  126891. * Update this model using the current XRFrame
  126892. * @param xrFrame the current xr frame to use and update the model
  126893. */
  126894. updateFromXRFrame(xrFrame: XRFrame): void;
  126895. /**
  126896. * Backwards compatibility due to a deeply-integrated typo
  126897. */
  126898. get handness(): XREye;
  126899. /**
  126900. * Pulse (vibrate) this controller
  126901. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  126902. * Consecutive calls to this function will cancel the last pulse call
  126903. *
  126904. * @param value the strength of the pulse in 0.0...1.0 range
  126905. * @param duration Duration of the pulse in milliseconds
  126906. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  126907. * @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
  126908. */
  126909. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  126910. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126911. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126912. /**
  126913. * Moves the axis on the controller mesh based on its current state
  126914. * @param axis the index of the axis
  126915. * @param axisValue the value of the axis which determines the meshes new position
  126916. * @hidden
  126917. */
  126918. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  126919. /**
  126920. * Update the model itself with the current frame data
  126921. * @param xrFrame the frame to use for updating the model mesh
  126922. */
  126923. protected updateModel(xrFrame: XRFrame): void;
  126924. /**
  126925. * Get the filename and path for this controller's model
  126926. * @returns a map of filename and path
  126927. */
  126928. protected abstract _getFilenameAndPath(): {
  126929. filename: string;
  126930. path: string;
  126931. };
  126932. /**
  126933. * This function is called before the mesh is loaded. It checks for loading constraints.
  126934. * For example, this function can check if the GLB loader is available
  126935. * If this function returns false, the generic controller will be loaded instead
  126936. * @returns Is the client ready to load the mesh
  126937. */
  126938. protected abstract _getModelLoadingConstraints(): boolean;
  126939. /**
  126940. * This function will be called after the model was successfully loaded and can be used
  126941. * for mesh transformations before it is available for the user
  126942. * @param meshes the loaded meshes
  126943. */
  126944. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  126945. /**
  126946. * Set the root mesh for this controller. Important for the WebXR controller class
  126947. * @param meshes the loaded meshes
  126948. */
  126949. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  126950. /**
  126951. * A function executed each frame that updates the mesh (if needed)
  126952. * @param xrFrame the current xrFrame
  126953. */
  126954. protected abstract _updateModel(xrFrame: XRFrame): void;
  126955. private _getGenericFilenameAndPath;
  126956. private _getGenericParentMesh;
  126957. }
  126958. }
  126959. declare module BABYLON {
  126960. /**
  126961. * A generic trigger-only motion controller for WebXR
  126962. */
  126963. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  126964. /**
  126965. * Static version of the profile id of this controller
  126966. */
  126967. static ProfileId: string;
  126968. profileId: string;
  126969. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  126970. protected _getFilenameAndPath(): {
  126971. filename: string;
  126972. path: string;
  126973. };
  126974. protected _getModelLoadingConstraints(): boolean;
  126975. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  126976. protected _setRootMesh(meshes: AbstractMesh[]): void;
  126977. protected _updateModel(): void;
  126978. }
  126979. }
  126980. declare module BABYLON {
  126981. /**
  126982. * Class containing static functions to help procedurally build meshes
  126983. */
  126984. export class SphereBuilder {
  126985. /**
  126986. * Creates a sphere mesh
  126987. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126988. * * 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`)
  126989. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126990. * * 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
  126991. * * 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)
  126992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126995. * @param name defines the name of the mesh
  126996. * @param options defines the options used to create the mesh
  126997. * @param scene defines the hosting scene
  126998. * @returns the sphere mesh
  126999. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127000. */
  127001. static CreateSphere(name: string, options: {
  127002. segments?: number;
  127003. diameter?: number;
  127004. diameterX?: number;
  127005. diameterY?: number;
  127006. diameterZ?: number;
  127007. arc?: number;
  127008. slice?: number;
  127009. sideOrientation?: number;
  127010. frontUVs?: Vector4;
  127011. backUVs?: Vector4;
  127012. updatable?: boolean;
  127013. }, scene?: Nullable<Scene>): Mesh;
  127014. }
  127015. }
  127016. declare module BABYLON {
  127017. /**
  127018. * A profiled motion controller has its profile loaded from an online repository.
  127019. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  127020. */
  127021. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  127022. private _repositoryUrl;
  127023. private _buttonMeshMapping;
  127024. private _touchDots;
  127025. /**
  127026. * The profile ID of this controller. Will be populated when the controller initializes.
  127027. */
  127028. profileId: string;
  127029. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  127030. dispose(): void;
  127031. protected _getFilenameAndPath(): {
  127032. filename: string;
  127033. path: string;
  127034. };
  127035. protected _getModelLoadingConstraints(): boolean;
  127036. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  127037. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127038. protected _updateModel(_xrFrame: XRFrame): void;
  127039. }
  127040. }
  127041. declare module BABYLON {
  127042. /**
  127043. * A construction function type to create a new controller based on an xrInput object
  127044. */
  127045. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  127046. /**
  127047. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  127048. *
  127049. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  127050. * it should be replaced with auto-loaded controllers.
  127051. *
  127052. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  127053. */
  127054. export class WebXRMotionControllerManager {
  127055. private static _AvailableControllers;
  127056. private static _Fallbacks;
  127057. private static _ProfileLoadingPromises;
  127058. private static _ProfilesList;
  127059. /**
  127060. * The base URL of the online controller repository. Can be changed at any time.
  127061. */
  127062. static BaseRepositoryUrl: string;
  127063. /**
  127064. * Which repository gets priority - local or online
  127065. */
  127066. static PrioritizeOnlineRepository: boolean;
  127067. /**
  127068. * Use the online repository, or use only locally-defined controllers
  127069. */
  127070. static UseOnlineRepository: boolean;
  127071. /**
  127072. * Clear the cache used for profile loading and reload when requested again
  127073. */
  127074. static ClearProfilesCache(): void;
  127075. /**
  127076. * Register the default fallbacks.
  127077. * This function is called automatically when this file is imported.
  127078. */
  127079. static DefaultFallbacks(): void;
  127080. /**
  127081. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  127082. * @param profileId the profile to which a fallback needs to be found
  127083. * @return an array with corresponding fallback profiles
  127084. */
  127085. static FindFallbackWithProfileId(profileId: string): string[];
  127086. /**
  127087. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  127088. * The order of search:
  127089. *
  127090. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  127091. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  127092. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  127093. * 4) return the generic trigger controller if none were found
  127094. *
  127095. * @param xrInput the xrInput to which a new controller is initialized
  127096. * @param scene the scene to which the model will be added
  127097. * @param forceProfile force a certain profile for this controller
  127098. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  127099. */
  127100. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  127101. /**
  127102. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  127103. *
  127104. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  127105. *
  127106. * @param type the profile type to register
  127107. * @param constructFunction the function to be called when loading this profile
  127108. */
  127109. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  127110. /**
  127111. * Register a fallback to a specific profile.
  127112. * @param profileId the profileId that will receive the fallbacks
  127113. * @param fallbacks A list of fallback profiles
  127114. */
  127115. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  127116. /**
  127117. * Will update the list of profiles available in the repository
  127118. * @return a promise that resolves to a map of profiles available online
  127119. */
  127120. static UpdateProfilesList(): Promise<{
  127121. [profile: string]: string;
  127122. }>;
  127123. private static _LoadProfileFromRepository;
  127124. private static _LoadProfilesFromAvailableControllers;
  127125. }
  127126. }
  127127. declare module BABYLON {
  127128. /**
  127129. * Configuration options for the WebXR controller creation
  127130. */
  127131. export interface IWebXRControllerOptions {
  127132. /**
  127133. * Should the controller mesh be animated when a user interacts with it
  127134. * The pressed buttons / thumbstick and touchpad animations will be disabled
  127135. */
  127136. disableMotionControllerAnimation?: boolean;
  127137. /**
  127138. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  127139. */
  127140. doNotLoadControllerMesh?: boolean;
  127141. /**
  127142. * Force a specific controller type for this controller.
  127143. * This can be used when creating your own profile or when testing different controllers
  127144. */
  127145. forceControllerProfile?: string;
  127146. /**
  127147. * Defines a rendering group ID for meshes that will be loaded.
  127148. * This is for the default controllers only.
  127149. */
  127150. renderingGroupId?: number;
  127151. }
  127152. /**
  127153. * Represents an XR controller
  127154. */
  127155. export class WebXRInputSource {
  127156. private _scene;
  127157. /** The underlying input source for the controller */
  127158. inputSource: XRInputSource;
  127159. private _options;
  127160. private _tmpVector;
  127161. private _uniqueId;
  127162. /**
  127163. * 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
  127164. */
  127165. grip?: AbstractMesh;
  127166. /**
  127167. * If available, this is the gamepad object related to this controller.
  127168. * Using this object it is possible to get click events and trackpad changes of the
  127169. * webxr controller that is currently being used.
  127170. */
  127171. motionController?: WebXRAbstractMotionController;
  127172. /**
  127173. * Event that fires when the controller is removed/disposed.
  127174. * The object provided as event data is this controller, after associated assets were disposed.
  127175. * uniqueId is still available.
  127176. */
  127177. onDisposeObservable: Observable<WebXRInputSource>;
  127178. /**
  127179. * Will be triggered when the mesh associated with the motion controller is done loading.
  127180. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  127181. * A shortened version of controller -> motion controller -> on mesh loaded.
  127182. */
  127183. onMeshLoadedObservable: Observable<AbstractMesh>;
  127184. /**
  127185. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  127186. */
  127187. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  127188. /**
  127189. * Pointer which can be used to select objects or attach a visible laser to
  127190. */
  127191. pointer: AbstractMesh;
  127192. /**
  127193. * Creates the input source object
  127194. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  127195. * @param _scene the scene which the controller should be associated to
  127196. * @param inputSource the underlying input source for the controller
  127197. * @param _options options for this controller creation
  127198. */
  127199. constructor(_scene: Scene,
  127200. /** The underlying input source for the controller */
  127201. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  127202. /**
  127203. * Get this controllers unique id
  127204. */
  127205. get uniqueId(): string;
  127206. /**
  127207. * Disposes of the object
  127208. */
  127209. dispose(): void;
  127210. /**
  127211. * Gets a world space ray coming from the pointer or grip
  127212. * @param result the resulting ray
  127213. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  127214. */
  127215. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  127216. /**
  127217. * Updates the controller pose based on the given XRFrame
  127218. * @param xrFrame xr frame to update the pose with
  127219. * @param referenceSpace reference space to use
  127220. */
  127221. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  127222. }
  127223. }
  127224. declare module BABYLON {
  127225. /**
  127226. * The schema for initialization options of the XR Input class
  127227. */
  127228. export interface IWebXRInputOptions {
  127229. /**
  127230. * If set to true no model will be automatically loaded
  127231. */
  127232. doNotLoadControllerMeshes?: boolean;
  127233. /**
  127234. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  127235. * If not found, the xr input profile data will be used.
  127236. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  127237. */
  127238. forceInputProfile?: string;
  127239. /**
  127240. * Do not send a request to the controller repository to load the profile.
  127241. *
  127242. * Instead, use the controllers available in babylon itself.
  127243. */
  127244. disableOnlineControllerRepository?: boolean;
  127245. /**
  127246. * A custom URL for the controllers repository
  127247. */
  127248. customControllersRepositoryURL?: string;
  127249. /**
  127250. * Should the controller model's components not move according to the user input
  127251. */
  127252. disableControllerAnimation?: boolean;
  127253. /**
  127254. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  127255. */
  127256. controllerOptions?: IWebXRControllerOptions;
  127257. }
  127258. /**
  127259. * XR input used to track XR inputs such as controllers/rays
  127260. */
  127261. export class WebXRInput implements IDisposable {
  127262. /**
  127263. * the xr session manager for this session
  127264. */
  127265. xrSessionManager: WebXRSessionManager;
  127266. /**
  127267. * the WebXR camera for this session. Mainly used for teleportation
  127268. */
  127269. xrCamera: WebXRCamera;
  127270. private readonly options;
  127271. /**
  127272. * XR controllers being tracked
  127273. */
  127274. controllers: Array<WebXRInputSource>;
  127275. private _frameObserver;
  127276. private _sessionEndedObserver;
  127277. private _sessionInitObserver;
  127278. /**
  127279. * Event when a controller has been connected/added
  127280. */
  127281. onControllerAddedObservable: Observable<WebXRInputSource>;
  127282. /**
  127283. * Event when a controller has been removed/disconnected
  127284. */
  127285. onControllerRemovedObservable: Observable<WebXRInputSource>;
  127286. /**
  127287. * Initializes the WebXRInput
  127288. * @param xrSessionManager the xr session manager for this session
  127289. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  127290. * @param options = initialization options for this xr input
  127291. */
  127292. constructor(
  127293. /**
  127294. * the xr session manager for this session
  127295. */
  127296. xrSessionManager: WebXRSessionManager,
  127297. /**
  127298. * the WebXR camera for this session. Mainly used for teleportation
  127299. */
  127300. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  127301. private _onInputSourcesChange;
  127302. private _addAndRemoveControllers;
  127303. /**
  127304. * Disposes of the object
  127305. */
  127306. dispose(): void;
  127307. }
  127308. }
  127309. declare module BABYLON {
  127310. /**
  127311. * This is the base class for all WebXR features.
  127312. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  127313. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  127314. */
  127315. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  127316. protected _xrSessionManager: WebXRSessionManager;
  127317. private _attached;
  127318. private _removeOnDetach;
  127319. /**
  127320. * Should auto-attach be disabled?
  127321. */
  127322. disableAutoAttach: boolean;
  127323. /**
  127324. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  127325. */
  127326. xrNativeFeatureName: string;
  127327. /**
  127328. * Construct a new (abstract) WebXR feature
  127329. * @param _xrSessionManager the xr session manager for this feature
  127330. */
  127331. constructor(_xrSessionManager: WebXRSessionManager);
  127332. /**
  127333. * Is this feature attached
  127334. */
  127335. get attached(): boolean;
  127336. /**
  127337. * attach this feature
  127338. *
  127339. * @param force should attachment be forced (even when already attached)
  127340. * @returns true if successful, false is failed or already attached
  127341. */
  127342. attach(force?: boolean): boolean;
  127343. /**
  127344. * detach this feature.
  127345. *
  127346. * @returns true if successful, false if failed or already detached
  127347. */
  127348. detach(): boolean;
  127349. /**
  127350. * Dispose this feature and all of the resources attached
  127351. */
  127352. dispose(): void;
  127353. /**
  127354. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127355. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127356. *
  127357. * @returns whether or not the feature is compatible in this environment
  127358. */
  127359. isCompatible(): boolean;
  127360. /**
  127361. * This is used to register callbacks that will automatically be removed when detach is called.
  127362. * @param observable the observable to which the observer will be attached
  127363. * @param callback the callback to register
  127364. */
  127365. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  127366. /**
  127367. * Code in this function will be executed on each xrFrame received from the browser.
  127368. * This function will not execute after the feature is detached.
  127369. * @param _xrFrame the current frame
  127370. */
  127371. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  127372. }
  127373. }
  127374. declare module BABYLON {
  127375. /**
  127376. * Renders a layer on top of an existing scene
  127377. */
  127378. export class UtilityLayerRenderer implements IDisposable {
  127379. /** the original scene that will be rendered on top of */
  127380. originalScene: Scene;
  127381. private _pointerCaptures;
  127382. private _lastPointerEvents;
  127383. private static _DefaultUtilityLayer;
  127384. private static _DefaultKeepDepthUtilityLayer;
  127385. private _sharedGizmoLight;
  127386. private _renderCamera;
  127387. /**
  127388. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  127389. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  127390. * @returns the camera that is used when rendering the utility layer
  127391. */
  127392. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127393. /**
  127394. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127395. * @param cam the camera that should be used when rendering the utility layer
  127396. */
  127397. setRenderCamera(cam: Nullable<Camera>): void;
  127398. /**
  127399. * @hidden
  127400. * Light which used by gizmos to get light shading
  127401. */
  127402. _getSharedGizmoLight(): HemisphericLight;
  127403. /**
  127404. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127405. */
  127406. pickUtilitySceneFirst: boolean;
  127407. /**
  127408. * 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)
  127409. */
  127410. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127411. /**
  127412. * 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)
  127413. */
  127414. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127415. /**
  127416. * The scene that is rendered on top of the original scene
  127417. */
  127418. utilityLayerScene: Scene;
  127419. /**
  127420. * If the utility layer should automatically be rendered on top of existing scene
  127421. */
  127422. shouldRender: boolean;
  127423. /**
  127424. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127425. */
  127426. onlyCheckPointerDownEvents: boolean;
  127427. /**
  127428. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127429. */
  127430. processAllEvents: boolean;
  127431. /**
  127432. * Observable raised when the pointer move from the utility layer scene to the main scene
  127433. */
  127434. onPointerOutObservable: Observable<number>;
  127435. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  127436. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  127437. private _afterRenderObserver;
  127438. private _sceneDisposeObserver;
  127439. private _originalPointerObserver;
  127440. /**
  127441. * Instantiates a UtilityLayerRenderer
  127442. * @param originalScene the original scene that will be rendered on top of
  127443. * @param handleEvents boolean indicating if the utility layer should handle events
  127444. */
  127445. constructor(
  127446. /** the original scene that will be rendered on top of */
  127447. originalScene: Scene, handleEvents?: boolean);
  127448. private _notifyObservers;
  127449. /**
  127450. * Renders the utility layers scene on top of the original scene
  127451. */
  127452. render(): void;
  127453. /**
  127454. * Disposes of the renderer
  127455. */
  127456. dispose(): void;
  127457. private _updateCamera;
  127458. }
  127459. }
  127460. declare module BABYLON {
  127461. /**
  127462. * Options interface for the pointer selection module
  127463. */
  127464. export interface IWebXRControllerPointerSelectionOptions {
  127465. /**
  127466. * if provided, this scene will be used to render meshes.
  127467. */
  127468. customUtilityLayerScene?: Scene;
  127469. /**
  127470. * 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)
  127471. * If not disabled, the last picked point will be used to execute a pointer up event
  127472. * If disabled, pointer up event will be triggered right after the pointer down event.
  127473. * Used in screen and gaze target ray mode only
  127474. */
  127475. disablePointerUpOnTouchOut: boolean;
  127476. /**
  127477. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  127478. */
  127479. forceGazeMode: boolean;
  127480. /**
  127481. * 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
  127482. * to start a new countdown to the pointer down event.
  127483. * Defaults to 1.
  127484. */
  127485. gazeModePointerMovedFactor?: number;
  127486. /**
  127487. * Different button type to use instead of the main component
  127488. */
  127489. overrideButtonId?: string;
  127490. /**
  127491. * use this rendering group id for the meshes (optional)
  127492. */
  127493. renderingGroupId?: number;
  127494. /**
  127495. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  127496. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  127497. * 3000 means 3 seconds between pointing at something and selecting it
  127498. */
  127499. timeToSelect?: number;
  127500. /**
  127501. * Should meshes created here be added to a utility layer or the main scene
  127502. */
  127503. useUtilityLayer?: boolean;
  127504. /**
  127505. * Optional WebXR camera to be used for gaze selection
  127506. */
  127507. gazeCamera?: WebXRCamera;
  127508. /**
  127509. * the xr input to use with this pointer selection
  127510. */
  127511. xrInput: WebXRInput;
  127512. }
  127513. /**
  127514. * A module that will enable pointer selection for motion controllers of XR Input Sources
  127515. */
  127516. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  127517. private readonly _options;
  127518. private static _idCounter;
  127519. private _attachController;
  127520. private _controllers;
  127521. private _scene;
  127522. private _tmpVectorForPickCompare;
  127523. /**
  127524. * The module's name
  127525. */
  127526. static readonly Name: string;
  127527. /**
  127528. * The (Babylon) version of this module.
  127529. * This is an integer representing the implementation version.
  127530. * This number does not correspond to the WebXR specs version
  127531. */
  127532. static readonly Version: number;
  127533. /**
  127534. * Disable lighting on the laser pointer (so it will always be visible)
  127535. */
  127536. disablePointerLighting: boolean;
  127537. /**
  127538. * Disable lighting on the selection mesh (so it will always be visible)
  127539. */
  127540. disableSelectionMeshLighting: boolean;
  127541. /**
  127542. * Should the laser pointer be displayed
  127543. */
  127544. displayLaserPointer: boolean;
  127545. /**
  127546. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  127547. */
  127548. displaySelectionMesh: boolean;
  127549. /**
  127550. * This color will be set to the laser pointer when selection is triggered
  127551. */
  127552. laserPointerPickedColor: Color3;
  127553. /**
  127554. * Default color of the laser pointer
  127555. */
  127556. laserPointerDefaultColor: Color3;
  127557. /**
  127558. * default color of the selection ring
  127559. */
  127560. selectionMeshDefaultColor: Color3;
  127561. /**
  127562. * This color will be applied to the selection ring when selection is triggered
  127563. */
  127564. selectionMeshPickedColor: Color3;
  127565. /**
  127566. * Optional filter to be used for ray selection. This predicate shares behavior with
  127567. * scene.pointerMovePredicate which takes priority if it is also assigned.
  127568. */
  127569. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127570. /**
  127571. * constructs a new background remover module
  127572. * @param _xrSessionManager the session manager for this module
  127573. * @param _options read-only options to be used in this module
  127574. */
  127575. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  127576. /**
  127577. * attach this feature
  127578. * Will usually be called by the features manager
  127579. *
  127580. * @returns true if successful.
  127581. */
  127582. attach(): boolean;
  127583. /**
  127584. * detach this feature.
  127585. * Will usually be called by the features manager
  127586. *
  127587. * @returns true if successful.
  127588. */
  127589. detach(): boolean;
  127590. /**
  127591. * Will get the mesh under a specific pointer.
  127592. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  127593. * @param controllerId the controllerId to check
  127594. * @returns The mesh under pointer or null if no mesh is under the pointer
  127595. */
  127596. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  127597. /**
  127598. * Get the xr controller that correlates to the pointer id in the pointer event
  127599. *
  127600. * @param id the pointer id to search for
  127601. * @returns the controller that correlates to this id or null if not found
  127602. */
  127603. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  127604. protected _onXRFrame(_xrFrame: XRFrame): void;
  127605. private _attachGazeMode;
  127606. private _attachScreenRayMode;
  127607. private _attachTrackedPointerRayMode;
  127608. private _convertNormalToDirectionOfRay;
  127609. private _detachController;
  127610. private _generateNewMeshPair;
  127611. private _pickingMoved;
  127612. private _updatePointerDistance;
  127613. /** @hidden */
  127614. get lasterPointerDefaultColor(): Color3;
  127615. }
  127616. }
  127617. declare module BABYLON {
  127618. /**
  127619. * Button which can be used to enter a different mode of XR
  127620. */
  127621. export class WebXREnterExitUIButton {
  127622. /** button element */
  127623. element: HTMLElement;
  127624. /** XR initialization options for the button */
  127625. sessionMode: XRSessionMode;
  127626. /** Reference space type */
  127627. referenceSpaceType: XRReferenceSpaceType;
  127628. /**
  127629. * Creates a WebXREnterExitUIButton
  127630. * @param element button element
  127631. * @param sessionMode XR initialization session mode
  127632. * @param referenceSpaceType the type of reference space to be used
  127633. */
  127634. constructor(
  127635. /** button element */
  127636. element: HTMLElement,
  127637. /** XR initialization options for the button */
  127638. sessionMode: XRSessionMode,
  127639. /** Reference space type */
  127640. referenceSpaceType: XRReferenceSpaceType);
  127641. /**
  127642. * Extendable function which can be used to update the button's visuals when the state changes
  127643. * @param activeButton the current active button in the UI
  127644. */
  127645. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  127646. }
  127647. /**
  127648. * Options to create the webXR UI
  127649. */
  127650. export class WebXREnterExitUIOptions {
  127651. /**
  127652. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  127653. */
  127654. customButtons?: Array<WebXREnterExitUIButton>;
  127655. /**
  127656. * A reference space type to use when creating the default button.
  127657. * Default is local-floor
  127658. */
  127659. referenceSpaceType?: XRReferenceSpaceType;
  127660. /**
  127661. * Context to enter xr with
  127662. */
  127663. renderTarget?: Nullable<WebXRRenderTarget>;
  127664. /**
  127665. * A session mode to use when creating the default button.
  127666. * Default is immersive-vr
  127667. */
  127668. sessionMode?: XRSessionMode;
  127669. /**
  127670. * A list of optional features to init the session with
  127671. */
  127672. optionalFeatures?: string[];
  127673. /**
  127674. * A list of optional features to init the session with
  127675. */
  127676. requiredFeatures?: string[];
  127677. }
  127678. /**
  127679. * UI to allow the user to enter/exit XR mode
  127680. */
  127681. export class WebXREnterExitUI implements IDisposable {
  127682. private scene;
  127683. /** version of the options passed to this UI */
  127684. options: WebXREnterExitUIOptions;
  127685. private _activeButton;
  127686. private _buttons;
  127687. private _overlay;
  127688. /**
  127689. * Fired every time the active button is changed.
  127690. *
  127691. * When xr is entered via a button that launches xr that button will be the callback parameter
  127692. *
  127693. * When exiting xr the callback parameter will be null)
  127694. */
  127695. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  127696. /**
  127697. *
  127698. * @param scene babylon scene object to use
  127699. * @param options (read-only) version of the options passed to this UI
  127700. */
  127701. private constructor();
  127702. /**
  127703. * Creates UI to allow the user to enter/exit XR mode
  127704. * @param scene the scene to add the ui to
  127705. * @param helper the xr experience helper to enter/exit xr with
  127706. * @param options options to configure the UI
  127707. * @returns the created ui
  127708. */
  127709. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  127710. /**
  127711. * Disposes of the XR UI component
  127712. */
  127713. dispose(): void;
  127714. private _updateButtons;
  127715. }
  127716. }
  127717. declare module BABYLON {
  127718. /**
  127719. * Class containing static functions to help procedurally build meshes
  127720. */
  127721. export class LinesBuilder {
  127722. /**
  127723. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127724. * * 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
  127725. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127726. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127727. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127728. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127729. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127730. * * 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
  127731. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127734. * @param name defines the name of the new line system
  127735. * @param options defines the options used to create the line system
  127736. * @param scene defines the hosting scene
  127737. * @returns a new line system mesh
  127738. */
  127739. static CreateLineSystem(name: string, options: {
  127740. lines: Vector3[][];
  127741. updatable?: boolean;
  127742. instance?: Nullable<LinesMesh>;
  127743. colors?: Nullable<Color4[][]>;
  127744. useVertexAlpha?: boolean;
  127745. }, scene: Nullable<Scene>): LinesMesh;
  127746. /**
  127747. * Creates a line mesh
  127748. * 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
  127749. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127750. * * The parameter `points` is an array successive Vector3
  127751. * * 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
  127752. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127753. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127754. * * When updating an instance, remember that only point positions can change, not the number of points
  127755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127757. * @param name defines the name of the new line system
  127758. * @param options defines the options used to create the line system
  127759. * @param scene defines the hosting scene
  127760. * @returns a new line mesh
  127761. */
  127762. static CreateLines(name: string, options: {
  127763. points: Vector3[];
  127764. updatable?: boolean;
  127765. instance?: Nullable<LinesMesh>;
  127766. colors?: Color4[];
  127767. useVertexAlpha?: boolean;
  127768. }, scene?: Nullable<Scene>): LinesMesh;
  127769. /**
  127770. * Creates a dashed line mesh
  127771. * * 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
  127772. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127773. * * The parameter `points` is an array successive Vector3
  127774. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127775. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127776. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127777. * * 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
  127778. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127779. * * When updating an instance, remember that only point positions can change, not the number of points
  127780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127781. * @param name defines the name of the mesh
  127782. * @param options defines the options used to create the mesh
  127783. * @param scene defines the hosting scene
  127784. * @returns the dashed line mesh
  127785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127786. */
  127787. static CreateDashedLines(name: string, options: {
  127788. points: Vector3[];
  127789. dashSize?: number;
  127790. gapSize?: number;
  127791. dashNb?: number;
  127792. updatable?: boolean;
  127793. instance?: LinesMesh;
  127794. useVertexAlpha?: boolean;
  127795. }, scene?: Nullable<Scene>): LinesMesh;
  127796. }
  127797. }
  127798. declare module BABYLON {
  127799. /**
  127800. * Construction options for a timer
  127801. */
  127802. export interface ITimerOptions<T> {
  127803. /**
  127804. * Time-to-end
  127805. */
  127806. timeout: number;
  127807. /**
  127808. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  127809. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  127810. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  127811. */
  127812. contextObservable: Observable<T>;
  127813. /**
  127814. * Optional parameters when adding an observer to the observable
  127815. */
  127816. observableParameters?: {
  127817. mask?: number;
  127818. insertFirst?: boolean;
  127819. scope?: any;
  127820. };
  127821. /**
  127822. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  127823. */
  127824. breakCondition?: (data?: ITimerData<T>) => boolean;
  127825. /**
  127826. * Will be triggered when the time condition has met
  127827. */
  127828. onEnded?: (data: ITimerData<any>) => void;
  127829. /**
  127830. * Will be triggered when the break condition has met (prematurely ended)
  127831. */
  127832. onAborted?: (data: ITimerData<any>) => void;
  127833. /**
  127834. * Optional function to execute on each tick (or count)
  127835. */
  127836. onTick?: (data: ITimerData<any>) => void;
  127837. }
  127838. /**
  127839. * An interface defining the data sent by the timer
  127840. */
  127841. export interface ITimerData<T> {
  127842. /**
  127843. * When did it start
  127844. */
  127845. startTime: number;
  127846. /**
  127847. * Time now
  127848. */
  127849. currentTime: number;
  127850. /**
  127851. * Time passed since started
  127852. */
  127853. deltaTime: number;
  127854. /**
  127855. * How much is completed, in [0.0...1.0].
  127856. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  127857. */
  127858. completeRate: number;
  127859. /**
  127860. * What the registered observable sent in the last count
  127861. */
  127862. payload: T;
  127863. }
  127864. /**
  127865. * The current state of the timer
  127866. */
  127867. export enum TimerState {
  127868. /**
  127869. * Timer initialized, not yet started
  127870. */
  127871. INIT = 0,
  127872. /**
  127873. * Timer started and counting
  127874. */
  127875. STARTED = 1,
  127876. /**
  127877. * Timer ended (whether aborted or time reached)
  127878. */
  127879. ENDED = 2
  127880. }
  127881. /**
  127882. * A simple version of the timer. Will take options and start the timer immediately after calling it
  127883. *
  127884. * @param options options with which to initialize this timer
  127885. */
  127886. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  127887. /**
  127888. * An advanced implementation of a timer class
  127889. */
  127890. export class AdvancedTimer<T = any> implements IDisposable {
  127891. /**
  127892. * Will notify each time the timer calculates the remaining time
  127893. */
  127894. onEachCountObservable: Observable<ITimerData<T>>;
  127895. /**
  127896. * Will trigger when the timer was aborted due to the break condition
  127897. */
  127898. onTimerAbortedObservable: Observable<ITimerData<T>>;
  127899. /**
  127900. * Will trigger when the timer ended successfully
  127901. */
  127902. onTimerEndedObservable: Observable<ITimerData<T>>;
  127903. /**
  127904. * Will trigger when the timer state has changed
  127905. */
  127906. onStateChangedObservable: Observable<TimerState>;
  127907. private _observer;
  127908. private _contextObservable;
  127909. private _observableParameters;
  127910. private _startTime;
  127911. private _timer;
  127912. private _state;
  127913. private _breakCondition;
  127914. private _timeToEnd;
  127915. private _breakOnNextTick;
  127916. /**
  127917. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  127918. * @param options construction options for this advanced timer
  127919. */
  127920. constructor(options: ITimerOptions<T>);
  127921. /**
  127922. * set a breaking condition for this timer. Default is to never break during count
  127923. * @param predicate the new break condition. Returns true to break, false otherwise
  127924. */
  127925. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  127926. /**
  127927. * Reset ALL associated observables in this advanced timer
  127928. */
  127929. clearObservables(): void;
  127930. /**
  127931. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  127932. *
  127933. * @param timeToEnd how much time to measure until timer ended
  127934. */
  127935. start(timeToEnd?: number): void;
  127936. /**
  127937. * Will force a stop on the next tick.
  127938. */
  127939. stop(): void;
  127940. /**
  127941. * Dispose this timer, clearing all resources
  127942. */
  127943. dispose(): void;
  127944. private _setState;
  127945. private _tick;
  127946. private _stop;
  127947. }
  127948. }
  127949. declare module BABYLON {
  127950. /**
  127951. * The options container for the teleportation module
  127952. */
  127953. export interface IWebXRTeleportationOptions {
  127954. /**
  127955. * if provided, this scene will be used to render meshes.
  127956. */
  127957. customUtilityLayerScene?: Scene;
  127958. /**
  127959. * Values to configure the default target mesh
  127960. */
  127961. defaultTargetMeshOptions?: {
  127962. /**
  127963. * Fill color of the teleportation area
  127964. */
  127965. teleportationFillColor?: string;
  127966. /**
  127967. * Border color for the teleportation area
  127968. */
  127969. teleportationBorderColor?: string;
  127970. /**
  127971. * Disable the mesh's animation sequence
  127972. */
  127973. disableAnimation?: boolean;
  127974. /**
  127975. * Disable lighting on the material or the ring and arrow
  127976. */
  127977. disableLighting?: boolean;
  127978. /**
  127979. * Override the default material of the torus and arrow
  127980. */
  127981. torusArrowMaterial?: Material;
  127982. };
  127983. /**
  127984. * A list of meshes to use as floor meshes.
  127985. * Meshes can be added and removed after initializing the feature using the
  127986. * addFloorMesh and removeFloorMesh functions
  127987. * If empty, rotation will still work
  127988. */
  127989. floorMeshes?: AbstractMesh[];
  127990. /**
  127991. * use this rendering group id for the meshes (optional)
  127992. */
  127993. renderingGroupId?: number;
  127994. /**
  127995. * Should teleportation move only to snap points
  127996. */
  127997. snapPointsOnly?: boolean;
  127998. /**
  127999. * An array of points to which the teleportation will snap to.
  128000. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  128001. */
  128002. snapPositions?: Vector3[];
  128003. /**
  128004. * How close should the teleportation ray be in order to snap to position.
  128005. * Default to 0.8 units (meters)
  128006. */
  128007. snapToPositionRadius?: number;
  128008. /**
  128009. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  128010. * If you want to support rotation, make sure your mesh has a direction indicator.
  128011. *
  128012. * When left untouched, the default mesh will be initialized.
  128013. */
  128014. teleportationTargetMesh?: AbstractMesh;
  128015. /**
  128016. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  128017. */
  128018. timeToTeleport?: number;
  128019. /**
  128020. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  128021. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  128022. */
  128023. useMainComponentOnly?: boolean;
  128024. /**
  128025. * Should meshes created here be added to a utility layer or the main scene
  128026. */
  128027. useUtilityLayer?: boolean;
  128028. /**
  128029. * Babylon XR Input class for controller
  128030. */
  128031. xrInput: WebXRInput;
  128032. }
  128033. /**
  128034. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  128035. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  128036. * the input of the attached controllers.
  128037. */
  128038. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  128039. private _options;
  128040. private _controllers;
  128041. private _currentTeleportationControllerId;
  128042. private _floorMeshes;
  128043. private _quadraticBezierCurve;
  128044. private _selectionFeature;
  128045. private _snapToPositions;
  128046. private _snappedToPoint;
  128047. private _teleportationRingMaterial?;
  128048. private _tmpRay;
  128049. private _tmpVector;
  128050. /**
  128051. * The module's name
  128052. */
  128053. static readonly Name: string;
  128054. /**
  128055. * The (Babylon) version of this module.
  128056. * This is an integer representing the implementation version.
  128057. * This number does not correspond to the webxr specs version
  128058. */
  128059. static readonly Version: number;
  128060. /**
  128061. * Is movement backwards enabled
  128062. */
  128063. backwardsMovementEnabled: boolean;
  128064. /**
  128065. * Distance to travel when moving backwards
  128066. */
  128067. backwardsTeleportationDistance: number;
  128068. /**
  128069. * The distance from the user to the inspection point in the direction of the controller
  128070. * A higher number will allow the user to move further
  128071. * defaults to 5 (meters, in xr units)
  128072. */
  128073. parabolicCheckRadius: number;
  128074. /**
  128075. * Should the module support parabolic ray on top of direct ray
  128076. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  128077. * Very helpful when moving between floors / different heights
  128078. */
  128079. parabolicRayEnabled: boolean;
  128080. /**
  128081. * How much rotation should be applied when rotating right and left
  128082. */
  128083. rotationAngle: number;
  128084. /**
  128085. * Is rotation enabled when moving forward?
  128086. * Disabling this feature will prevent the user from deciding the direction when teleporting
  128087. */
  128088. rotationEnabled: boolean;
  128089. /**
  128090. * constructs a new anchor system
  128091. * @param _xrSessionManager an instance of WebXRSessionManager
  128092. * @param _options configuration object for this feature
  128093. */
  128094. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  128095. /**
  128096. * Get the snapPointsOnly flag
  128097. */
  128098. get snapPointsOnly(): boolean;
  128099. /**
  128100. * Sets the snapPointsOnly flag
  128101. * @param snapToPoints should teleportation be exclusively to snap points
  128102. */
  128103. set snapPointsOnly(snapToPoints: boolean);
  128104. /**
  128105. * Add a new mesh to the floor meshes array
  128106. * @param mesh the mesh to use as floor mesh
  128107. */
  128108. addFloorMesh(mesh: AbstractMesh): void;
  128109. /**
  128110. * Add a new snap-to point to fix teleportation to this position
  128111. * @param newSnapPoint The new Snap-To point
  128112. */
  128113. addSnapPoint(newSnapPoint: Vector3): void;
  128114. attach(): boolean;
  128115. detach(): boolean;
  128116. dispose(): void;
  128117. /**
  128118. * Remove a mesh from the floor meshes array
  128119. * @param mesh the mesh to remove
  128120. */
  128121. removeFloorMesh(mesh: AbstractMesh): void;
  128122. /**
  128123. * Remove a mesh from the floor meshes array using its name
  128124. * @param name the mesh name to remove
  128125. */
  128126. removeFloorMeshByName(name: string): void;
  128127. /**
  128128. * 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
  128129. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  128130. * @returns was the point found and removed or not
  128131. */
  128132. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  128133. /**
  128134. * This function sets a selection feature that will be disabled when
  128135. * the forward ray is shown and will be reattached when hidden.
  128136. * This is used to remove the selection rays when moving.
  128137. * @param selectionFeature the feature to disable when forward movement is enabled
  128138. */
  128139. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  128140. protected _onXRFrame(_xrFrame: XRFrame): void;
  128141. private _attachController;
  128142. private _createDefaultTargetMesh;
  128143. private _detachController;
  128144. private _findClosestSnapPointWithRadius;
  128145. private _setTargetMeshPosition;
  128146. private _setTargetMeshVisibility;
  128147. private _showParabolicPath;
  128148. private _teleportForward;
  128149. }
  128150. }
  128151. declare module BABYLON {
  128152. /**
  128153. * Options for the default xr helper
  128154. */
  128155. export class WebXRDefaultExperienceOptions {
  128156. /**
  128157. * Enable or disable default UI to enter XR
  128158. */
  128159. disableDefaultUI?: boolean;
  128160. /**
  128161. * Should teleportation not initialize. defaults to false.
  128162. */
  128163. disableTeleportation?: boolean;
  128164. /**
  128165. * Floor meshes that will be used for teleport
  128166. */
  128167. floorMeshes?: Array<AbstractMesh>;
  128168. /**
  128169. * If set to true, the first frame will not be used to reset position
  128170. * The first frame is mainly used when copying transformation from the old camera
  128171. * Mainly used in AR
  128172. */
  128173. ignoreNativeCameraTransformation?: boolean;
  128174. /**
  128175. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  128176. */
  128177. inputOptions?: IWebXRInputOptions;
  128178. /**
  128179. * optional configuration for the output canvas
  128180. */
  128181. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  128182. /**
  128183. * optional UI options. This can be used among other to change session mode and reference space type
  128184. */
  128185. uiOptions?: WebXREnterExitUIOptions;
  128186. /**
  128187. * When loading teleportation and pointer select, use stable versions instead of latest.
  128188. */
  128189. useStablePlugins?: boolean;
  128190. /**
  128191. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  128192. */
  128193. renderingGroupId?: number;
  128194. /**
  128195. * A list of optional features to init the session with
  128196. * If set to true, all features we support will be added
  128197. */
  128198. optionalFeatures?: boolean | string[];
  128199. }
  128200. /**
  128201. * Default experience which provides a similar setup to the previous webVRExperience
  128202. */
  128203. export class WebXRDefaultExperience {
  128204. /**
  128205. * Base experience
  128206. */
  128207. baseExperience: WebXRExperienceHelper;
  128208. /**
  128209. * Enables ui for entering/exiting xr
  128210. */
  128211. enterExitUI: WebXREnterExitUI;
  128212. /**
  128213. * Input experience extension
  128214. */
  128215. input: WebXRInput;
  128216. /**
  128217. * Enables laser pointer and selection
  128218. */
  128219. pointerSelection: WebXRControllerPointerSelection;
  128220. /**
  128221. * Default target xr should render to
  128222. */
  128223. renderTarget: WebXRRenderTarget;
  128224. /**
  128225. * Enables teleportation
  128226. */
  128227. teleportation: WebXRMotionControllerTeleportation;
  128228. private constructor();
  128229. /**
  128230. * Creates the default xr experience
  128231. * @param scene scene
  128232. * @param options options for basic configuration
  128233. * @returns resulting WebXRDefaultExperience
  128234. */
  128235. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128236. /**
  128237. * DIsposes of the experience helper
  128238. */
  128239. dispose(): void;
  128240. }
  128241. }
  128242. declare module BABYLON {
  128243. /**
  128244. * Options to modify the vr teleportation behavior.
  128245. */
  128246. export interface VRTeleportationOptions {
  128247. /**
  128248. * The name of the mesh which should be used as the teleportation floor. (default: null)
  128249. */
  128250. floorMeshName?: string;
  128251. /**
  128252. * A list of meshes to be used as the teleportation floor. (default: empty)
  128253. */
  128254. floorMeshes?: Mesh[];
  128255. /**
  128256. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  128257. */
  128258. teleportationMode?: number;
  128259. /**
  128260. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  128261. */
  128262. teleportationTime?: number;
  128263. /**
  128264. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  128265. */
  128266. teleportationSpeed?: number;
  128267. /**
  128268. * The easing function used in the animation or null for Linear. (default CircleEase)
  128269. */
  128270. easingFunction?: EasingFunction;
  128271. }
  128272. /**
  128273. * Options to modify the vr experience helper's behavior.
  128274. */
  128275. export interface VRExperienceHelperOptions extends WebVROptions {
  128276. /**
  128277. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  128278. */
  128279. createDeviceOrientationCamera?: boolean;
  128280. /**
  128281. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  128282. */
  128283. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  128284. /**
  128285. * Uses the main button on the controller to toggle the laser casted. (default: true)
  128286. */
  128287. laserToggle?: boolean;
  128288. /**
  128289. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  128290. */
  128291. floorMeshes?: Mesh[];
  128292. /**
  128293. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  128294. */
  128295. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  128296. /**
  128297. * Defines if WebXR should be used instead of WebVR (if available)
  128298. */
  128299. useXR?: boolean;
  128300. }
  128301. /**
  128302. * Event containing information after VR has been entered
  128303. */
  128304. export class OnAfterEnteringVRObservableEvent {
  128305. /**
  128306. * If entering vr was successful
  128307. */
  128308. success: boolean;
  128309. }
  128310. /**
  128311. * Helps to quickly add VR support to an existing scene.
  128312. * See https://doc.babylonjs.com/how_to/webvr_helper
  128313. */
  128314. export class VRExperienceHelper {
  128315. /** Options to modify the vr experience helper's behavior. */
  128316. webVROptions: VRExperienceHelperOptions;
  128317. private _scene;
  128318. private _position;
  128319. private _btnVR;
  128320. private _btnVRDisplayed;
  128321. private _webVRsupported;
  128322. private _webVRready;
  128323. private _webVRrequesting;
  128324. private _webVRpresenting;
  128325. private _hasEnteredVR;
  128326. private _fullscreenVRpresenting;
  128327. private _inputElement;
  128328. private _webVRCamera;
  128329. private _vrDeviceOrientationCamera;
  128330. private _deviceOrientationCamera;
  128331. private _existingCamera;
  128332. private _onKeyDown;
  128333. private _onVrDisplayPresentChange;
  128334. private _onVRDisplayChanged;
  128335. private _onVRRequestPresentStart;
  128336. private _onVRRequestPresentComplete;
  128337. /**
  128338. * 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)
  128339. */
  128340. enableGazeEvenWhenNoPointerLock: boolean;
  128341. /**
  128342. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  128343. */
  128344. exitVROnDoubleTap: boolean;
  128345. /**
  128346. * Observable raised right before entering VR.
  128347. */
  128348. onEnteringVRObservable: Observable<VRExperienceHelper>;
  128349. /**
  128350. * Observable raised when entering VR has completed.
  128351. */
  128352. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  128353. /**
  128354. * Observable raised when exiting VR.
  128355. */
  128356. onExitingVRObservable: Observable<VRExperienceHelper>;
  128357. /**
  128358. * Observable raised when controller mesh is loaded.
  128359. */
  128360. onControllerMeshLoadedObservable: Observable<WebVRController>;
  128361. /** Return this.onEnteringVRObservable
  128362. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  128363. */
  128364. get onEnteringVR(): Observable<VRExperienceHelper>;
  128365. /** Return this.onExitingVRObservable
  128366. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  128367. */
  128368. get onExitingVR(): Observable<VRExperienceHelper>;
  128369. /** Return this.onControllerMeshLoadedObservable
  128370. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  128371. */
  128372. get onControllerMeshLoaded(): Observable<WebVRController>;
  128373. private _rayLength;
  128374. private _useCustomVRButton;
  128375. private _teleportationRequested;
  128376. private _teleportActive;
  128377. private _floorMeshName;
  128378. private _floorMeshesCollection;
  128379. private _teleportationMode;
  128380. private _teleportationTime;
  128381. private _teleportationSpeed;
  128382. private _teleportationEasing;
  128383. private _rotationAllowed;
  128384. private _teleportBackwardsVector;
  128385. private _teleportationTarget;
  128386. private _isDefaultTeleportationTarget;
  128387. private _postProcessMove;
  128388. private _teleportationFillColor;
  128389. private _teleportationBorderColor;
  128390. private _rotationAngle;
  128391. private _haloCenter;
  128392. private _cameraGazer;
  128393. private _padSensibilityUp;
  128394. private _padSensibilityDown;
  128395. private _leftController;
  128396. private _rightController;
  128397. private _gazeColor;
  128398. private _laserColor;
  128399. private _pickedLaserColor;
  128400. private _pickedGazeColor;
  128401. /**
  128402. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128403. */
  128404. onNewMeshSelected: Observable<AbstractMesh>;
  128405. /**
  128406. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128407. * This observable will provide the mesh and the controller used to select the mesh
  128408. */
  128409. onMeshSelectedWithController: Observable<{
  128410. mesh: AbstractMesh;
  128411. controller: WebVRController;
  128412. }>;
  128413. /**
  128414. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128415. */
  128416. onNewMeshPicked: Observable<PickingInfo>;
  128417. private _circleEase;
  128418. /**
  128419. * Observable raised before camera teleportation
  128420. */
  128421. onBeforeCameraTeleport: Observable<Vector3>;
  128422. /**
  128423. * Observable raised after camera teleportation
  128424. */
  128425. onAfterCameraTeleport: Observable<Vector3>;
  128426. /**
  128427. * Observable raised when current selected mesh gets unselected
  128428. */
  128429. onSelectedMeshUnselected: Observable<AbstractMesh>;
  128430. private _raySelectionPredicate;
  128431. /**
  128432. * To be optionaly changed by user to define custom ray selection
  128433. */
  128434. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128435. /**
  128436. * To be optionaly changed by user to define custom selection logic (after ray selection)
  128437. */
  128438. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128439. /**
  128440. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  128441. */
  128442. teleportationEnabled: boolean;
  128443. private _defaultHeight;
  128444. private _teleportationInitialized;
  128445. private _interactionsEnabled;
  128446. private _interactionsRequested;
  128447. private _displayGaze;
  128448. private _displayLaserPointer;
  128449. /**
  128450. * The mesh used to display where the user is going to teleport.
  128451. */
  128452. get teleportationTarget(): Mesh;
  128453. /**
  128454. * Sets the mesh to be used to display where the user is going to teleport.
  128455. */
  128456. set teleportationTarget(value: Mesh);
  128457. /**
  128458. * 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
  128459. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  128460. * See https://doc.babylonjs.com/resources/baking_transformations
  128461. */
  128462. get gazeTrackerMesh(): Mesh;
  128463. set gazeTrackerMesh(value: Mesh);
  128464. /**
  128465. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  128466. */
  128467. updateGazeTrackerScale: boolean;
  128468. /**
  128469. * If the gaze trackers color should be updated when selecting meshes
  128470. */
  128471. updateGazeTrackerColor: boolean;
  128472. /**
  128473. * If the controller laser color should be updated when selecting meshes
  128474. */
  128475. updateControllerLaserColor: boolean;
  128476. /**
  128477. * The gaze tracking mesh corresponding to the left controller
  128478. */
  128479. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  128480. /**
  128481. * The gaze tracking mesh corresponding to the right controller
  128482. */
  128483. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  128484. /**
  128485. * If the ray of the gaze should be displayed.
  128486. */
  128487. get displayGaze(): boolean;
  128488. /**
  128489. * Sets if the ray of the gaze should be displayed.
  128490. */
  128491. set displayGaze(value: boolean);
  128492. /**
  128493. * If the ray of the LaserPointer should be displayed.
  128494. */
  128495. get displayLaserPointer(): boolean;
  128496. /**
  128497. * Sets if the ray of the LaserPointer should be displayed.
  128498. */
  128499. set displayLaserPointer(value: boolean);
  128500. /**
  128501. * The deviceOrientationCamera used as the camera when not in VR.
  128502. */
  128503. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  128504. /**
  128505. * Based on the current WebVR support, returns the current VR camera used.
  128506. */
  128507. get currentVRCamera(): Nullable<Camera>;
  128508. /**
  128509. * The webVRCamera which is used when in VR.
  128510. */
  128511. get webVRCamera(): WebVRFreeCamera;
  128512. /**
  128513. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  128514. */
  128515. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  128516. /**
  128517. * The html button that is used to trigger entering into VR.
  128518. */
  128519. get vrButton(): Nullable<HTMLButtonElement>;
  128520. private get _teleportationRequestInitiated();
  128521. /**
  128522. * Defines whether or not Pointer lock should be requested when switching to
  128523. * full screen.
  128524. */
  128525. requestPointerLockOnFullScreen: boolean;
  128526. /**
  128527. * If asking to force XR, this will be populated with the default xr experience
  128528. */
  128529. xr: WebXRDefaultExperience;
  128530. /**
  128531. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  128532. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  128533. */
  128534. xrTestDone: boolean;
  128535. /**
  128536. * Instantiates a VRExperienceHelper.
  128537. * Helps to quickly add VR support to an existing scene.
  128538. * @param scene The scene the VRExperienceHelper belongs to.
  128539. * @param webVROptions Options to modify the vr experience helper's behavior.
  128540. */
  128541. constructor(scene: Scene,
  128542. /** Options to modify the vr experience helper's behavior. */
  128543. webVROptions?: VRExperienceHelperOptions);
  128544. private completeVRInit;
  128545. private _onDefaultMeshLoaded;
  128546. private _onResize;
  128547. private _onFullscreenChange;
  128548. /**
  128549. * Gets a value indicating if we are currently in VR mode.
  128550. */
  128551. get isInVRMode(): boolean;
  128552. private onVrDisplayPresentChange;
  128553. private onVRDisplayChanged;
  128554. private moveButtonToBottomRight;
  128555. private displayVRButton;
  128556. private updateButtonVisibility;
  128557. private _cachedAngularSensibility;
  128558. /**
  128559. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  128560. * Otherwise, will use the fullscreen API.
  128561. */
  128562. enterVR(): void;
  128563. /**
  128564. * Attempt to exit VR, or fullscreen.
  128565. */
  128566. exitVR(): void;
  128567. /**
  128568. * The position of the vr experience helper.
  128569. */
  128570. get position(): Vector3;
  128571. /**
  128572. * Sets the position of the vr experience helper.
  128573. */
  128574. set position(value: Vector3);
  128575. /**
  128576. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  128577. */
  128578. enableInteractions(): void;
  128579. private get _noControllerIsActive();
  128580. private beforeRender;
  128581. private _isTeleportationFloor;
  128582. /**
  128583. * Adds a floor mesh to be used for teleportation.
  128584. * @param floorMesh the mesh to be used for teleportation.
  128585. */
  128586. addFloorMesh(floorMesh: Mesh): void;
  128587. /**
  128588. * Removes a floor mesh from being used for teleportation.
  128589. * @param floorMesh the mesh to be removed.
  128590. */
  128591. removeFloorMesh(floorMesh: Mesh): void;
  128592. /**
  128593. * Enables interactions and teleportation using the VR controllers and gaze.
  128594. * @param vrTeleportationOptions options to modify teleportation behavior.
  128595. */
  128596. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  128597. private _onNewGamepadConnected;
  128598. private _tryEnableInteractionOnController;
  128599. private _onNewGamepadDisconnected;
  128600. private _enableInteractionOnController;
  128601. private _checkTeleportWithRay;
  128602. private _checkRotate;
  128603. private _checkTeleportBackwards;
  128604. private _enableTeleportationOnController;
  128605. private _createTeleportationCircles;
  128606. private _displayTeleportationTarget;
  128607. private _hideTeleportationTarget;
  128608. private _rotateCamera;
  128609. private _moveTeleportationSelectorTo;
  128610. private _workingVector;
  128611. private _workingQuaternion;
  128612. private _workingMatrix;
  128613. /**
  128614. * Time Constant Teleportation Mode
  128615. */
  128616. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  128617. /**
  128618. * Speed Constant Teleportation Mode
  128619. */
  128620. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  128621. /**
  128622. * Teleports the users feet to the desired location
  128623. * @param location The location where the user's feet should be placed
  128624. */
  128625. teleportCamera(location: Vector3): void;
  128626. private _convertNormalToDirectionOfRay;
  128627. private _castRayAndSelectObject;
  128628. private _notifySelectedMeshUnselected;
  128629. /**
  128630. * Permanently set new colors for the laser pointer
  128631. * @param color the new laser color
  128632. * @param pickedColor the new laser color when picked mesh detected
  128633. */
  128634. setLaserColor(color: Color3, pickedColor?: Color3): void;
  128635. /**
  128636. * Set lighting enabled / disabled on the laser pointer of both controllers
  128637. * @param enabled should the lighting be enabled on the laser pointer
  128638. */
  128639. setLaserLightingState(enabled?: boolean): void;
  128640. /**
  128641. * Permanently set new colors for the gaze pointer
  128642. * @param color the new gaze color
  128643. * @param pickedColor the new gaze color when picked mesh detected
  128644. */
  128645. setGazeColor(color: Color3, pickedColor?: Color3): void;
  128646. /**
  128647. * Sets the color of the laser ray from the vr controllers.
  128648. * @param color new color for the ray.
  128649. */
  128650. changeLaserColor(color: Color3): void;
  128651. /**
  128652. * Sets the color of the ray from the vr headsets gaze.
  128653. * @param color new color for the ray.
  128654. */
  128655. changeGazeColor(color: Color3): void;
  128656. /**
  128657. * Exits VR and disposes of the vr experience helper
  128658. */
  128659. dispose(): void;
  128660. /**
  128661. * Gets the name of the VRExperienceHelper class
  128662. * @returns "VRExperienceHelper"
  128663. */
  128664. getClassName(): string;
  128665. }
  128666. }
  128667. declare module BABYLON {
  128668. /**
  128669. * Contains an array of blocks representing the octree
  128670. */
  128671. export interface IOctreeContainer<T> {
  128672. /**
  128673. * Blocks within the octree
  128674. */
  128675. blocks: Array<OctreeBlock<T>>;
  128676. }
  128677. /**
  128678. * Class used to store a cell in an octree
  128679. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128680. */
  128681. export class OctreeBlock<T> {
  128682. /**
  128683. * Gets the content of the current block
  128684. */
  128685. entries: T[];
  128686. /**
  128687. * Gets the list of block children
  128688. */
  128689. blocks: Array<OctreeBlock<T>>;
  128690. private _depth;
  128691. private _maxDepth;
  128692. private _capacity;
  128693. private _minPoint;
  128694. private _maxPoint;
  128695. private _boundingVectors;
  128696. private _creationFunc;
  128697. /**
  128698. * Creates a new block
  128699. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  128700. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  128701. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128702. * @param depth defines the current depth of this block in the octree
  128703. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  128704. * @param creationFunc defines a callback to call when an element is added to the block
  128705. */
  128706. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  128707. /**
  128708. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128709. */
  128710. get capacity(): number;
  128711. /**
  128712. * Gets the minimum vector (in world space) of the block's bounding box
  128713. */
  128714. get minPoint(): Vector3;
  128715. /**
  128716. * Gets the maximum vector (in world space) of the block's bounding box
  128717. */
  128718. get maxPoint(): Vector3;
  128719. /**
  128720. * Add a new element to this block
  128721. * @param entry defines the element to add
  128722. */
  128723. addEntry(entry: T): void;
  128724. /**
  128725. * Remove an element from this block
  128726. * @param entry defines the element to remove
  128727. */
  128728. removeEntry(entry: T): void;
  128729. /**
  128730. * Add an array of elements to this block
  128731. * @param entries defines the array of elements to add
  128732. */
  128733. addEntries(entries: T[]): void;
  128734. /**
  128735. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  128736. * @param frustumPlanes defines the frustum planes to test
  128737. * @param selection defines the array to store current content if selection is positive
  128738. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128739. */
  128740. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128741. /**
  128742. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  128743. * @param sphereCenter defines the bounding sphere center
  128744. * @param sphereRadius defines the bounding sphere radius
  128745. * @param selection defines the array to store current content if selection is positive
  128746. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128747. */
  128748. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128749. /**
  128750. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  128751. * @param ray defines the ray to test with
  128752. * @param selection defines the array to store current content if selection is positive
  128753. */
  128754. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  128755. /**
  128756. * Subdivide the content into child blocks (this block will then be empty)
  128757. */
  128758. createInnerBlocks(): void;
  128759. /**
  128760. * @hidden
  128761. */
  128762. 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;
  128763. }
  128764. }
  128765. declare module BABYLON {
  128766. /**
  128767. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  128768. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128769. */
  128770. export class Octree<T> {
  128771. /** 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.) */
  128772. maxDepth: number;
  128773. /**
  128774. * Blocks within the octree containing objects
  128775. */
  128776. blocks: Array<OctreeBlock<T>>;
  128777. /**
  128778. * Content stored in the octree
  128779. */
  128780. dynamicContent: T[];
  128781. private _maxBlockCapacity;
  128782. private _selectionContent;
  128783. private _creationFunc;
  128784. /**
  128785. * Creates a octree
  128786. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128787. * @param creationFunc function to be used to instatiate the octree
  128788. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  128789. * @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.)
  128790. */
  128791. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  128792. /** 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.) */
  128793. maxDepth?: number);
  128794. /**
  128795. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  128796. * @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);
  128797. * @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);
  128798. * @param entries meshes to be added to the octree blocks
  128799. */
  128800. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  128801. /**
  128802. * Adds a mesh to the octree
  128803. * @param entry Mesh to add to the octree
  128804. */
  128805. addMesh(entry: T): void;
  128806. /**
  128807. * Remove an element from the octree
  128808. * @param entry defines the element to remove
  128809. */
  128810. removeMesh(entry: T): void;
  128811. /**
  128812. * Selects an array of meshes within the frustum
  128813. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  128814. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  128815. * @returns array of meshes within the frustum
  128816. */
  128817. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  128818. /**
  128819. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  128820. * @param sphereCenter defines the bounding sphere center
  128821. * @param sphereRadius defines the bounding sphere radius
  128822. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128823. * @returns an array of objects that intersect the sphere
  128824. */
  128825. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  128826. /**
  128827. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  128828. * @param ray defines the ray to test with
  128829. * @returns array of intersected objects
  128830. */
  128831. intersectsRay(ray: Ray): SmartArray<T>;
  128832. /**
  128833. * Adds a mesh into the octree block if it intersects the block
  128834. */
  128835. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  128836. /**
  128837. * Adds a submesh into the octree block if it intersects the block
  128838. */
  128839. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  128840. }
  128841. }
  128842. declare module BABYLON {
  128843. interface Scene {
  128844. /**
  128845. * @hidden
  128846. * Backing Filed
  128847. */
  128848. _selectionOctree: Octree<AbstractMesh>;
  128849. /**
  128850. * Gets the octree used to boost mesh selection (picking)
  128851. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128852. */
  128853. selectionOctree: Octree<AbstractMesh>;
  128854. /**
  128855. * Creates or updates the octree used to boost selection (picking)
  128856. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128857. * @param maxCapacity defines the maximum capacity per leaf
  128858. * @param maxDepth defines the maximum depth of the octree
  128859. * @returns an octree of AbstractMesh
  128860. */
  128861. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  128862. }
  128863. interface AbstractMesh {
  128864. /**
  128865. * @hidden
  128866. * Backing Field
  128867. */
  128868. _submeshesOctree: Octree<SubMesh>;
  128869. /**
  128870. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  128871. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  128872. * @param maxCapacity defines the maximum size of each block (64 by default)
  128873. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  128874. * @returns the new octree
  128875. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  128876. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128877. */
  128878. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  128879. }
  128880. /**
  128881. * Defines the octree scene component responsible to manage any octrees
  128882. * in a given scene.
  128883. */
  128884. export class OctreeSceneComponent {
  128885. /**
  128886. * The component name help to identify the component in the list of scene components.
  128887. */
  128888. readonly name: string;
  128889. /**
  128890. * The scene the component belongs to.
  128891. */
  128892. scene: Scene;
  128893. /**
  128894. * Indicates if the meshes have been checked to make sure they are isEnabled()
  128895. */
  128896. readonly checksIsEnabled: boolean;
  128897. /**
  128898. * Creates a new instance of the component for the given scene
  128899. * @param scene Defines the scene to register the component in
  128900. */
  128901. constructor(scene: Scene);
  128902. /**
  128903. * Registers the component in a given scene
  128904. */
  128905. register(): void;
  128906. /**
  128907. * Return the list of active meshes
  128908. * @returns the list of active meshes
  128909. */
  128910. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  128911. /**
  128912. * Return the list of active sub meshes
  128913. * @param mesh The mesh to get the candidates sub meshes from
  128914. * @returns the list of active sub meshes
  128915. */
  128916. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  128917. private _tempRay;
  128918. /**
  128919. * Return the list of sub meshes intersecting with a given local ray
  128920. * @param mesh defines the mesh to find the submesh for
  128921. * @param localRay defines the ray in local space
  128922. * @returns the list of intersecting sub meshes
  128923. */
  128924. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  128925. /**
  128926. * Return the list of sub meshes colliding with a collider
  128927. * @param mesh defines the mesh to find the submesh for
  128928. * @param collider defines the collider to evaluate the collision against
  128929. * @returns the list of colliding sub meshes
  128930. */
  128931. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  128932. /**
  128933. * Rebuilds the elements related to this component in case of
  128934. * context lost for instance.
  128935. */
  128936. rebuild(): void;
  128937. /**
  128938. * Disposes the component and the associated ressources.
  128939. */
  128940. dispose(): void;
  128941. }
  128942. }
  128943. declare module BABYLON {
  128944. /**
  128945. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  128946. */
  128947. export class Gizmo implements IDisposable {
  128948. /** The utility layer the gizmo will be added to */
  128949. gizmoLayer: UtilityLayerRenderer;
  128950. /**
  128951. * The root mesh of the gizmo
  128952. */
  128953. _rootMesh: Mesh;
  128954. private _attachedMesh;
  128955. private _attachedNode;
  128956. /**
  128957. * Ratio for the scale of the gizmo (Default: 1)
  128958. */
  128959. scaleRatio: number;
  128960. /**
  128961. * If a custom mesh has been set (Default: false)
  128962. */
  128963. protected _customMeshSet: boolean;
  128964. /**
  128965. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  128966. * * When set, interactions will be enabled
  128967. */
  128968. get attachedMesh(): Nullable<AbstractMesh>;
  128969. set attachedMesh(value: Nullable<AbstractMesh>);
  128970. /**
  128971. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  128972. * * When set, interactions will be enabled
  128973. */
  128974. get attachedNode(): Nullable<Node>;
  128975. set attachedNode(value: Nullable<Node>);
  128976. /**
  128977. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  128978. * @param mesh The mesh to replace the default mesh of the gizmo
  128979. */
  128980. setCustomMesh(mesh: Mesh): void;
  128981. /**
  128982. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  128983. */
  128984. updateGizmoRotationToMatchAttachedMesh: boolean;
  128985. /**
  128986. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  128987. */
  128988. updateGizmoPositionToMatchAttachedMesh: boolean;
  128989. /**
  128990. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  128991. */
  128992. updateScale: boolean;
  128993. protected _interactionsEnabled: boolean;
  128994. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128995. private _beforeRenderObserver;
  128996. private _tempQuaternion;
  128997. private _tempVector;
  128998. private _tempVector2;
  128999. /**
  129000. * Creates a gizmo
  129001. * @param gizmoLayer The utility layer the gizmo will be added to
  129002. */
  129003. constructor(
  129004. /** The utility layer the gizmo will be added to */
  129005. gizmoLayer?: UtilityLayerRenderer);
  129006. /**
  129007. * Updates the gizmo to match the attached mesh's position/rotation
  129008. */
  129009. protected _update(): void;
  129010. /**
  129011. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  129012. * @param value Node, TransformNode or mesh
  129013. */
  129014. protected _matrixChanged(): void;
  129015. /**
  129016. * Disposes of the gizmo
  129017. */
  129018. dispose(): void;
  129019. }
  129020. }
  129021. declare module BABYLON {
  129022. /**
  129023. * Single plane drag gizmo
  129024. */
  129025. export class PlaneDragGizmo extends Gizmo {
  129026. /**
  129027. * Drag behavior responsible for the gizmos dragging interactions
  129028. */
  129029. dragBehavior: PointerDragBehavior;
  129030. private _pointerObserver;
  129031. /**
  129032. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129033. */
  129034. snapDistance: number;
  129035. /**
  129036. * Event that fires each time the gizmo snaps to a new location.
  129037. * * snapDistance is the the change in distance
  129038. */
  129039. onSnapObservable: Observable<{
  129040. snapDistance: number;
  129041. }>;
  129042. private _plane;
  129043. private _coloredMaterial;
  129044. private _hoverMaterial;
  129045. private _isEnabled;
  129046. private _parent;
  129047. /** @hidden */
  129048. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  129049. /** @hidden */
  129050. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129051. /**
  129052. * Creates a PlaneDragGizmo
  129053. * @param gizmoLayer The utility layer the gizmo will be added to
  129054. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  129055. * @param color The color of the gizmo
  129056. */
  129057. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  129058. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129059. /**
  129060. * If the gizmo is enabled
  129061. */
  129062. set isEnabled(value: boolean);
  129063. get isEnabled(): boolean;
  129064. /**
  129065. * Disposes of the gizmo
  129066. */
  129067. dispose(): void;
  129068. }
  129069. }
  129070. declare module BABYLON {
  129071. /**
  129072. * Gizmo that enables dragging a mesh along 3 axis
  129073. */
  129074. export class PositionGizmo extends Gizmo {
  129075. /**
  129076. * Internal gizmo used for interactions on the x axis
  129077. */
  129078. xGizmo: AxisDragGizmo;
  129079. /**
  129080. * Internal gizmo used for interactions on the y axis
  129081. */
  129082. yGizmo: AxisDragGizmo;
  129083. /**
  129084. * Internal gizmo used for interactions on the z axis
  129085. */
  129086. zGizmo: AxisDragGizmo;
  129087. /**
  129088. * Internal gizmo used for interactions on the yz plane
  129089. */
  129090. xPlaneGizmo: PlaneDragGizmo;
  129091. /**
  129092. * Internal gizmo used for interactions on the xz plane
  129093. */
  129094. yPlaneGizmo: PlaneDragGizmo;
  129095. /**
  129096. * Internal gizmo used for interactions on the xy plane
  129097. */
  129098. zPlaneGizmo: PlaneDragGizmo;
  129099. /**
  129100. * private variables
  129101. */
  129102. private _meshAttached;
  129103. private _nodeAttached;
  129104. private _updateGizmoRotationToMatchAttachedMesh;
  129105. private _snapDistance;
  129106. private _scaleRatio;
  129107. /** Fires an event when any of it's sub gizmos are dragged */
  129108. onDragStartObservable: Observable<unknown>;
  129109. /** Fires an event when any of it's sub gizmos are released from dragging */
  129110. onDragEndObservable: Observable<unknown>;
  129111. /**
  129112. * If set to true, planar drag is enabled
  129113. */
  129114. private _planarGizmoEnabled;
  129115. get attachedMesh(): Nullable<AbstractMesh>;
  129116. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129117. get attachedNode(): Nullable<Node>;
  129118. set attachedNode(node: Nullable<Node>);
  129119. /**
  129120. * Creates a PositionGizmo
  129121. * @param gizmoLayer The utility layer the gizmo will be added to
  129122. @param thickness display gizmo axis thickness
  129123. */
  129124. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  129125. /**
  129126. * If the planar drag gizmo is enabled
  129127. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  129128. */
  129129. set planarGizmoEnabled(value: boolean);
  129130. get planarGizmoEnabled(): boolean;
  129131. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129132. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129133. /**
  129134. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129135. */
  129136. set snapDistance(value: number);
  129137. get snapDistance(): number;
  129138. /**
  129139. * Ratio for the scale of the gizmo (Default: 1)
  129140. */
  129141. set scaleRatio(value: number);
  129142. get scaleRatio(): number;
  129143. /**
  129144. * Disposes of the gizmo
  129145. */
  129146. dispose(): void;
  129147. /**
  129148. * CustomMeshes are not supported by this gizmo
  129149. * @param mesh The mesh to replace the default mesh of the gizmo
  129150. */
  129151. setCustomMesh(mesh: Mesh): void;
  129152. }
  129153. }
  129154. declare module BABYLON {
  129155. /**
  129156. * Single axis drag gizmo
  129157. */
  129158. export class AxisDragGizmo extends Gizmo {
  129159. /**
  129160. * Drag behavior responsible for the gizmos dragging interactions
  129161. */
  129162. dragBehavior: PointerDragBehavior;
  129163. private _pointerObserver;
  129164. /**
  129165. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129166. */
  129167. snapDistance: number;
  129168. /**
  129169. * Event that fires each time the gizmo snaps to a new location.
  129170. * * snapDistance is the the change in distance
  129171. */
  129172. onSnapObservable: Observable<{
  129173. snapDistance: number;
  129174. }>;
  129175. private _isEnabled;
  129176. private _parent;
  129177. private _arrow;
  129178. private _coloredMaterial;
  129179. private _hoverMaterial;
  129180. /** @hidden */
  129181. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  129182. /** @hidden */
  129183. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129184. /**
  129185. * Creates an AxisDragGizmo
  129186. * @param gizmoLayer The utility layer the gizmo will be added to
  129187. * @param dragAxis The axis which the gizmo will be able to drag on
  129188. * @param color The color of the gizmo
  129189. * @param thickness display gizmo axis thickness
  129190. */
  129191. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  129192. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129193. /**
  129194. * If the gizmo is enabled
  129195. */
  129196. set isEnabled(value: boolean);
  129197. get isEnabled(): boolean;
  129198. /**
  129199. * Disposes of the gizmo
  129200. */
  129201. dispose(): void;
  129202. }
  129203. }
  129204. declare module BABYLON.Debug {
  129205. /**
  129206. * The Axes viewer will show 3 axes in a specific point in space
  129207. */
  129208. export class AxesViewer {
  129209. private _xAxis;
  129210. private _yAxis;
  129211. private _zAxis;
  129212. private _scaleLinesFactor;
  129213. private _instanced;
  129214. /**
  129215. * Gets the hosting scene
  129216. */
  129217. scene: Scene;
  129218. /**
  129219. * Gets or sets a number used to scale line length
  129220. */
  129221. scaleLines: number;
  129222. /** Gets the node hierarchy used to render x-axis */
  129223. get xAxis(): TransformNode;
  129224. /** Gets the node hierarchy used to render y-axis */
  129225. get yAxis(): TransformNode;
  129226. /** Gets the node hierarchy used to render z-axis */
  129227. get zAxis(): TransformNode;
  129228. /**
  129229. * Creates a new AxesViewer
  129230. * @param scene defines the hosting scene
  129231. * @param scaleLines defines a number used to scale line length (1 by default)
  129232. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  129233. * @param xAxis defines the node hierarchy used to render the x-axis
  129234. * @param yAxis defines the node hierarchy used to render the y-axis
  129235. * @param zAxis defines the node hierarchy used to render the z-axis
  129236. */
  129237. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  129238. /**
  129239. * Force the viewer to update
  129240. * @param position defines the position of the viewer
  129241. * @param xaxis defines the x axis of the viewer
  129242. * @param yaxis defines the y axis of the viewer
  129243. * @param zaxis defines the z axis of the viewer
  129244. */
  129245. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  129246. /**
  129247. * Creates an instance of this axes viewer.
  129248. * @returns a new axes viewer with instanced meshes
  129249. */
  129250. createInstance(): AxesViewer;
  129251. /** Releases resources */
  129252. dispose(): void;
  129253. private static _SetRenderingGroupId;
  129254. }
  129255. }
  129256. declare module BABYLON.Debug {
  129257. /**
  129258. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  129259. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  129260. */
  129261. export class BoneAxesViewer extends AxesViewer {
  129262. /**
  129263. * Gets or sets the target mesh where to display the axes viewer
  129264. */
  129265. mesh: Nullable<Mesh>;
  129266. /**
  129267. * Gets or sets the target bone where to display the axes viewer
  129268. */
  129269. bone: Nullable<Bone>;
  129270. /** Gets current position */
  129271. pos: Vector3;
  129272. /** Gets direction of X axis */
  129273. xaxis: Vector3;
  129274. /** Gets direction of Y axis */
  129275. yaxis: Vector3;
  129276. /** Gets direction of Z axis */
  129277. zaxis: Vector3;
  129278. /**
  129279. * Creates a new BoneAxesViewer
  129280. * @param scene defines the hosting scene
  129281. * @param bone defines the target bone
  129282. * @param mesh defines the target mesh
  129283. * @param scaleLines defines a scaling factor for line length (1 by default)
  129284. */
  129285. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  129286. /**
  129287. * Force the viewer to update
  129288. */
  129289. update(): void;
  129290. /** Releases resources */
  129291. dispose(): void;
  129292. }
  129293. }
  129294. declare module BABYLON {
  129295. /**
  129296. * Interface used to define scene explorer extensibility option
  129297. */
  129298. export interface IExplorerExtensibilityOption {
  129299. /**
  129300. * Define the option label
  129301. */
  129302. label: string;
  129303. /**
  129304. * Defines the action to execute on click
  129305. */
  129306. action: (entity: any) => void;
  129307. }
  129308. /**
  129309. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  129310. */
  129311. export interface IExplorerExtensibilityGroup {
  129312. /**
  129313. * Defines a predicate to test if a given type mut be extended
  129314. */
  129315. predicate: (entity: any) => boolean;
  129316. /**
  129317. * Gets the list of options added to a type
  129318. */
  129319. entries: IExplorerExtensibilityOption[];
  129320. }
  129321. /**
  129322. * Interface used to define the options to use to create the Inspector
  129323. */
  129324. export interface IInspectorOptions {
  129325. /**
  129326. * Display in overlay mode (default: false)
  129327. */
  129328. overlay?: boolean;
  129329. /**
  129330. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  129331. */
  129332. globalRoot?: HTMLElement;
  129333. /**
  129334. * Display the Scene explorer
  129335. */
  129336. showExplorer?: boolean;
  129337. /**
  129338. * Display the property inspector
  129339. */
  129340. showInspector?: boolean;
  129341. /**
  129342. * Display in embed mode (both panes on the right)
  129343. */
  129344. embedMode?: boolean;
  129345. /**
  129346. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  129347. */
  129348. handleResize?: boolean;
  129349. /**
  129350. * Allow the panes to popup (default: true)
  129351. */
  129352. enablePopup?: boolean;
  129353. /**
  129354. * Allow the panes to be closed by users (default: true)
  129355. */
  129356. enableClose?: boolean;
  129357. /**
  129358. * Optional list of extensibility entries
  129359. */
  129360. explorerExtensibility?: IExplorerExtensibilityGroup[];
  129361. /**
  129362. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  129363. */
  129364. inspectorURL?: string;
  129365. /**
  129366. * Optional initial tab (default to DebugLayerTab.Properties)
  129367. */
  129368. initialTab?: DebugLayerTab;
  129369. }
  129370. interface Scene {
  129371. /**
  129372. * @hidden
  129373. * Backing field
  129374. */
  129375. _debugLayer: DebugLayer;
  129376. /**
  129377. * Gets the debug layer (aka Inspector) associated with the scene
  129378. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129379. */
  129380. debugLayer: DebugLayer;
  129381. }
  129382. /**
  129383. * Enum of inspector action tab
  129384. */
  129385. export enum DebugLayerTab {
  129386. /**
  129387. * Properties tag (default)
  129388. */
  129389. Properties = 0,
  129390. /**
  129391. * Debug tab
  129392. */
  129393. Debug = 1,
  129394. /**
  129395. * Statistics tab
  129396. */
  129397. Statistics = 2,
  129398. /**
  129399. * Tools tab
  129400. */
  129401. Tools = 3,
  129402. /**
  129403. * Settings tab
  129404. */
  129405. Settings = 4
  129406. }
  129407. /**
  129408. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129409. * what is happening in your scene
  129410. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129411. */
  129412. export class DebugLayer {
  129413. /**
  129414. * Define the url to get the inspector script from.
  129415. * By default it uses the babylonjs CDN.
  129416. * @ignoreNaming
  129417. */
  129418. static InspectorURL: string;
  129419. private _scene;
  129420. private BJSINSPECTOR;
  129421. private _onPropertyChangedObservable?;
  129422. /**
  129423. * Observable triggered when a property is changed through the inspector.
  129424. */
  129425. get onPropertyChangedObservable(): any;
  129426. /**
  129427. * Instantiates a new debug layer.
  129428. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129429. * what is happening in your scene
  129430. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129431. * @param scene Defines the scene to inspect
  129432. */
  129433. constructor(scene: Scene);
  129434. /** Creates the inspector window. */
  129435. private _createInspector;
  129436. /**
  129437. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  129438. * @param entity defines the entity to select
  129439. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  129440. */
  129441. select(entity: any, lineContainerTitles?: string | string[]): void;
  129442. /** Get the inspector from bundle or global */
  129443. private _getGlobalInspector;
  129444. /**
  129445. * Get if the inspector is visible or not.
  129446. * @returns true if visible otherwise, false
  129447. */
  129448. isVisible(): boolean;
  129449. /**
  129450. * Hide the inspector and close its window.
  129451. */
  129452. hide(): void;
  129453. /**
  129454. * Update the scene in the inspector
  129455. */
  129456. setAsActiveScene(): void;
  129457. /**
  129458. * Launch the debugLayer.
  129459. * @param config Define the configuration of the inspector
  129460. * @return a promise fulfilled when the debug layer is visible
  129461. */
  129462. show(config?: IInspectorOptions): Promise<DebugLayer>;
  129463. }
  129464. }
  129465. declare module BABYLON {
  129466. /**
  129467. * Class containing static functions to help procedurally build meshes
  129468. */
  129469. export class BoxBuilder {
  129470. /**
  129471. * Creates a box mesh
  129472. * * The parameter `size` sets the size (float) of each box side (default 1)
  129473. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129474. * * 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)
  129475. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129479. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129480. * @param name defines the name of the mesh
  129481. * @param options defines the options used to create the mesh
  129482. * @param scene defines the hosting scene
  129483. * @returns the box mesh
  129484. */
  129485. static CreateBox(name: string, options: {
  129486. size?: number;
  129487. width?: number;
  129488. height?: number;
  129489. depth?: number;
  129490. faceUV?: Vector4[];
  129491. faceColors?: Color4[];
  129492. sideOrientation?: number;
  129493. frontUVs?: Vector4;
  129494. backUVs?: Vector4;
  129495. wrap?: boolean;
  129496. topBaseAt?: number;
  129497. bottomBaseAt?: number;
  129498. updatable?: boolean;
  129499. }, scene?: Nullable<Scene>): Mesh;
  129500. }
  129501. }
  129502. declare module BABYLON.Debug {
  129503. /**
  129504. * Used to show the physics impostor around the specific mesh
  129505. */
  129506. export class PhysicsViewer {
  129507. /** @hidden */
  129508. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  129509. /** @hidden */
  129510. protected _meshes: Array<Nullable<AbstractMesh>>;
  129511. /** @hidden */
  129512. protected _scene: Nullable<Scene>;
  129513. /** @hidden */
  129514. protected _numMeshes: number;
  129515. /** @hidden */
  129516. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  129517. private _renderFunction;
  129518. private _utilityLayer;
  129519. private _debugBoxMesh;
  129520. private _debugSphereMesh;
  129521. private _debugCylinderMesh;
  129522. private _debugMaterial;
  129523. private _debugMeshMeshes;
  129524. /**
  129525. * Creates a new PhysicsViewer
  129526. * @param scene defines the hosting scene
  129527. */
  129528. constructor(scene: Scene);
  129529. /** @hidden */
  129530. protected _updateDebugMeshes(): void;
  129531. /**
  129532. * Renders a specified physic impostor
  129533. * @param impostor defines the impostor to render
  129534. * @param targetMesh defines the mesh represented by the impostor
  129535. * @returns the new debug mesh used to render the impostor
  129536. */
  129537. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  129538. /**
  129539. * Hides a specified physic impostor
  129540. * @param impostor defines the impostor to hide
  129541. */
  129542. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  129543. private _getDebugMaterial;
  129544. private _getDebugBoxMesh;
  129545. private _getDebugSphereMesh;
  129546. private _getDebugCylinderMesh;
  129547. private _getDebugMeshMesh;
  129548. private _getDebugMesh;
  129549. /** Releases all resources */
  129550. dispose(): void;
  129551. }
  129552. }
  129553. declare module BABYLON {
  129554. /**
  129555. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129556. * in order to better appreciate the issue one might have.
  129557. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129558. */
  129559. export class RayHelper {
  129560. /**
  129561. * Defines the ray we are currently tryin to visualize.
  129562. */
  129563. ray: Nullable<Ray>;
  129564. private _renderPoints;
  129565. private _renderLine;
  129566. private _renderFunction;
  129567. private _scene;
  129568. private _updateToMeshFunction;
  129569. private _attachedToMesh;
  129570. private _meshSpaceDirection;
  129571. private _meshSpaceOrigin;
  129572. /**
  129573. * Helper function to create a colored helper in a scene in one line.
  129574. * @param ray Defines the ray we are currently tryin to visualize
  129575. * @param scene Defines the scene the ray is used in
  129576. * @param color Defines the color we want to see the ray in
  129577. * @returns The newly created ray helper.
  129578. */
  129579. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  129580. /**
  129581. * Instantiate a new ray helper.
  129582. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129583. * in order to better appreciate the issue one might have.
  129584. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129585. * @param ray Defines the ray we are currently tryin to visualize
  129586. */
  129587. constructor(ray: Ray);
  129588. /**
  129589. * Shows the ray we are willing to debug.
  129590. * @param scene Defines the scene the ray needs to be rendered in
  129591. * @param color Defines the color the ray needs to be rendered in
  129592. */
  129593. show(scene: Scene, color?: Color3): void;
  129594. /**
  129595. * Hides the ray we are debugging.
  129596. */
  129597. hide(): void;
  129598. private _render;
  129599. /**
  129600. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  129601. * @param mesh Defines the mesh we want the helper attached to
  129602. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  129603. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  129604. * @param length Defines the length of the ray
  129605. */
  129606. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  129607. /**
  129608. * Detach the ray helper from the mesh it has previously been attached to.
  129609. */
  129610. detachFromMesh(): void;
  129611. private _updateToMesh;
  129612. /**
  129613. * Dispose the helper and release its associated resources.
  129614. */
  129615. dispose(): void;
  129616. }
  129617. }
  129618. declare module BABYLON {
  129619. /**
  129620. * Defines the options associated with the creation of a SkeletonViewer.
  129621. */
  129622. export interface ISkeletonViewerOptions {
  129623. /** Should the system pause animations before building the Viewer? */
  129624. pauseAnimations: boolean;
  129625. /** Should the system return the skeleton to rest before building? */
  129626. returnToRest: boolean;
  129627. /** public Display Mode of the Viewer */
  129628. displayMode: number;
  129629. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129630. displayOptions: ISkeletonViewerDisplayOptions;
  129631. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129632. computeBonesUsingShaders: boolean;
  129633. }
  129634. /**
  129635. * Defines how to display the various bone meshes for the viewer.
  129636. */
  129637. export interface ISkeletonViewerDisplayOptions {
  129638. /** How far down to start tapering the bone spurs */
  129639. midStep?: number;
  129640. /** How big is the midStep? */
  129641. midStepFactor?: number;
  129642. /** Base for the Sphere Size */
  129643. sphereBaseSize?: number;
  129644. /** The ratio of the sphere to the longest bone in units */
  129645. sphereScaleUnit?: number;
  129646. /** Ratio for the Sphere Size */
  129647. sphereFactor?: number;
  129648. }
  129649. }
  129650. declare module BABYLON {
  129651. /**
  129652. * Class containing static functions to help procedurally build meshes
  129653. */
  129654. export class RibbonBuilder {
  129655. /**
  129656. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129657. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129658. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129659. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129660. * * 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
  129661. * * 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
  129662. * * 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
  129663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129665. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129666. * * 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
  129667. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129668. * * 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
  129669. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129671. * @param name defines the name of the mesh
  129672. * @param options defines the options used to create the mesh
  129673. * @param scene defines the hosting scene
  129674. * @returns the ribbon mesh
  129675. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129677. */
  129678. static CreateRibbon(name: string, options: {
  129679. pathArray: Vector3[][];
  129680. closeArray?: boolean;
  129681. closePath?: boolean;
  129682. offset?: number;
  129683. updatable?: boolean;
  129684. sideOrientation?: number;
  129685. frontUVs?: Vector4;
  129686. backUVs?: Vector4;
  129687. instance?: Mesh;
  129688. invertUV?: boolean;
  129689. uvs?: Vector2[];
  129690. colors?: Color4[];
  129691. }, scene?: Nullable<Scene>): Mesh;
  129692. }
  129693. }
  129694. declare module BABYLON {
  129695. /**
  129696. * Class containing static functions to help procedurally build meshes
  129697. */
  129698. export class ShapeBuilder {
  129699. /**
  129700. * 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.
  129701. * * 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.
  129702. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129703. * * 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.
  129704. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129705. * * 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
  129706. * * 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
  129707. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129710. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129712. * @param name defines the name of the mesh
  129713. * @param options defines the options used to create the mesh
  129714. * @param scene defines the hosting scene
  129715. * @returns the extruded shape mesh
  129716. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129718. */
  129719. static ExtrudeShape(name: string, options: {
  129720. shape: Vector3[];
  129721. path: Vector3[];
  129722. scale?: number;
  129723. rotation?: number;
  129724. cap?: number;
  129725. updatable?: boolean;
  129726. sideOrientation?: number;
  129727. frontUVs?: Vector4;
  129728. backUVs?: Vector4;
  129729. instance?: Mesh;
  129730. invertUV?: boolean;
  129731. }, scene?: Nullable<Scene>): Mesh;
  129732. /**
  129733. * Creates an custom extruded shape mesh.
  129734. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129735. * * 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.
  129736. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129737. * * 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
  129738. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129739. * * 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
  129740. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129741. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129742. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129743. * * 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
  129744. * * 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
  129745. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129748. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129750. * @param name defines the name of the mesh
  129751. * @param options defines the options used to create the mesh
  129752. * @param scene defines the hosting scene
  129753. * @returns the custom extruded shape mesh
  129754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129755. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129757. */
  129758. static ExtrudeShapeCustom(name: string, options: {
  129759. shape: Vector3[];
  129760. path: Vector3[];
  129761. scaleFunction?: any;
  129762. rotationFunction?: any;
  129763. ribbonCloseArray?: boolean;
  129764. ribbonClosePath?: boolean;
  129765. cap?: number;
  129766. updatable?: boolean;
  129767. sideOrientation?: number;
  129768. frontUVs?: Vector4;
  129769. backUVs?: Vector4;
  129770. instance?: Mesh;
  129771. invertUV?: boolean;
  129772. }, scene?: Nullable<Scene>): Mesh;
  129773. private static _ExtrudeShapeGeneric;
  129774. }
  129775. }
  129776. declare module BABYLON.Debug {
  129777. /**
  129778. * Class used to render a debug view of a given skeleton
  129779. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  129780. */
  129781. export class SkeletonViewer {
  129782. /** defines the skeleton to render */
  129783. skeleton: Skeleton;
  129784. /** defines the mesh attached to the skeleton */
  129785. mesh: AbstractMesh;
  129786. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129787. autoUpdateBonesMatrices: boolean;
  129788. /** defines the rendering group id to use with the viewer */
  129789. renderingGroupId: number;
  129790. /** is the options for the viewer */
  129791. options: Partial<ISkeletonViewerOptions>;
  129792. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  129793. static readonly DISPLAY_LINES: number;
  129794. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  129795. static readonly DISPLAY_SPHERES: number;
  129796. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  129797. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  129798. /** If SkeletonViewer scene scope. */
  129799. private _scene;
  129800. /** Gets or sets the color used to render the skeleton */
  129801. color: Color3;
  129802. /** Array of the points of the skeleton fo the line view. */
  129803. private _debugLines;
  129804. /** The SkeletonViewers Mesh. */
  129805. private _debugMesh;
  129806. /** If SkeletonViewer is enabled. */
  129807. private _isEnabled;
  129808. /** If SkeletonViewer is ready. */
  129809. private _ready;
  129810. /** SkeletonViewer render observable. */
  129811. private _obs;
  129812. /** The Utility Layer to render the gizmos in. */
  129813. private _utilityLayer;
  129814. /** Gets the Scene. */
  129815. get scene(): Scene;
  129816. /** Gets the utilityLayer. */
  129817. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  129818. /** Checks Ready Status. */
  129819. get isReady(): Boolean;
  129820. /** Sets Ready Status. */
  129821. set ready(value: boolean);
  129822. /** Gets the debugMesh */
  129823. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  129824. /** Sets the debugMesh */
  129825. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  129826. /** Gets the material */
  129827. get material(): StandardMaterial;
  129828. /** Sets the material */
  129829. set material(value: StandardMaterial);
  129830. /**
  129831. * Creates a new SkeletonViewer
  129832. * @param skeleton defines the skeleton to render
  129833. * @param mesh defines the mesh attached to the skeleton
  129834. * @param scene defines the hosting scene
  129835. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  129836. * @param renderingGroupId defines the rendering group id to use with the viewer
  129837. * @param options All of the extra constructor options for the SkeletonViewer
  129838. */
  129839. constructor(
  129840. /** defines the skeleton to render */
  129841. skeleton: Skeleton,
  129842. /** defines the mesh attached to the skeleton */
  129843. mesh: AbstractMesh,
  129844. /** The Scene scope*/
  129845. scene: Scene,
  129846. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129847. autoUpdateBonesMatrices?: boolean,
  129848. /** defines the rendering group id to use with the viewer */
  129849. renderingGroupId?: number,
  129850. /** is the options for the viewer */
  129851. options?: Partial<ISkeletonViewerOptions>);
  129852. /** The Dynamic bindings for the update functions */
  129853. private _bindObs;
  129854. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  129855. update(): void;
  129856. /** Gets or sets a boolean indicating if the viewer is enabled */
  129857. set isEnabled(value: boolean);
  129858. get isEnabled(): boolean;
  129859. private _getBonePosition;
  129860. private _getLinesForBonesWithLength;
  129861. private _getLinesForBonesNoLength;
  129862. /** function to revert the mesh and scene back to the initial state. */
  129863. private _revert;
  129864. /** function to build and bind sphere joint points and spur bone representations. */
  129865. private _buildSpheresAndSpurs;
  129866. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  129867. private _displayLinesUpdate;
  129868. /** Release associated resources */
  129869. dispose(): void;
  129870. }
  129871. }
  129872. declare module BABYLON {
  129873. /**
  129874. * Enum for Device Types
  129875. */
  129876. export enum DeviceType {
  129877. /** Generic */
  129878. Generic = 0,
  129879. /** Keyboard */
  129880. Keyboard = 1,
  129881. /** Mouse */
  129882. Mouse = 2,
  129883. /** Touch Pointers */
  129884. Touch = 3,
  129885. /** PS4 Dual Shock */
  129886. DualShock = 4,
  129887. /** Xbox */
  129888. Xbox = 5,
  129889. /** Switch Controller */
  129890. Switch = 6
  129891. }
  129892. /**
  129893. * Enum for All Pointers (Touch/Mouse)
  129894. */
  129895. export enum PointerInput {
  129896. /** Horizontal Axis */
  129897. Horizontal = 0,
  129898. /** Vertical Axis */
  129899. Vertical = 1,
  129900. /** Left Click or Touch */
  129901. LeftClick = 2,
  129902. /** Middle Click */
  129903. MiddleClick = 3,
  129904. /** Right Click */
  129905. RightClick = 4,
  129906. /** Browser Back */
  129907. BrowserBack = 5,
  129908. /** Browser Forward */
  129909. BrowserForward = 6
  129910. }
  129911. /**
  129912. * Enum for Dual Shock Gamepad
  129913. */
  129914. export enum DualShockInput {
  129915. /** Cross */
  129916. Cross = 0,
  129917. /** Circle */
  129918. Circle = 1,
  129919. /** Square */
  129920. Square = 2,
  129921. /** Triangle */
  129922. Triangle = 3,
  129923. /** L1 */
  129924. L1 = 4,
  129925. /** R1 */
  129926. R1 = 5,
  129927. /** L2 */
  129928. L2 = 6,
  129929. /** R2 */
  129930. R2 = 7,
  129931. /** Share */
  129932. Share = 8,
  129933. /** Options */
  129934. Options = 9,
  129935. /** L3 */
  129936. L3 = 10,
  129937. /** R3 */
  129938. R3 = 11,
  129939. /** DPadUp */
  129940. DPadUp = 12,
  129941. /** DPadDown */
  129942. DPadDown = 13,
  129943. /** DPadLeft */
  129944. DPadLeft = 14,
  129945. /** DRight */
  129946. DPadRight = 15,
  129947. /** Home */
  129948. Home = 16,
  129949. /** TouchPad */
  129950. TouchPad = 17,
  129951. /** LStickXAxis */
  129952. LStickXAxis = 18,
  129953. /** LStickYAxis */
  129954. LStickYAxis = 19,
  129955. /** RStickXAxis */
  129956. RStickXAxis = 20,
  129957. /** RStickYAxis */
  129958. RStickYAxis = 21
  129959. }
  129960. /**
  129961. * Enum for Xbox Gamepad
  129962. */
  129963. export enum XboxInput {
  129964. /** A */
  129965. A = 0,
  129966. /** B */
  129967. B = 1,
  129968. /** X */
  129969. X = 2,
  129970. /** Y */
  129971. Y = 3,
  129972. /** LB */
  129973. LB = 4,
  129974. /** RB */
  129975. RB = 5,
  129976. /** LT */
  129977. LT = 6,
  129978. /** RT */
  129979. RT = 7,
  129980. /** Back */
  129981. Back = 8,
  129982. /** Start */
  129983. Start = 9,
  129984. /** LS */
  129985. LS = 10,
  129986. /** RS */
  129987. RS = 11,
  129988. /** DPadUp */
  129989. DPadUp = 12,
  129990. /** DPadDown */
  129991. DPadDown = 13,
  129992. /** DPadLeft */
  129993. DPadLeft = 14,
  129994. /** DRight */
  129995. DPadRight = 15,
  129996. /** Home */
  129997. Home = 16,
  129998. /** LStickXAxis */
  129999. LStickXAxis = 17,
  130000. /** LStickYAxis */
  130001. LStickYAxis = 18,
  130002. /** RStickXAxis */
  130003. RStickXAxis = 19,
  130004. /** RStickYAxis */
  130005. RStickYAxis = 20
  130006. }
  130007. /**
  130008. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  130009. */
  130010. export enum SwitchInput {
  130011. /** B */
  130012. B = 0,
  130013. /** A */
  130014. A = 1,
  130015. /** Y */
  130016. Y = 2,
  130017. /** X */
  130018. X = 3,
  130019. /** L */
  130020. L = 4,
  130021. /** R */
  130022. R = 5,
  130023. /** ZL */
  130024. ZL = 6,
  130025. /** ZR */
  130026. ZR = 7,
  130027. /** Minus */
  130028. Minus = 8,
  130029. /** Plus */
  130030. Plus = 9,
  130031. /** LS */
  130032. LS = 10,
  130033. /** RS */
  130034. RS = 11,
  130035. /** DPadUp */
  130036. DPadUp = 12,
  130037. /** DPadDown */
  130038. DPadDown = 13,
  130039. /** DPadLeft */
  130040. DPadLeft = 14,
  130041. /** DRight */
  130042. DPadRight = 15,
  130043. /** Home */
  130044. Home = 16,
  130045. /** Capture */
  130046. Capture = 17,
  130047. /** LStickXAxis */
  130048. LStickXAxis = 18,
  130049. /** LStickYAxis */
  130050. LStickYAxis = 19,
  130051. /** RStickXAxis */
  130052. RStickXAxis = 20,
  130053. /** RStickYAxis */
  130054. RStickYAxis = 21
  130055. }
  130056. }
  130057. declare module BABYLON {
  130058. /**
  130059. * This class will take all inputs from Keyboard, Pointer, and
  130060. * any Gamepads and provide a polling system that all devices
  130061. * will use. This class assumes that there will only be one
  130062. * pointer device and one keyboard.
  130063. */
  130064. export class DeviceInputSystem implements IDisposable {
  130065. /**
  130066. * Callback to be triggered when a device is connected
  130067. */
  130068. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130069. /**
  130070. * Callback to be triggered when a device is disconnected
  130071. */
  130072. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130073. /**
  130074. * Callback to be triggered when event driven input is updated
  130075. */
  130076. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  130077. private _inputs;
  130078. private _gamepads;
  130079. private _keyboardActive;
  130080. private _pointerActive;
  130081. private _elementToAttachTo;
  130082. private _keyboardDownEvent;
  130083. private _keyboardUpEvent;
  130084. private _pointerMoveEvent;
  130085. private _pointerDownEvent;
  130086. private _pointerUpEvent;
  130087. private _gamepadConnectedEvent;
  130088. private _gamepadDisconnectedEvent;
  130089. private static _MAX_KEYCODES;
  130090. private static _MAX_POINTER_INPUTS;
  130091. private constructor();
  130092. /**
  130093. * Creates a new DeviceInputSystem instance
  130094. * @param engine Engine to pull input element from
  130095. * @returns The new instance
  130096. */
  130097. static Create(engine: Engine): DeviceInputSystem;
  130098. /**
  130099. * Checks for current device input value, given an id and input index
  130100. * @param deviceName Id of connected device
  130101. * @param inputIndex Index of device input
  130102. * @returns Current value of input
  130103. */
  130104. /**
  130105. * Checks for current device input value, given an id and input index
  130106. * @param deviceType Enum specifiying device type
  130107. * @param deviceSlot "Slot" or index that device is referenced in
  130108. * @param inputIndex Id of input to be checked
  130109. * @returns Current value of input
  130110. */
  130111. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  130112. /**
  130113. * Dispose of all the eventlisteners
  130114. */
  130115. dispose(): void;
  130116. /**
  130117. * Add device and inputs to device array
  130118. * @param deviceType Enum specifiying device type
  130119. * @param deviceSlot "Slot" or index that device is referenced in
  130120. * @param numberOfInputs Number of input entries to create for given device
  130121. */
  130122. private _registerDevice;
  130123. /**
  130124. * Given a specific device name, remove that device from the device map
  130125. * @param deviceType Enum specifiying device type
  130126. * @param deviceSlot "Slot" or index that device is referenced in
  130127. */
  130128. private _unregisterDevice;
  130129. /**
  130130. * Handle all actions that come from keyboard interaction
  130131. */
  130132. private _handleKeyActions;
  130133. /**
  130134. * Handle all actions that come from pointer interaction
  130135. */
  130136. private _handlePointerActions;
  130137. /**
  130138. * Handle all actions that come from gamepad interaction
  130139. */
  130140. private _handleGamepadActions;
  130141. /**
  130142. * Update all non-event based devices with each frame
  130143. * @param deviceType Enum specifiying device type
  130144. * @param deviceSlot "Slot" or index that device is referenced in
  130145. * @param inputIndex Id of input to be checked
  130146. */
  130147. private _updateDevice;
  130148. /**
  130149. * Gets DeviceType from the device name
  130150. * @param deviceName Name of Device from DeviceInputSystem
  130151. * @returns DeviceType enum value
  130152. */
  130153. private _getGamepadDeviceType;
  130154. }
  130155. }
  130156. declare module BABYLON {
  130157. /**
  130158. * Type to handle enforcement of inputs
  130159. */
  130160. 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;
  130161. }
  130162. declare module BABYLON {
  130163. /**
  130164. * Class that handles all input for a specific device
  130165. */
  130166. export class DeviceSource<T extends DeviceType> {
  130167. /** Type of device */
  130168. readonly deviceType: DeviceType;
  130169. /** "Slot" or index that device is referenced in */
  130170. readonly deviceSlot: number;
  130171. /**
  130172. * Observable to handle device input changes per device
  130173. */
  130174. readonly onInputChangedObservable: Observable<{
  130175. inputIndex: DeviceInput<T>;
  130176. previousState: Nullable<number>;
  130177. currentState: Nullable<number>;
  130178. }>;
  130179. private readonly _deviceInputSystem;
  130180. /**
  130181. * Default Constructor
  130182. * @param deviceInputSystem Reference to DeviceInputSystem
  130183. * @param deviceType Type of device
  130184. * @param deviceSlot "Slot" or index that device is referenced in
  130185. */
  130186. constructor(deviceInputSystem: DeviceInputSystem,
  130187. /** Type of device */
  130188. deviceType: DeviceType,
  130189. /** "Slot" or index that device is referenced in */
  130190. deviceSlot?: number);
  130191. /**
  130192. * Get input for specific input
  130193. * @param inputIndex index of specific input on device
  130194. * @returns Input value from DeviceInputSystem
  130195. */
  130196. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  130197. }
  130198. /**
  130199. * Class to keep track of devices
  130200. */
  130201. export class DeviceSourceManager implements IDisposable {
  130202. /**
  130203. * Observable to be triggered when before a device is connected
  130204. */
  130205. readonly onBeforeDeviceConnectedObservable: Observable<{
  130206. deviceType: DeviceType;
  130207. deviceSlot: number;
  130208. }>;
  130209. /**
  130210. * Observable to be triggered when before a device is disconnected
  130211. */
  130212. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  130213. deviceType: DeviceType;
  130214. deviceSlot: number;
  130215. }>;
  130216. /**
  130217. * Observable to be triggered when after a device is connected
  130218. */
  130219. readonly onAfterDeviceConnectedObservable: Observable<{
  130220. deviceType: DeviceType;
  130221. deviceSlot: number;
  130222. }>;
  130223. /**
  130224. * Observable to be triggered when after a device is disconnected
  130225. */
  130226. readonly onAfterDeviceDisconnectedObservable: Observable<{
  130227. deviceType: DeviceType;
  130228. deviceSlot: number;
  130229. }>;
  130230. private readonly _devices;
  130231. private readonly _firstDevice;
  130232. private readonly _deviceInputSystem;
  130233. /**
  130234. * Default Constructor
  130235. * @param engine engine to pull input element from
  130236. */
  130237. constructor(engine: Engine);
  130238. /**
  130239. * Gets a DeviceSource, given a type and slot
  130240. * @param deviceType Enum specifying device type
  130241. * @param deviceSlot "Slot" or index that device is referenced in
  130242. * @returns DeviceSource object
  130243. */
  130244. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  130245. /**
  130246. * Gets an array of DeviceSource objects for a given device type
  130247. * @param deviceType Enum specifying device type
  130248. * @returns Array of DeviceSource objects
  130249. */
  130250. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  130251. /**
  130252. * Dispose of DeviceInputSystem and other parts
  130253. */
  130254. dispose(): void;
  130255. /**
  130256. * Function to add device name to device list
  130257. * @param deviceType Enum specifying device type
  130258. * @param deviceSlot "Slot" or index that device is referenced in
  130259. */
  130260. private _addDevice;
  130261. /**
  130262. * Function to remove device name to device list
  130263. * @param deviceType Enum specifying device type
  130264. * @param deviceSlot "Slot" or index that device is referenced in
  130265. */
  130266. private _removeDevice;
  130267. /**
  130268. * Updates array storing first connected device of each type
  130269. * @param type Type of Device
  130270. */
  130271. private _updateFirstDevices;
  130272. }
  130273. }
  130274. declare module BABYLON {
  130275. /**
  130276. * Options to create the null engine
  130277. */
  130278. export class NullEngineOptions {
  130279. /**
  130280. * Render width (Default: 512)
  130281. */
  130282. renderWidth: number;
  130283. /**
  130284. * Render height (Default: 256)
  130285. */
  130286. renderHeight: number;
  130287. /**
  130288. * Texture size (Default: 512)
  130289. */
  130290. textureSize: number;
  130291. /**
  130292. * If delta time between frames should be constant
  130293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130294. */
  130295. deterministicLockstep: boolean;
  130296. /**
  130297. * Maximum about of steps between frames (Default: 4)
  130298. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130299. */
  130300. lockstepMaxSteps: number;
  130301. /**
  130302. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  130303. */
  130304. useHighPrecisionMatrix?: boolean;
  130305. }
  130306. /**
  130307. * The null engine class provides support for headless version of babylon.js.
  130308. * This can be used in server side scenario or for testing purposes
  130309. */
  130310. export class NullEngine extends Engine {
  130311. private _options;
  130312. /**
  130313. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  130314. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130315. * @returns true if engine is in deterministic lock step mode
  130316. */
  130317. isDeterministicLockStep(): boolean;
  130318. /**
  130319. * Gets the max steps when engine is running in deterministic lock step
  130320. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130321. * @returns the max steps
  130322. */
  130323. getLockstepMaxSteps(): number;
  130324. /**
  130325. * Gets the current hardware scaling level.
  130326. * By default the hardware scaling level is computed from the window device ratio.
  130327. * 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.
  130328. * @returns a number indicating the current hardware scaling level
  130329. */
  130330. getHardwareScalingLevel(): number;
  130331. constructor(options?: NullEngineOptions);
  130332. /**
  130333. * Creates a vertex buffer
  130334. * @param vertices the data for the vertex buffer
  130335. * @returns the new WebGL static buffer
  130336. */
  130337. createVertexBuffer(vertices: FloatArray): DataBuffer;
  130338. /**
  130339. * Creates a new index buffer
  130340. * @param indices defines the content of the index buffer
  130341. * @param updatable defines if the index buffer must be updatable
  130342. * @returns a new webGL buffer
  130343. */
  130344. createIndexBuffer(indices: IndicesArray): DataBuffer;
  130345. /**
  130346. * Clear the current render buffer or the current render target (if any is set up)
  130347. * @param color defines the color to use
  130348. * @param backBuffer defines if the back buffer must be cleared
  130349. * @param depth defines if the depth buffer must be cleared
  130350. * @param stencil defines if the stencil buffer must be cleared
  130351. */
  130352. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130353. /**
  130354. * Gets the current render width
  130355. * @param useScreen defines if screen size must be used (or the current render target if any)
  130356. * @returns a number defining the current render width
  130357. */
  130358. getRenderWidth(useScreen?: boolean): number;
  130359. /**
  130360. * Gets the current render height
  130361. * @param useScreen defines if screen size must be used (or the current render target if any)
  130362. * @returns a number defining the current render height
  130363. */
  130364. getRenderHeight(useScreen?: boolean): number;
  130365. /**
  130366. * Set the WebGL's viewport
  130367. * @param viewport defines the viewport element to be used
  130368. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  130369. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  130370. */
  130371. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  130372. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  130373. /**
  130374. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  130375. * @param pipelineContext defines the pipeline context to use
  130376. * @param uniformsNames defines the list of uniform names
  130377. * @returns an array of webGL uniform locations
  130378. */
  130379. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130380. /**
  130381. * Gets the lsit of active attributes for a given webGL program
  130382. * @param pipelineContext defines the pipeline context to use
  130383. * @param attributesNames defines the list of attribute names to get
  130384. * @returns an array of indices indicating the offset of each attribute
  130385. */
  130386. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130387. /**
  130388. * Binds an effect to the webGL context
  130389. * @param effect defines the effect to bind
  130390. */
  130391. bindSamplers(effect: Effect): void;
  130392. /**
  130393. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130394. * @param effect defines the effect to activate
  130395. */
  130396. enableEffect(effect: Effect): void;
  130397. /**
  130398. * Set various states to the webGL context
  130399. * @param culling defines backface culling state
  130400. * @param zOffset defines the value to apply to zOffset (0 by default)
  130401. * @param force defines if states must be applied even if cache is up to date
  130402. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130403. */
  130404. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130405. /**
  130406. * Set the value of an uniform to an array of int32
  130407. * @param uniform defines the webGL uniform location where to store the value
  130408. * @param array defines the array of int32 to store
  130409. */
  130410. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130411. /**
  130412. * Set the value of an uniform to an array of int32 (stored as vec2)
  130413. * @param uniform defines the webGL uniform location where to store the value
  130414. * @param array defines the array of int32 to store
  130415. */
  130416. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130417. /**
  130418. * Set the value of an uniform to an array of int32 (stored as vec3)
  130419. * @param uniform defines the webGL uniform location where to store the value
  130420. * @param array defines the array of int32 to store
  130421. */
  130422. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130423. /**
  130424. * Set the value of an uniform to an array of int32 (stored as vec4)
  130425. * @param uniform defines the webGL uniform location where to store the value
  130426. * @param array defines the array of int32 to store
  130427. */
  130428. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130429. /**
  130430. * Set the value of an uniform to an array of float32
  130431. * @param uniform defines the webGL uniform location where to store the value
  130432. * @param array defines the array of float32 to store
  130433. */
  130434. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130435. /**
  130436. * Set the value of an uniform to an array of float32 (stored as vec2)
  130437. * @param uniform defines the webGL uniform location where to store the value
  130438. * @param array defines the array of float32 to store
  130439. */
  130440. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130441. /**
  130442. * Set the value of an uniform to an array of float32 (stored as vec3)
  130443. * @param uniform defines the webGL uniform location where to store the value
  130444. * @param array defines the array of float32 to store
  130445. */
  130446. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130447. /**
  130448. * Set the value of an uniform to an array of float32 (stored as vec4)
  130449. * @param uniform defines the webGL uniform location where to store the value
  130450. * @param array defines the array of float32 to store
  130451. */
  130452. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130453. /**
  130454. * Set the value of an uniform to an array of number
  130455. * @param uniform defines the webGL uniform location where to store the value
  130456. * @param array defines the array of number to store
  130457. */
  130458. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130459. /**
  130460. * Set the value of an uniform to an array of number (stored as vec2)
  130461. * @param uniform defines the webGL uniform location where to store the value
  130462. * @param array defines the array of number to store
  130463. */
  130464. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130465. /**
  130466. * Set the value of an uniform to an array of number (stored as vec3)
  130467. * @param uniform defines the webGL uniform location where to store the value
  130468. * @param array defines the array of number to store
  130469. */
  130470. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130471. /**
  130472. * Set the value of an uniform to an array of number (stored as vec4)
  130473. * @param uniform defines the webGL uniform location where to store the value
  130474. * @param array defines the array of number to store
  130475. */
  130476. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130477. /**
  130478. * Set the value of an uniform to an array of float32 (stored as matrices)
  130479. * @param uniform defines the webGL uniform location where to store the value
  130480. * @param matrices defines the array of float32 to store
  130481. */
  130482. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130483. /**
  130484. * Set the value of an uniform to a matrix (3x3)
  130485. * @param uniform defines the webGL uniform location where to store the value
  130486. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  130487. */
  130488. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130489. /**
  130490. * Set the value of an uniform to a matrix (2x2)
  130491. * @param uniform defines the webGL uniform location where to store the value
  130492. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  130493. */
  130494. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130495. /**
  130496. * Set the value of an uniform to a number (float)
  130497. * @param uniform defines the webGL uniform location where to store the value
  130498. * @param value defines the float number to store
  130499. */
  130500. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130501. /**
  130502. * Set the value of an uniform to a vec2
  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. */
  130507. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130508. /**
  130509. * Set the value of an uniform to a vec3
  130510. * @param uniform defines the webGL uniform location where to store the value
  130511. * @param x defines the 1st component of the value
  130512. * @param y defines the 2nd component of the value
  130513. * @param z defines the 3rd component of the value
  130514. */
  130515. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130516. /**
  130517. * Set the value of an uniform to a boolean
  130518. * @param uniform defines the webGL uniform location where to store the value
  130519. * @param bool defines the boolean to store
  130520. */
  130521. setBool(uniform: WebGLUniformLocation, bool: number): void;
  130522. /**
  130523. * Set the value of an uniform to a vec4
  130524. * @param uniform defines the webGL uniform location where to store the value
  130525. * @param x defines the 1st component of the value
  130526. * @param y defines the 2nd component of the value
  130527. * @param z defines the 3rd component of the value
  130528. * @param w defines the 4th component of the value
  130529. */
  130530. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130531. /**
  130532. * Sets the current alpha mode
  130533. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  130534. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130535. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130536. */
  130537. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130538. /**
  130539. * Bind webGl buffers directly to the webGL context
  130540. * @param vertexBuffers defines the vertex buffer to bind
  130541. * @param indexBuffer defines the index buffer to bind
  130542. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  130543. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  130544. * @param effect defines the effect associated with the vertex buffer
  130545. */
  130546. bindBuffers(vertexBuffers: {
  130547. [key: string]: VertexBuffer;
  130548. }, indexBuffer: DataBuffer, effect: Effect): void;
  130549. /**
  130550. * Force the entire cache to be cleared
  130551. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  130552. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  130553. */
  130554. wipeCaches(bruteForce?: boolean): void;
  130555. /**
  130556. * Send a draw order
  130557. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  130558. * @param indexStart defines the starting index
  130559. * @param indexCount defines the number of index to draw
  130560. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130561. */
  130562. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  130563. /**
  130564. * Draw a list of indexed primitives
  130565. * @param fillMode defines the primitive to use
  130566. * @param indexStart defines the starting index
  130567. * @param indexCount defines the number of index to draw
  130568. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130569. */
  130570. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130571. /**
  130572. * Draw a list of unindexed primitives
  130573. * @param fillMode defines the primitive to use
  130574. * @param verticesStart defines the index of first vertex to draw
  130575. * @param verticesCount defines the count of vertices to draw
  130576. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130577. */
  130578. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130579. /** @hidden */
  130580. _createTexture(): WebGLTexture;
  130581. /** @hidden */
  130582. _releaseTexture(texture: InternalTexture): void;
  130583. /**
  130584. * Usually called from Texture.ts.
  130585. * Passed information to create a WebGLTexture
  130586. * @param urlArg defines a value which contains one of the following:
  130587. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130588. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130589. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130590. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130591. * @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)
  130592. * @param scene needed for loading to the correct scene
  130593. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130594. * @param onLoad optional callback to be called upon successful completion
  130595. * @param onError optional callback to be called upon failure
  130596. * @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
  130597. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130598. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130599. * @param forcedExtension defines the extension to use to pick the right loader
  130600. * @param mimeType defines an optional mime type
  130601. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130602. */
  130603. 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;
  130604. /**
  130605. * Creates a new render target texture
  130606. * @param size defines the size of the texture
  130607. * @param options defines the options used to create the texture
  130608. * @returns a new render target texture stored in an InternalTexture
  130609. */
  130610. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130611. /**
  130612. * Update the sampling mode of a given texture
  130613. * @param samplingMode defines the required sampling mode
  130614. * @param texture defines the texture to update
  130615. */
  130616. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130617. /**
  130618. * Binds the frame buffer to the specified texture.
  130619. * @param texture The texture to render to or null for the default canvas
  130620. * @param faceIndex The face of the texture to render to in case of cube texture
  130621. * @param requiredWidth The width of the target to render to
  130622. * @param requiredHeight The height of the target to render to
  130623. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130624. * @param lodLevel defines le lod level to bind to the frame buffer
  130625. */
  130626. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130627. /**
  130628. * Unbind the current render target texture from the webGL context
  130629. * @param texture defines the render target texture to unbind
  130630. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130631. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130632. */
  130633. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130634. /**
  130635. * Creates a dynamic vertex buffer
  130636. * @param vertices the data for the dynamic vertex buffer
  130637. * @returns the new WebGL dynamic buffer
  130638. */
  130639. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  130640. /**
  130641. * Update the content of a dynamic texture
  130642. * @param texture defines the texture to update
  130643. * @param canvas defines the canvas containing the source
  130644. * @param invertY defines if data must be stored with Y axis inverted
  130645. * @param premulAlpha defines if alpha is stored as premultiplied
  130646. * @param format defines the format of the data
  130647. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130648. */
  130649. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  130650. /**
  130651. * Gets a boolean indicating if all created effects are ready
  130652. * @returns true if all effects are ready
  130653. */
  130654. areAllEffectsReady(): boolean;
  130655. /**
  130656. * @hidden
  130657. * Get the current error code of the webGL context
  130658. * @returns the error code
  130659. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  130660. */
  130661. getError(): number;
  130662. /** @hidden */
  130663. _getUnpackAlignement(): number;
  130664. /** @hidden */
  130665. _unpackFlipY(value: boolean): void;
  130666. /**
  130667. * Update a dynamic index buffer
  130668. * @param indexBuffer defines the target index buffer
  130669. * @param indices defines the data to update
  130670. * @param offset defines the offset in the target index buffer where update should start
  130671. */
  130672. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  130673. /**
  130674. * Updates a dynamic vertex buffer.
  130675. * @param vertexBuffer the vertex buffer to update
  130676. * @param vertices the data used to update the vertex buffer
  130677. * @param byteOffset the byte offset of the data (optional)
  130678. * @param byteLength the byte length of the data (optional)
  130679. */
  130680. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  130681. /** @hidden */
  130682. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  130683. /** @hidden */
  130684. _bindTexture(channel: number, texture: InternalTexture): void;
  130685. protected _deleteBuffer(buffer: WebGLBuffer): void;
  130686. /**
  130687. * 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
  130688. */
  130689. releaseEffects(): void;
  130690. displayLoadingUI(): void;
  130691. hideLoadingUI(): void;
  130692. /** @hidden */
  130693. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130694. /** @hidden */
  130695. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130696. /** @hidden */
  130697. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130698. /** @hidden */
  130699. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130700. }
  130701. }
  130702. declare module BABYLON {
  130703. /**
  130704. * @hidden
  130705. **/
  130706. export class _TimeToken {
  130707. _startTimeQuery: Nullable<WebGLQuery>;
  130708. _endTimeQuery: Nullable<WebGLQuery>;
  130709. _timeElapsedQuery: Nullable<WebGLQuery>;
  130710. _timeElapsedQueryEnded: boolean;
  130711. }
  130712. }
  130713. declare module BABYLON {
  130714. /** @hidden */
  130715. export class _OcclusionDataStorage {
  130716. /** @hidden */
  130717. occlusionInternalRetryCounter: number;
  130718. /** @hidden */
  130719. isOcclusionQueryInProgress: boolean;
  130720. /** @hidden */
  130721. isOccluded: boolean;
  130722. /** @hidden */
  130723. occlusionRetryCount: number;
  130724. /** @hidden */
  130725. occlusionType: number;
  130726. /** @hidden */
  130727. occlusionQueryAlgorithmType: number;
  130728. }
  130729. interface Engine {
  130730. /**
  130731. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  130732. * @return the new query
  130733. */
  130734. createQuery(): WebGLQuery;
  130735. /**
  130736. * Delete and release a webGL query
  130737. * @param query defines the query to delete
  130738. * @return the current engine
  130739. */
  130740. deleteQuery(query: WebGLQuery): Engine;
  130741. /**
  130742. * Check if a given query has resolved and got its value
  130743. * @param query defines the query to check
  130744. * @returns true if the query got its value
  130745. */
  130746. isQueryResultAvailable(query: WebGLQuery): boolean;
  130747. /**
  130748. * Gets the value of a given query
  130749. * @param query defines the query to check
  130750. * @returns the value of the query
  130751. */
  130752. getQueryResult(query: WebGLQuery): number;
  130753. /**
  130754. * Initiates an occlusion query
  130755. * @param algorithmType defines the algorithm to use
  130756. * @param query defines the query to use
  130757. * @returns the current engine
  130758. * @see https://doc.babylonjs.com/features/occlusionquery
  130759. */
  130760. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  130761. /**
  130762. * Ends an occlusion query
  130763. * @see https://doc.babylonjs.com/features/occlusionquery
  130764. * @param algorithmType defines the algorithm to use
  130765. * @returns the current engine
  130766. */
  130767. endOcclusionQuery(algorithmType: number): Engine;
  130768. /**
  130769. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  130770. * Please note that only one query can be issued at a time
  130771. * @returns a time token used to track the time span
  130772. */
  130773. startTimeQuery(): Nullable<_TimeToken>;
  130774. /**
  130775. * Ends a time query
  130776. * @param token defines the token used to measure the time span
  130777. * @returns the time spent (in ns)
  130778. */
  130779. endTimeQuery(token: _TimeToken): int;
  130780. /** @hidden */
  130781. _currentNonTimestampToken: Nullable<_TimeToken>;
  130782. /** @hidden */
  130783. _createTimeQuery(): WebGLQuery;
  130784. /** @hidden */
  130785. _deleteTimeQuery(query: WebGLQuery): void;
  130786. /** @hidden */
  130787. _getGlAlgorithmType(algorithmType: number): number;
  130788. /** @hidden */
  130789. _getTimeQueryResult(query: WebGLQuery): any;
  130790. /** @hidden */
  130791. _getTimeQueryAvailability(query: WebGLQuery): any;
  130792. }
  130793. interface AbstractMesh {
  130794. /**
  130795. * Backing filed
  130796. * @hidden
  130797. */
  130798. __occlusionDataStorage: _OcclusionDataStorage;
  130799. /**
  130800. * Access property
  130801. * @hidden
  130802. */
  130803. _occlusionDataStorage: _OcclusionDataStorage;
  130804. /**
  130805. * 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.
  130806. * The default value is -1 which means don't break the query and wait till the result
  130807. * @see https://doc.babylonjs.com/features/occlusionquery
  130808. */
  130809. occlusionRetryCount: number;
  130810. /**
  130811. * 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:
  130812. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  130813. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  130814. * * 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.
  130815. * @see https://doc.babylonjs.com/features/occlusionquery
  130816. */
  130817. occlusionType: number;
  130818. /**
  130819. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  130820. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  130821. * * 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.
  130822. * @see https://doc.babylonjs.com/features/occlusionquery
  130823. */
  130824. occlusionQueryAlgorithmType: number;
  130825. /**
  130826. * 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
  130827. * @see https://doc.babylonjs.com/features/occlusionquery
  130828. */
  130829. isOccluded: boolean;
  130830. /**
  130831. * Flag to check the progress status of the query
  130832. * @see https://doc.babylonjs.com/features/occlusionquery
  130833. */
  130834. isOcclusionQueryInProgress: boolean;
  130835. }
  130836. }
  130837. declare module BABYLON {
  130838. /** @hidden */
  130839. export var _forceTransformFeedbackToBundle: boolean;
  130840. interface Engine {
  130841. /**
  130842. * Creates a webGL transform feedback object
  130843. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  130844. * @returns the webGL transform feedback object
  130845. */
  130846. createTransformFeedback(): WebGLTransformFeedback;
  130847. /**
  130848. * Delete a webGL transform feedback object
  130849. * @param value defines the webGL transform feedback object to delete
  130850. */
  130851. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  130852. /**
  130853. * Bind a webGL transform feedback object to the webgl context
  130854. * @param value defines the webGL transform feedback object to bind
  130855. */
  130856. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  130857. /**
  130858. * Begins a transform feedback operation
  130859. * @param usePoints defines if points or triangles must be used
  130860. */
  130861. beginTransformFeedback(usePoints: boolean): void;
  130862. /**
  130863. * Ends a transform feedback operation
  130864. */
  130865. endTransformFeedback(): void;
  130866. /**
  130867. * Specify the varyings to use with transform feedback
  130868. * @param program defines the associated webGL program
  130869. * @param value defines the list of strings representing the varying names
  130870. */
  130871. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  130872. /**
  130873. * Bind a webGL buffer for a transform feedback operation
  130874. * @param value defines the webGL buffer to bind
  130875. */
  130876. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  130877. }
  130878. }
  130879. declare module BABYLON {
  130880. /**
  130881. * Class used to define an additional view for the engine
  130882. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130883. */
  130884. export class EngineView {
  130885. /** Defines the canvas where to render the view */
  130886. target: HTMLCanvasElement;
  130887. /** Defines an optional camera used to render the view (will use active camera else) */
  130888. camera?: Camera;
  130889. }
  130890. interface Engine {
  130891. /**
  130892. * Gets or sets the HTML element to use for attaching events
  130893. */
  130894. inputElement: Nullable<HTMLElement>;
  130895. /**
  130896. * Gets the current engine view
  130897. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130898. */
  130899. activeView: Nullable<EngineView>;
  130900. /** Gets or sets the list of views */
  130901. views: EngineView[];
  130902. /**
  130903. * Register a new child canvas
  130904. * @param canvas defines the canvas to register
  130905. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  130906. * @returns the associated view
  130907. */
  130908. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  130909. /**
  130910. * Remove a registered child canvas
  130911. * @param canvas defines the canvas to remove
  130912. * @returns the current engine
  130913. */
  130914. unRegisterView(canvas: HTMLCanvasElement): Engine;
  130915. }
  130916. }
  130917. declare module BABYLON {
  130918. interface Engine {
  130919. /** @hidden */
  130920. _excludedCompressedTextures: string[];
  130921. /** @hidden */
  130922. _textureFormatInUse: string;
  130923. /**
  130924. * Gets the list of texture formats supported
  130925. */
  130926. readonly texturesSupported: Array<string>;
  130927. /**
  130928. * Gets the texture format in use
  130929. */
  130930. readonly textureFormatInUse: Nullable<string>;
  130931. /**
  130932. * Set the compressed texture extensions or file names to skip.
  130933. *
  130934. * @param skippedFiles defines the list of those texture files you want to skip
  130935. * Example: [".dds", ".env", "myfile.png"]
  130936. */
  130937. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  130938. /**
  130939. * Set the compressed texture format to use, based on the formats you have, and the formats
  130940. * supported by the hardware / browser.
  130941. *
  130942. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  130943. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  130944. * to API arguments needed to compressed textures. This puts the burden on the container
  130945. * generator to house the arcane code for determining these for current & future formats.
  130946. *
  130947. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  130948. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  130949. *
  130950. * Note: The result of this call is not taken into account when a texture is base64.
  130951. *
  130952. * @param formatsAvailable defines the list of those format families you have created
  130953. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  130954. *
  130955. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  130956. * @returns The extension selected.
  130957. */
  130958. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  130959. }
  130960. }
  130961. declare module BABYLON {
  130962. /**
  130963. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  130964. */
  130965. export interface CubeMapInfo {
  130966. /**
  130967. * The pixel array for the front face.
  130968. * This is stored in format, left to right, up to down format.
  130969. */
  130970. front: Nullable<ArrayBufferView>;
  130971. /**
  130972. * The pixel array for the back face.
  130973. * This is stored in format, left to right, up to down format.
  130974. */
  130975. back: Nullable<ArrayBufferView>;
  130976. /**
  130977. * The pixel array for the left face.
  130978. * This is stored in format, left to right, up to down format.
  130979. */
  130980. left: Nullable<ArrayBufferView>;
  130981. /**
  130982. * The pixel array for the right face.
  130983. * This is stored in format, left to right, up to down format.
  130984. */
  130985. right: Nullable<ArrayBufferView>;
  130986. /**
  130987. * The pixel array for the up face.
  130988. * This is stored in format, left to right, up to down format.
  130989. */
  130990. up: Nullable<ArrayBufferView>;
  130991. /**
  130992. * The pixel array for the down face.
  130993. * This is stored in format, left to right, up to down format.
  130994. */
  130995. down: Nullable<ArrayBufferView>;
  130996. /**
  130997. * The size of the cubemap stored.
  130998. *
  130999. * Each faces will be size * size pixels.
  131000. */
  131001. size: number;
  131002. /**
  131003. * The format of the texture.
  131004. *
  131005. * RGBA, RGB.
  131006. */
  131007. format: number;
  131008. /**
  131009. * The type of the texture data.
  131010. *
  131011. * UNSIGNED_INT, FLOAT.
  131012. */
  131013. type: number;
  131014. /**
  131015. * Specifies whether the texture is in gamma space.
  131016. */
  131017. gammaSpace: boolean;
  131018. }
  131019. /**
  131020. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  131021. */
  131022. export class PanoramaToCubeMapTools {
  131023. private static FACE_LEFT;
  131024. private static FACE_RIGHT;
  131025. private static FACE_FRONT;
  131026. private static FACE_BACK;
  131027. private static FACE_DOWN;
  131028. private static FACE_UP;
  131029. /**
  131030. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  131031. *
  131032. * @param float32Array The source data.
  131033. * @param inputWidth The width of the input panorama.
  131034. * @param inputHeight The height of the input panorama.
  131035. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  131036. * @return The cubemap data
  131037. */
  131038. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  131039. private static CreateCubemapTexture;
  131040. private static CalcProjectionSpherical;
  131041. }
  131042. }
  131043. declare module BABYLON {
  131044. /**
  131045. * Helper class dealing with the extraction of spherical polynomial dataArray
  131046. * from a cube map.
  131047. */
  131048. export class CubeMapToSphericalPolynomialTools {
  131049. private static FileFaces;
  131050. /**
  131051. * Converts a texture to the according Spherical Polynomial data.
  131052. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131053. *
  131054. * @param texture The texture to extract the information from.
  131055. * @return The Spherical Polynomial data.
  131056. */
  131057. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  131058. /**
  131059. * Converts a cubemap to the according Spherical Polynomial data.
  131060. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131061. *
  131062. * @param cubeInfo The Cube map to extract the information from.
  131063. * @return The Spherical Polynomial data.
  131064. */
  131065. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  131066. }
  131067. }
  131068. declare module BABYLON {
  131069. interface BaseTexture {
  131070. /**
  131071. * Get the polynomial representation of the texture data.
  131072. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  131073. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  131074. */
  131075. sphericalPolynomial: Nullable<SphericalPolynomial>;
  131076. }
  131077. }
  131078. declare module BABYLON {
  131079. /** @hidden */
  131080. export var rgbdEncodePixelShader: {
  131081. name: string;
  131082. shader: string;
  131083. };
  131084. }
  131085. declare module BABYLON {
  131086. /** @hidden */
  131087. export var rgbdDecodePixelShader: {
  131088. name: string;
  131089. shader: string;
  131090. };
  131091. }
  131092. declare module BABYLON {
  131093. /**
  131094. * Raw texture data and descriptor sufficient for WebGL texture upload
  131095. */
  131096. export interface EnvironmentTextureInfo {
  131097. /**
  131098. * Version of the environment map
  131099. */
  131100. version: number;
  131101. /**
  131102. * Width of image
  131103. */
  131104. width: number;
  131105. /**
  131106. * Irradiance information stored in the file.
  131107. */
  131108. irradiance: any;
  131109. /**
  131110. * Specular information stored in the file.
  131111. */
  131112. specular: any;
  131113. }
  131114. /**
  131115. * Defines One Image in the file. It requires only the position in the file
  131116. * as well as the length.
  131117. */
  131118. interface BufferImageData {
  131119. /**
  131120. * Length of the image data.
  131121. */
  131122. length: number;
  131123. /**
  131124. * Position of the data from the null terminator delimiting the end of the JSON.
  131125. */
  131126. position: number;
  131127. }
  131128. /**
  131129. * Defines the specular data enclosed in the file.
  131130. * This corresponds to the version 1 of the data.
  131131. */
  131132. export interface EnvironmentTextureSpecularInfoV1 {
  131133. /**
  131134. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  131135. */
  131136. specularDataPosition?: number;
  131137. /**
  131138. * This contains all the images data needed to reconstruct the cubemap.
  131139. */
  131140. mipmaps: Array<BufferImageData>;
  131141. /**
  131142. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  131143. */
  131144. lodGenerationScale: number;
  131145. }
  131146. /**
  131147. * Sets of helpers addressing the serialization and deserialization of environment texture
  131148. * stored in a BabylonJS env file.
  131149. * Those files are usually stored as .env files.
  131150. */
  131151. export class EnvironmentTextureTools {
  131152. /**
  131153. * Magic number identifying the env file.
  131154. */
  131155. private static _MagicBytes;
  131156. /**
  131157. * Gets the environment info from an env file.
  131158. * @param data The array buffer containing the .env bytes.
  131159. * @returns the environment file info (the json header) if successfully parsed.
  131160. */
  131161. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  131162. /**
  131163. * Creates an environment texture from a loaded cube texture.
  131164. * @param texture defines the cube texture to convert in env file
  131165. * @return a promise containing the environment data if succesfull.
  131166. */
  131167. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  131168. /**
  131169. * Creates a JSON representation of the spherical data.
  131170. * @param texture defines the texture containing the polynomials
  131171. * @return the JSON representation of the spherical info
  131172. */
  131173. private static _CreateEnvTextureIrradiance;
  131174. /**
  131175. * Creates the ArrayBufferViews used for initializing environment texture image data.
  131176. * @param data the image data
  131177. * @param info parameters that determine what views will be created for accessing the underlying buffer
  131178. * @return the views described by info providing access to the underlying buffer
  131179. */
  131180. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  131181. /**
  131182. * Uploads the texture info contained in the env file to the GPU.
  131183. * @param texture defines the internal texture to upload to
  131184. * @param data defines the data to load
  131185. * @param info defines the texture info retrieved through the GetEnvInfo method
  131186. * @returns a promise
  131187. */
  131188. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  131189. private static _OnImageReadyAsync;
  131190. /**
  131191. * Uploads the levels of image data to the GPU.
  131192. * @param texture defines the internal texture to upload to
  131193. * @param imageData defines the array buffer views of image data [mipmap][face]
  131194. * @returns a promise
  131195. */
  131196. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  131197. /**
  131198. * Uploads spherical polynomials information to the texture.
  131199. * @param texture defines the texture we are trying to upload the information to
  131200. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  131201. */
  131202. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  131203. /** @hidden */
  131204. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131205. }
  131206. }
  131207. declare module BABYLON {
  131208. /**
  131209. * Class used to inline functions in shader code
  131210. */
  131211. export class ShaderCodeInliner {
  131212. private static readonly _RegexpFindFunctionNameAndType;
  131213. private _sourceCode;
  131214. private _functionDescr;
  131215. private _numMaxIterations;
  131216. /** Gets or sets the token used to mark the functions to inline */
  131217. inlineToken: string;
  131218. /** Gets or sets the debug mode */
  131219. debug: boolean;
  131220. /** Gets the code after the inlining process */
  131221. get code(): string;
  131222. /**
  131223. * Initializes the inliner
  131224. * @param sourceCode shader code source to inline
  131225. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  131226. */
  131227. constructor(sourceCode: string, numMaxIterations?: number);
  131228. /**
  131229. * Start the processing of the shader code
  131230. */
  131231. processCode(): void;
  131232. private _collectFunctions;
  131233. private _processInlining;
  131234. private _extractBetweenMarkers;
  131235. private _skipWhitespaces;
  131236. private _removeComments;
  131237. private _replaceFunctionCallsByCode;
  131238. private _findBackward;
  131239. private _escapeRegExp;
  131240. private _replaceNames;
  131241. }
  131242. }
  131243. declare module BABYLON {
  131244. /**
  131245. * Container for accessors for natively-stored mesh data buffers.
  131246. */
  131247. class NativeDataBuffer extends DataBuffer {
  131248. /**
  131249. * Accessor value used to identify/retrieve a natively-stored index buffer.
  131250. */
  131251. nativeIndexBuffer?: any;
  131252. /**
  131253. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  131254. */
  131255. nativeVertexBuffer?: any;
  131256. }
  131257. /** @hidden */
  131258. class NativeTexture extends InternalTexture {
  131259. getInternalTexture(): InternalTexture;
  131260. getViewCount(): number;
  131261. }
  131262. /** @hidden */
  131263. export class NativeEngine extends Engine {
  131264. private readonly _native;
  131265. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  131266. private readonly INVALID_HANDLE;
  131267. getHardwareScalingLevel(): number;
  131268. constructor();
  131269. dispose(): void;
  131270. /**
  131271. * Can be used to override the current requestAnimationFrame requester.
  131272. * @hidden
  131273. */
  131274. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  131275. /**
  131276. * Override default engine behavior.
  131277. * @param color
  131278. * @param backBuffer
  131279. * @param depth
  131280. * @param stencil
  131281. */
  131282. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  131283. /**
  131284. * Gets host document
  131285. * @returns the host document object
  131286. */
  131287. getHostDocument(): Nullable<Document>;
  131288. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131289. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  131290. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  131291. bindBuffers(vertexBuffers: {
  131292. [key: string]: VertexBuffer;
  131293. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131294. recordVertexArrayObject(vertexBuffers: {
  131295. [key: string]: VertexBuffer;
  131296. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  131297. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131298. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131299. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131300. /**
  131301. * Draw a list of indexed primitives
  131302. * @param fillMode defines the primitive to use
  131303. * @param indexStart defines the starting index
  131304. * @param indexCount defines the number of index to draw
  131305. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131306. */
  131307. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131308. /**
  131309. * Draw a list of unindexed primitives
  131310. * @param fillMode defines the primitive to use
  131311. * @param verticesStart defines the index of first vertex to draw
  131312. * @param verticesCount defines the count of vertices to draw
  131313. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131314. */
  131315. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131316. createPipelineContext(): IPipelineContext;
  131317. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  131318. /** @hidden */
  131319. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  131320. /** @hidden */
  131321. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  131322. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131323. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131324. protected _setProgram(program: WebGLProgram): void;
  131325. _releaseEffect(effect: Effect): void;
  131326. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  131327. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  131328. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  131329. bindSamplers(effect: Effect): void;
  131330. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  131331. getRenderWidth(useScreen?: boolean): number;
  131332. getRenderHeight(useScreen?: boolean): number;
  131333. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  131334. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131335. /**
  131336. * Set the z offset to apply to current rendering
  131337. * @param value defines the offset to apply
  131338. */
  131339. setZOffset(value: number): void;
  131340. /**
  131341. * Gets the current value of the zOffset
  131342. * @returns the current zOffset state
  131343. */
  131344. getZOffset(): number;
  131345. /**
  131346. * Enable or disable depth buffering
  131347. * @param enable defines the state to set
  131348. */
  131349. setDepthBuffer(enable: boolean): void;
  131350. /**
  131351. * Gets a boolean indicating if depth writing is enabled
  131352. * @returns the current depth writing state
  131353. */
  131354. getDepthWrite(): boolean;
  131355. /**
  131356. * Enable or disable depth writing
  131357. * @param enable defines the state to set
  131358. */
  131359. setDepthWrite(enable: boolean): void;
  131360. /**
  131361. * Enable or disable color writing
  131362. * @param enable defines the state to set
  131363. */
  131364. setColorWrite(enable: boolean): void;
  131365. /**
  131366. * Gets a boolean indicating if color writing is enabled
  131367. * @returns the current color writing state
  131368. */
  131369. getColorWrite(): boolean;
  131370. /**
  131371. * Sets alpha constants used by some alpha blending modes
  131372. * @param r defines the red component
  131373. * @param g defines the green component
  131374. * @param b defines the blue component
  131375. * @param a defines the alpha component
  131376. */
  131377. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  131378. /**
  131379. * Sets the current alpha mode
  131380. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  131381. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131382. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131383. */
  131384. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131385. /**
  131386. * Gets the current alpha mode
  131387. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131388. * @returns the current alpha mode
  131389. */
  131390. getAlphaMode(): number;
  131391. setInt(uniform: WebGLUniformLocation, int: number): void;
  131392. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131393. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131394. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131395. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131396. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131397. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131398. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131399. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131400. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131401. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131402. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131403. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131404. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131405. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131406. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131407. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131408. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131409. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131410. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131411. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  131412. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  131413. wipeCaches(bruteForce?: boolean): void;
  131414. _createTexture(): WebGLTexture;
  131415. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  131416. /**
  131417. * Usually called from Texture.ts.
  131418. * Passed information to create a WebGLTexture
  131419. * @param url defines a value which contains one of the following:
  131420. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131421. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131422. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131424. * @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)
  131425. * @param scene needed for loading to the correct scene
  131426. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131427. * @param onLoad optional callback to be called upon successful completion
  131428. * @param onError optional callback to be called upon failure
  131429. * @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
  131430. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131431. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131432. * @param forcedExtension defines the extension to use to pick the right loader
  131433. * @param mimeType defines an optional mime type
  131434. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131435. */
  131436. 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;
  131437. /**
  131438. * Creates a cube texture
  131439. * @param rootUrl defines the url where the files to load is located
  131440. * @param scene defines the current scene
  131441. * @param files defines the list of files to load (1 per face)
  131442. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  131443. * @param onLoad defines an optional callback raised when the texture is loaded
  131444. * @param onError defines an optional callback raised if there is an issue to load the texture
  131445. * @param format defines the format of the data
  131446. * @param forcedExtension defines the extension to use to pick the right loader
  131447. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  131448. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131449. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131450. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  131451. * @returns the cube texture as an InternalTexture
  131452. */
  131453. 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;
  131454. private _getSamplingFilter;
  131455. private static _GetNativeTextureFormat;
  131456. createRenderTargetTexture(size: number | {
  131457. width: number;
  131458. height: number;
  131459. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  131460. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131461. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131462. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131463. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  131464. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  131465. /**
  131466. * Updates a dynamic vertex buffer.
  131467. * @param vertexBuffer the vertex buffer to update
  131468. * @param data the data used to update the vertex buffer
  131469. * @param byteOffset the byte offset of the data (optional)
  131470. * @param byteLength the byte length of the data (optional)
  131471. */
  131472. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  131473. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  131474. private _updateAnisotropicLevel;
  131475. private _getAddressMode;
  131476. /** @hidden */
  131477. _bindTexture(channel: number, texture: InternalTexture): void;
  131478. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  131479. releaseEffects(): void;
  131480. /** @hidden */
  131481. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131482. /** @hidden */
  131483. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131484. /** @hidden */
  131485. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131486. /** @hidden */
  131487. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131488. }
  131489. }
  131490. declare module BABYLON {
  131491. /**
  131492. * Gather the list of clipboard event types as constants.
  131493. */
  131494. export class ClipboardEventTypes {
  131495. /**
  131496. * The clipboard event is fired when a copy command is active (pressed).
  131497. */
  131498. static readonly COPY: number;
  131499. /**
  131500. * The clipboard event is fired when a cut command is active (pressed).
  131501. */
  131502. static readonly CUT: number;
  131503. /**
  131504. * The clipboard event is fired when a paste command is active (pressed).
  131505. */
  131506. static readonly PASTE: number;
  131507. }
  131508. /**
  131509. * This class is used to store clipboard related info for the onClipboardObservable event.
  131510. */
  131511. export class ClipboardInfo {
  131512. /**
  131513. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131514. */
  131515. type: number;
  131516. /**
  131517. * Defines the related dom event
  131518. */
  131519. event: ClipboardEvent;
  131520. /**
  131521. *Creates an instance of ClipboardInfo.
  131522. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  131523. * @param event Defines the related dom event
  131524. */
  131525. constructor(
  131526. /**
  131527. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131528. */
  131529. type: number,
  131530. /**
  131531. * Defines the related dom event
  131532. */
  131533. event: ClipboardEvent);
  131534. /**
  131535. * Get the clipboard event's type from the keycode.
  131536. * @param keyCode Defines the keyCode for the current keyboard event.
  131537. * @return {number}
  131538. */
  131539. static GetTypeFromCharacter(keyCode: number): number;
  131540. }
  131541. }
  131542. declare module BABYLON {
  131543. /**
  131544. * Google Daydream controller
  131545. */
  131546. export class DaydreamController extends WebVRController {
  131547. /**
  131548. * Base Url for the controller model.
  131549. */
  131550. static MODEL_BASE_URL: string;
  131551. /**
  131552. * File name for the controller model.
  131553. */
  131554. static MODEL_FILENAME: string;
  131555. /**
  131556. * Gamepad Id prefix used to identify Daydream Controller.
  131557. */
  131558. static readonly GAMEPAD_ID_PREFIX: string;
  131559. /**
  131560. * Creates a new DaydreamController from a gamepad
  131561. * @param vrGamepad the gamepad that the controller should be created from
  131562. */
  131563. constructor(vrGamepad: any);
  131564. /**
  131565. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131566. * @param scene scene in which to add meshes
  131567. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131568. */
  131569. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131570. /**
  131571. * Called once for each button that changed state since the last frame
  131572. * @param buttonIdx Which button index changed
  131573. * @param state New state of the button
  131574. * @param changes Which properties on the state changed since last frame
  131575. */
  131576. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131577. }
  131578. }
  131579. declare module BABYLON {
  131580. /**
  131581. * Gear VR Controller
  131582. */
  131583. export class GearVRController extends WebVRController {
  131584. /**
  131585. * Base Url for the controller model.
  131586. */
  131587. static MODEL_BASE_URL: string;
  131588. /**
  131589. * File name for the controller model.
  131590. */
  131591. static MODEL_FILENAME: string;
  131592. /**
  131593. * Gamepad Id prefix used to identify this controller.
  131594. */
  131595. static readonly GAMEPAD_ID_PREFIX: string;
  131596. private readonly _buttonIndexToObservableNameMap;
  131597. /**
  131598. * Creates a new GearVRController from a gamepad
  131599. * @param vrGamepad the gamepad that the controller should be created from
  131600. */
  131601. constructor(vrGamepad: any);
  131602. /**
  131603. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131604. * @param scene scene in which to add meshes
  131605. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131606. */
  131607. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131608. /**
  131609. * Called once for each button that changed state since the last frame
  131610. * @param buttonIdx Which button index changed
  131611. * @param state New state of the button
  131612. * @param changes Which properties on the state changed since last frame
  131613. */
  131614. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131615. }
  131616. }
  131617. declare module BABYLON {
  131618. /**
  131619. * Generic Controller
  131620. */
  131621. export class GenericController extends WebVRController {
  131622. /**
  131623. * Base Url for the controller model.
  131624. */
  131625. static readonly MODEL_BASE_URL: string;
  131626. /**
  131627. * File name for the controller model.
  131628. */
  131629. static readonly MODEL_FILENAME: string;
  131630. /**
  131631. * Creates a new GenericController from a gamepad
  131632. * @param vrGamepad the gamepad that the controller should be created from
  131633. */
  131634. constructor(vrGamepad: any);
  131635. /**
  131636. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131637. * @param scene scene in which to add meshes
  131638. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131639. */
  131640. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131641. /**
  131642. * Called once for each button that changed state since the last frame
  131643. * @param buttonIdx Which button index changed
  131644. * @param state New state of the button
  131645. * @param changes Which properties on the state changed since last frame
  131646. */
  131647. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131648. }
  131649. }
  131650. declare module BABYLON {
  131651. /**
  131652. * Oculus Touch Controller
  131653. */
  131654. export class OculusTouchController extends WebVRController {
  131655. /**
  131656. * Base Url for the controller model.
  131657. */
  131658. static MODEL_BASE_URL: string;
  131659. /**
  131660. * File name for the left controller model.
  131661. */
  131662. static MODEL_LEFT_FILENAME: string;
  131663. /**
  131664. * File name for the right controller model.
  131665. */
  131666. static MODEL_RIGHT_FILENAME: string;
  131667. /**
  131668. * Base Url for the Quest controller model.
  131669. */
  131670. static QUEST_MODEL_BASE_URL: string;
  131671. /**
  131672. * @hidden
  131673. * If the controllers are running on a device that needs the updated Quest controller models
  131674. */
  131675. static _IsQuest: boolean;
  131676. /**
  131677. * Fired when the secondary trigger on this controller is modified
  131678. */
  131679. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  131680. /**
  131681. * Fired when the thumb rest on this controller is modified
  131682. */
  131683. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  131684. /**
  131685. * Creates a new OculusTouchController from a gamepad
  131686. * @param vrGamepad the gamepad that the controller should be created from
  131687. */
  131688. constructor(vrGamepad: any);
  131689. /**
  131690. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131691. * @param scene scene in which to add meshes
  131692. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131693. */
  131694. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131695. /**
  131696. * Fired when the A button on this controller is modified
  131697. */
  131698. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131699. /**
  131700. * Fired when the B button on this controller is modified
  131701. */
  131702. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131703. /**
  131704. * Fired when the X button on this controller is modified
  131705. */
  131706. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131707. /**
  131708. * Fired when the Y button on this controller is modified
  131709. */
  131710. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131711. /**
  131712. * Called once for each button that changed state since the last frame
  131713. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  131714. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  131715. * 2) secondary trigger (same)
  131716. * 3) A (right) X (left), touch, pressed = value
  131717. * 4) B / Y
  131718. * 5) thumb rest
  131719. * @param buttonIdx Which button index changed
  131720. * @param state New state of the button
  131721. * @param changes Which properties on the state changed since last frame
  131722. */
  131723. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131724. }
  131725. }
  131726. declare module BABYLON {
  131727. /**
  131728. * Vive Controller
  131729. */
  131730. export class ViveController extends WebVRController {
  131731. /**
  131732. * Base Url for the controller model.
  131733. */
  131734. static MODEL_BASE_URL: string;
  131735. /**
  131736. * File name for the controller model.
  131737. */
  131738. static MODEL_FILENAME: string;
  131739. /**
  131740. * Creates a new ViveController from a gamepad
  131741. * @param vrGamepad the gamepad that the controller should be created from
  131742. */
  131743. constructor(vrGamepad: any);
  131744. /**
  131745. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131746. * @param scene scene in which to add meshes
  131747. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131748. */
  131749. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131750. /**
  131751. * Fired when the left button on this controller is modified
  131752. */
  131753. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131754. /**
  131755. * Fired when the right button on this controller is modified
  131756. */
  131757. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131758. /**
  131759. * Fired when the menu button on this controller is modified
  131760. */
  131761. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131762. /**
  131763. * Called once for each button that changed state since the last frame
  131764. * Vive mapping:
  131765. * 0: touchpad
  131766. * 1: trigger
  131767. * 2: left AND right buttons
  131768. * 3: menu button
  131769. * @param buttonIdx Which button index changed
  131770. * @param state New state of the button
  131771. * @param changes Which properties on the state changed since last frame
  131772. */
  131773. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131774. }
  131775. }
  131776. declare module BABYLON {
  131777. /**
  131778. * Defines the WindowsMotionController object that the state of the windows motion controller
  131779. */
  131780. export class WindowsMotionController extends WebVRController {
  131781. /**
  131782. * The base url used to load the left and right controller models
  131783. */
  131784. static MODEL_BASE_URL: string;
  131785. /**
  131786. * The name of the left controller model file
  131787. */
  131788. static MODEL_LEFT_FILENAME: string;
  131789. /**
  131790. * The name of the right controller model file
  131791. */
  131792. static MODEL_RIGHT_FILENAME: string;
  131793. /**
  131794. * The controller name prefix for this controller type
  131795. */
  131796. static readonly GAMEPAD_ID_PREFIX: string;
  131797. /**
  131798. * The controller id pattern for this controller type
  131799. */
  131800. private static readonly GAMEPAD_ID_PATTERN;
  131801. private _loadedMeshInfo;
  131802. protected readonly _mapping: {
  131803. buttons: string[];
  131804. buttonMeshNames: {
  131805. trigger: string;
  131806. menu: string;
  131807. grip: string;
  131808. thumbstick: string;
  131809. trackpad: string;
  131810. };
  131811. buttonObservableNames: {
  131812. trigger: string;
  131813. menu: string;
  131814. grip: string;
  131815. thumbstick: string;
  131816. trackpad: string;
  131817. };
  131818. axisMeshNames: string[];
  131819. pointingPoseMeshName: string;
  131820. };
  131821. /**
  131822. * Fired when the trackpad on this controller is clicked
  131823. */
  131824. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131825. /**
  131826. * Fired when the trackpad on this controller is modified
  131827. */
  131828. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131829. /**
  131830. * The current x and y values of this controller's trackpad
  131831. */
  131832. trackpad: StickValues;
  131833. /**
  131834. * Creates a new WindowsMotionController from a gamepad
  131835. * @param vrGamepad the gamepad that the controller should be created from
  131836. */
  131837. constructor(vrGamepad: any);
  131838. /**
  131839. * Fired when the trigger on this controller is modified
  131840. */
  131841. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131842. /**
  131843. * Fired when the menu button on this controller is modified
  131844. */
  131845. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131846. /**
  131847. * Fired when the grip button on this controller is modified
  131848. */
  131849. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131850. /**
  131851. * Fired when the thumbstick button on this controller is modified
  131852. */
  131853. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131854. /**
  131855. * Fired when the touchpad button on this controller is modified
  131856. */
  131857. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131858. /**
  131859. * Fired when the touchpad values on this controller are modified
  131860. */
  131861. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  131862. protected _updateTrackpad(): void;
  131863. /**
  131864. * Called once per frame by the engine.
  131865. */
  131866. update(): void;
  131867. /**
  131868. * Called once for each button that changed state since the last frame
  131869. * @param buttonIdx Which button index changed
  131870. * @param state New state of the button
  131871. * @param changes Which properties on the state changed since last frame
  131872. */
  131873. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131874. /**
  131875. * Moves the buttons on the controller mesh based on their current state
  131876. * @param buttonName the name of the button to move
  131877. * @param buttonValue the value of the button which determines the buttons new position
  131878. */
  131879. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  131880. /**
  131881. * Moves the axis on the controller mesh based on its current state
  131882. * @param axis the index of the axis
  131883. * @param axisValue the value of the axis which determines the meshes new position
  131884. * @hidden
  131885. */
  131886. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  131887. /**
  131888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131889. * @param scene scene in which to add meshes
  131890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131891. */
  131892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  131893. /**
  131894. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  131895. * can be transformed by button presses and axes values, based on this._mapping.
  131896. *
  131897. * @param scene scene in which the meshes exist
  131898. * @param meshes list of meshes that make up the controller model to process
  131899. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  131900. */
  131901. private processModel;
  131902. private createMeshInfo;
  131903. /**
  131904. * Gets the ray of the controller in the direction the controller is pointing
  131905. * @param length the length the resulting ray should be
  131906. * @returns a ray in the direction the controller is pointing
  131907. */
  131908. getForwardRay(length?: number): Ray;
  131909. /**
  131910. * Disposes of the controller
  131911. */
  131912. dispose(): void;
  131913. }
  131914. /**
  131915. * This class represents a new windows motion controller in XR.
  131916. */
  131917. export class XRWindowsMotionController extends WindowsMotionController {
  131918. /**
  131919. * Changing the original WIndowsMotionController mapping to fir the new mapping
  131920. */
  131921. protected readonly _mapping: {
  131922. buttons: string[];
  131923. buttonMeshNames: {
  131924. trigger: string;
  131925. menu: string;
  131926. grip: string;
  131927. thumbstick: string;
  131928. trackpad: string;
  131929. };
  131930. buttonObservableNames: {
  131931. trigger: string;
  131932. menu: string;
  131933. grip: string;
  131934. thumbstick: string;
  131935. trackpad: string;
  131936. };
  131937. axisMeshNames: string[];
  131938. pointingPoseMeshName: string;
  131939. };
  131940. /**
  131941. * Construct a new XR-Based windows motion controller
  131942. *
  131943. * @param gamepadInfo the gamepad object from the browser
  131944. */
  131945. constructor(gamepadInfo: any);
  131946. /**
  131947. * holds the thumbstick values (X,Y)
  131948. */
  131949. thumbstickValues: StickValues;
  131950. /**
  131951. * Fired when the thumbstick on this controller is clicked
  131952. */
  131953. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  131954. /**
  131955. * Fired when the thumbstick on this controller is modified
  131956. */
  131957. onThumbstickValuesChangedObservable: Observable<StickValues>;
  131958. /**
  131959. * Fired when the touchpad button on this controller is modified
  131960. */
  131961. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131962. /**
  131963. * Fired when the touchpad values on this controller are modified
  131964. */
  131965. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131966. /**
  131967. * Fired when the thumbstick button on this controller is modified
  131968. * here to prevent breaking changes
  131969. */
  131970. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131971. /**
  131972. * updating the thumbstick(!) and not the trackpad.
  131973. * This is named this way due to the difference between WebVR and XR and to avoid
  131974. * changing the parent class.
  131975. */
  131976. protected _updateTrackpad(): void;
  131977. /**
  131978. * Disposes the class with joy
  131979. */
  131980. dispose(): void;
  131981. }
  131982. }
  131983. declare module BABYLON {
  131984. /**
  131985. * Class containing static functions to help procedurally build meshes
  131986. */
  131987. export class PolyhedronBuilder {
  131988. /**
  131989. * Creates a polyhedron mesh
  131990. * * 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
  131991. * * The parameter `size` (positive float, default 1) sets the polygon size
  131992. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  131993. * * 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`
  131994. * * 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
  131995. * * 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)`)
  131996. * * 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
  131997. * * 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
  131998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132001. * @param name defines the name of the mesh
  132002. * @param options defines the options used to create the mesh
  132003. * @param scene defines the hosting scene
  132004. * @returns the polyhedron mesh
  132005. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132006. */
  132007. static CreatePolyhedron(name: string, options: {
  132008. type?: number;
  132009. size?: number;
  132010. sizeX?: number;
  132011. sizeY?: number;
  132012. sizeZ?: number;
  132013. custom?: any;
  132014. faceUV?: Vector4[];
  132015. faceColors?: Color4[];
  132016. flat?: boolean;
  132017. updatable?: boolean;
  132018. sideOrientation?: number;
  132019. frontUVs?: Vector4;
  132020. backUVs?: Vector4;
  132021. }, scene?: Nullable<Scene>): Mesh;
  132022. }
  132023. }
  132024. declare module BABYLON {
  132025. /**
  132026. * Gizmo that enables scaling a mesh along 3 axis
  132027. */
  132028. export class ScaleGizmo extends Gizmo {
  132029. /**
  132030. * Internal gizmo used for interactions on the x axis
  132031. */
  132032. xGizmo: AxisScaleGizmo;
  132033. /**
  132034. * Internal gizmo used for interactions on the y axis
  132035. */
  132036. yGizmo: AxisScaleGizmo;
  132037. /**
  132038. * Internal gizmo used for interactions on the z axis
  132039. */
  132040. zGizmo: AxisScaleGizmo;
  132041. /**
  132042. * Internal gizmo used to scale all axis equally
  132043. */
  132044. uniformScaleGizmo: AxisScaleGizmo;
  132045. private _meshAttached;
  132046. private _nodeAttached;
  132047. private _updateGizmoRotationToMatchAttachedMesh;
  132048. private _snapDistance;
  132049. private _scaleRatio;
  132050. private _uniformScalingMesh;
  132051. private _octahedron;
  132052. private _sensitivity;
  132053. /** Fires an event when any of it's sub gizmos are dragged */
  132054. onDragStartObservable: Observable<unknown>;
  132055. /** Fires an event when any of it's sub gizmos are released from dragging */
  132056. onDragEndObservable: Observable<unknown>;
  132057. get attachedMesh(): Nullable<AbstractMesh>;
  132058. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132059. get attachedNode(): Nullable<Node>;
  132060. set attachedNode(node: Nullable<Node>);
  132061. /**
  132062. * Creates a ScaleGizmo
  132063. * @param gizmoLayer The utility layer the gizmo will be added to
  132064. * @param thickness display gizmo axis thickness
  132065. */
  132066. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  132067. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132068. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132069. /**
  132070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132071. */
  132072. set snapDistance(value: number);
  132073. get snapDistance(): number;
  132074. /**
  132075. * Ratio for the scale of the gizmo (Default: 1)
  132076. */
  132077. set scaleRatio(value: number);
  132078. get scaleRatio(): number;
  132079. /**
  132080. * Sensitivity factor for dragging (Default: 1)
  132081. */
  132082. set sensitivity(value: number);
  132083. get sensitivity(): number;
  132084. /**
  132085. * Disposes of the gizmo
  132086. */
  132087. dispose(): void;
  132088. }
  132089. }
  132090. declare module BABYLON {
  132091. /**
  132092. * Single axis scale gizmo
  132093. */
  132094. export class AxisScaleGizmo extends Gizmo {
  132095. /**
  132096. * Drag behavior responsible for the gizmos dragging interactions
  132097. */
  132098. dragBehavior: PointerDragBehavior;
  132099. private _pointerObserver;
  132100. /**
  132101. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132102. */
  132103. snapDistance: number;
  132104. /**
  132105. * Event that fires each time the gizmo snaps to a new location.
  132106. * * snapDistance is the the change in distance
  132107. */
  132108. onSnapObservable: Observable<{
  132109. snapDistance: number;
  132110. }>;
  132111. /**
  132112. * If the scaling operation should be done on all axis (default: false)
  132113. */
  132114. uniformScaling: boolean;
  132115. /**
  132116. * Custom sensitivity value for the drag strength
  132117. */
  132118. sensitivity: number;
  132119. private _isEnabled;
  132120. private _parent;
  132121. private _arrow;
  132122. private _coloredMaterial;
  132123. private _hoverMaterial;
  132124. /**
  132125. * Creates an AxisScaleGizmo
  132126. * @param gizmoLayer The utility layer the gizmo will be added to
  132127. * @param dragAxis The axis which the gizmo will be able to scale on
  132128. * @param color The color of the gizmo
  132129. * @param thickness display gizmo axis thickness
  132130. */
  132131. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  132132. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132133. /**
  132134. * If the gizmo is enabled
  132135. */
  132136. set isEnabled(value: boolean);
  132137. get isEnabled(): boolean;
  132138. /**
  132139. * Disposes of the gizmo
  132140. */
  132141. dispose(): void;
  132142. /**
  132143. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  132144. * @param mesh The mesh to replace the default mesh of the gizmo
  132145. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  132146. */
  132147. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  132148. }
  132149. }
  132150. declare module BABYLON {
  132151. /**
  132152. * Bounding box gizmo
  132153. */
  132154. export class BoundingBoxGizmo extends Gizmo {
  132155. private _lineBoundingBox;
  132156. private _rotateSpheresParent;
  132157. private _scaleBoxesParent;
  132158. private _boundingDimensions;
  132159. private _renderObserver;
  132160. private _pointerObserver;
  132161. private _scaleDragSpeed;
  132162. private _tmpQuaternion;
  132163. private _tmpVector;
  132164. private _tmpRotationMatrix;
  132165. /**
  132166. * 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)
  132167. */
  132168. ignoreChildren: boolean;
  132169. /**
  132170. * 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)
  132171. */
  132172. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  132173. /**
  132174. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  132175. */
  132176. rotationSphereSize: number;
  132177. /**
  132178. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  132179. */
  132180. scaleBoxSize: number;
  132181. /**
  132182. * 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)
  132183. */
  132184. fixedDragMeshScreenSize: boolean;
  132185. /**
  132186. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  132187. */
  132188. fixedDragMeshScreenSizeDistanceFactor: number;
  132189. /**
  132190. * Fired when a rotation sphere or scale box is dragged
  132191. */
  132192. onDragStartObservable: Observable<{}>;
  132193. /**
  132194. * Fired when a scale box is dragged
  132195. */
  132196. onScaleBoxDragObservable: Observable<{}>;
  132197. /**
  132198. * Fired when a scale box drag is ended
  132199. */
  132200. onScaleBoxDragEndObservable: Observable<{}>;
  132201. /**
  132202. * Fired when a rotation sphere is dragged
  132203. */
  132204. onRotationSphereDragObservable: Observable<{}>;
  132205. /**
  132206. * Fired when a rotation sphere drag is ended
  132207. */
  132208. onRotationSphereDragEndObservable: Observable<{}>;
  132209. /**
  132210. * 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)
  132211. */
  132212. scalePivot: Nullable<Vector3>;
  132213. /**
  132214. * Mesh used as a pivot to rotate the attached node
  132215. */
  132216. private _anchorMesh;
  132217. private _existingMeshScale;
  132218. private _dragMesh;
  132219. private pointerDragBehavior;
  132220. private coloredMaterial;
  132221. private hoverColoredMaterial;
  132222. /**
  132223. * Sets the color of the bounding box gizmo
  132224. * @param color the color to set
  132225. */
  132226. setColor(color: Color3): void;
  132227. /**
  132228. * Creates an BoundingBoxGizmo
  132229. * @param gizmoLayer The utility layer the gizmo will be added to
  132230. * @param color The color of the gizmo
  132231. */
  132232. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  132233. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  132234. private _selectNode;
  132235. /**
  132236. * Updates the bounding box information for the Gizmo
  132237. */
  132238. updateBoundingBox(): void;
  132239. private _updateRotationSpheres;
  132240. private _updateScaleBoxes;
  132241. /**
  132242. * Enables rotation on the specified axis and disables rotation on the others
  132243. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  132244. */
  132245. setEnabledRotationAxis(axis: string): void;
  132246. /**
  132247. * Enables/disables scaling
  132248. * @param enable if scaling should be enabled
  132249. * @param homogeneousScaling defines if scaling should only be homogeneous
  132250. */
  132251. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  132252. private _updateDummy;
  132253. /**
  132254. * Enables a pointer drag behavior on the bounding box of the gizmo
  132255. */
  132256. enableDragBehavior(): void;
  132257. /**
  132258. * Disposes of the gizmo
  132259. */
  132260. dispose(): void;
  132261. /**
  132262. * 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)
  132263. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  132264. * @returns the bounding box mesh with the passed in mesh as a child
  132265. */
  132266. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  132267. /**
  132268. * CustomMeshes are not supported by this gizmo
  132269. * @param mesh The mesh to replace the default mesh of the gizmo
  132270. */
  132271. setCustomMesh(mesh: Mesh): void;
  132272. }
  132273. }
  132274. declare module BABYLON {
  132275. /**
  132276. * Single plane rotation gizmo
  132277. */
  132278. export class PlaneRotationGizmo extends Gizmo {
  132279. /**
  132280. * Drag behavior responsible for the gizmos dragging interactions
  132281. */
  132282. dragBehavior: PointerDragBehavior;
  132283. private _pointerObserver;
  132284. /**
  132285. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  132286. */
  132287. snapDistance: number;
  132288. /**
  132289. * Event that fires each time the gizmo snaps to a new location.
  132290. * * snapDistance is the the change in distance
  132291. */
  132292. onSnapObservable: Observable<{
  132293. snapDistance: number;
  132294. }>;
  132295. private _isEnabled;
  132296. private _parent;
  132297. /**
  132298. * Creates a PlaneRotationGizmo
  132299. * @param gizmoLayer The utility layer the gizmo will be added to
  132300. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  132301. * @param color The color of the gizmo
  132302. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132303. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132304. * @param thickness display gizmo axis thickness
  132305. */
  132306. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  132307. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132308. /**
  132309. * If the gizmo is enabled
  132310. */
  132311. set isEnabled(value: boolean);
  132312. get isEnabled(): boolean;
  132313. /**
  132314. * Disposes of the gizmo
  132315. */
  132316. dispose(): void;
  132317. }
  132318. }
  132319. declare module BABYLON {
  132320. /**
  132321. * Gizmo that enables rotating a mesh along 3 axis
  132322. */
  132323. export class RotationGizmo extends Gizmo {
  132324. /**
  132325. * Internal gizmo used for interactions on the x axis
  132326. */
  132327. xGizmo: PlaneRotationGizmo;
  132328. /**
  132329. * Internal gizmo used for interactions on the y axis
  132330. */
  132331. yGizmo: PlaneRotationGizmo;
  132332. /**
  132333. * Internal gizmo used for interactions on the z axis
  132334. */
  132335. zGizmo: PlaneRotationGizmo;
  132336. /** Fires an event when any of it's sub gizmos are dragged */
  132337. onDragStartObservable: Observable<unknown>;
  132338. /** Fires an event when any of it's sub gizmos are released from dragging */
  132339. onDragEndObservable: Observable<unknown>;
  132340. private _meshAttached;
  132341. private _nodeAttached;
  132342. get attachedMesh(): Nullable<AbstractMesh>;
  132343. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132344. get attachedNode(): Nullable<Node>;
  132345. set attachedNode(node: Nullable<Node>);
  132346. /**
  132347. * Creates a RotationGizmo
  132348. * @param gizmoLayer The utility layer the gizmo will be added to
  132349. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132350. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132351. * @param thickness display gizmo axis thickness
  132352. */
  132353. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  132354. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132355. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132356. /**
  132357. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132358. */
  132359. set snapDistance(value: number);
  132360. get snapDistance(): number;
  132361. /**
  132362. * Ratio for the scale of the gizmo (Default: 1)
  132363. */
  132364. set scaleRatio(value: number);
  132365. get scaleRatio(): number;
  132366. /**
  132367. * Disposes of the gizmo
  132368. */
  132369. dispose(): void;
  132370. /**
  132371. * CustomMeshes are not supported by this gizmo
  132372. * @param mesh The mesh to replace the default mesh of the gizmo
  132373. */
  132374. setCustomMesh(mesh: Mesh): void;
  132375. }
  132376. }
  132377. declare module BABYLON {
  132378. /**
  132379. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  132380. */
  132381. export class GizmoManager implements IDisposable {
  132382. private scene;
  132383. /**
  132384. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  132385. */
  132386. gizmos: {
  132387. positionGizmo: Nullable<PositionGizmo>;
  132388. rotationGizmo: Nullable<RotationGizmo>;
  132389. scaleGizmo: Nullable<ScaleGizmo>;
  132390. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  132391. };
  132392. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  132393. clearGizmoOnEmptyPointerEvent: boolean;
  132394. /** Fires an event when the manager is attached to a mesh */
  132395. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  132396. private _gizmosEnabled;
  132397. private _pointerObserver;
  132398. private _attachedMesh;
  132399. private _boundingBoxColor;
  132400. private _defaultUtilityLayer;
  132401. private _defaultKeepDepthUtilityLayer;
  132402. private _thickness;
  132403. /**
  132404. * When bounding box gizmo is enabled, this can be used to track drag/end events
  132405. */
  132406. boundingBoxDragBehavior: SixDofDragBehavior;
  132407. /**
  132408. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  132409. */
  132410. attachableMeshes: Nullable<Array<AbstractMesh>>;
  132411. /**
  132412. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  132413. */
  132414. usePointerToAttachGizmos: boolean;
  132415. /**
  132416. * Utility layer that the bounding box gizmo belongs to
  132417. */
  132418. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  132419. /**
  132420. * Utility layer that all gizmos besides bounding box belong to
  132421. */
  132422. get utilityLayer(): UtilityLayerRenderer;
  132423. /**
  132424. * Instatiates a gizmo manager
  132425. * @param scene the scene to overlay the gizmos on top of
  132426. * @param thickness display gizmo axis thickness
  132427. */
  132428. constructor(scene: Scene, thickness?: number);
  132429. /**
  132430. * Attaches a set of gizmos to the specified mesh
  132431. * @param mesh The mesh the gizmo's should be attached to
  132432. */
  132433. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132434. /**
  132435. * If the position gizmo is enabled
  132436. */
  132437. set positionGizmoEnabled(value: boolean);
  132438. get positionGizmoEnabled(): boolean;
  132439. /**
  132440. * If the rotation gizmo is enabled
  132441. */
  132442. set rotationGizmoEnabled(value: boolean);
  132443. get rotationGizmoEnabled(): boolean;
  132444. /**
  132445. * If the scale gizmo is enabled
  132446. */
  132447. set scaleGizmoEnabled(value: boolean);
  132448. get scaleGizmoEnabled(): boolean;
  132449. /**
  132450. * If the boundingBox gizmo is enabled
  132451. */
  132452. set boundingBoxGizmoEnabled(value: boolean);
  132453. get boundingBoxGizmoEnabled(): boolean;
  132454. /**
  132455. * Disposes of the gizmo manager
  132456. */
  132457. dispose(): void;
  132458. }
  132459. }
  132460. declare module BABYLON {
  132461. /**
  132462. * A directional light is defined by a direction (what a surprise!).
  132463. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  132464. * 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.
  132465. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132466. */
  132467. export class DirectionalLight extends ShadowLight {
  132468. private _shadowFrustumSize;
  132469. /**
  132470. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  132471. */
  132472. get shadowFrustumSize(): number;
  132473. /**
  132474. * Specifies a fix frustum size for the shadow generation.
  132475. */
  132476. set shadowFrustumSize(value: number);
  132477. private _shadowOrthoScale;
  132478. /**
  132479. * Gets the shadow projection scale against the optimal computed one.
  132480. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132481. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132482. */
  132483. get shadowOrthoScale(): number;
  132484. /**
  132485. * Sets the shadow projection scale against the optimal computed one.
  132486. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132487. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132488. */
  132489. set shadowOrthoScale(value: number);
  132490. /**
  132491. * Automatically compute the projection matrix to best fit (including all the casters)
  132492. * on each frame.
  132493. */
  132494. autoUpdateExtends: boolean;
  132495. /**
  132496. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  132497. * on each frame. autoUpdateExtends must be set to true for this to work
  132498. */
  132499. autoCalcShadowZBounds: boolean;
  132500. private _orthoLeft;
  132501. private _orthoRight;
  132502. private _orthoTop;
  132503. private _orthoBottom;
  132504. /**
  132505. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  132506. * The directional light is emitted from everywhere in the given direction.
  132507. * It can cast shadows.
  132508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132509. * @param name The friendly name of the light
  132510. * @param direction The direction of the light
  132511. * @param scene The scene the light belongs to
  132512. */
  132513. constructor(name: string, direction: Vector3, scene: Scene);
  132514. /**
  132515. * Returns the string "DirectionalLight".
  132516. * @return The class name
  132517. */
  132518. getClassName(): string;
  132519. /**
  132520. * Returns the integer 1.
  132521. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132522. */
  132523. getTypeID(): number;
  132524. /**
  132525. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132529. /**
  132530. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  132531. * Returns the DirectionalLight Shadow projection matrix.
  132532. */
  132533. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  132534. /**
  132535. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  132536. * Returns the DirectionalLight Shadow projection matrix.
  132537. */
  132538. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132539. protected _buildUniformLayout(): void;
  132540. /**
  132541. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  132542. * @param effect The effect to update
  132543. * @param lightIndex The index of the light in the effect to update
  132544. * @returns The directional light
  132545. */
  132546. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  132547. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  132548. /**
  132549. * Gets the minZ used for shadow according to both the scene and the light.
  132550. *
  132551. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132552. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132553. * @param activeCamera The camera we are returning the min for
  132554. * @returns the depth min z
  132555. */
  132556. getDepthMinZ(activeCamera: Camera): number;
  132557. /**
  132558. * Gets the maxZ used for shadow according to both the scene and the light.
  132559. *
  132560. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132561. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132562. * @param activeCamera The camera we are returning the max for
  132563. * @returns the depth max z
  132564. */
  132565. getDepthMaxZ(activeCamera: Camera): number;
  132566. /**
  132567. * Prepares the list of defines specific to the light type.
  132568. * @param defines the list of defines
  132569. * @param lightIndex defines the index of the light for the effect
  132570. */
  132571. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132572. }
  132573. }
  132574. declare module BABYLON {
  132575. /**
  132576. * Class containing static functions to help procedurally build meshes
  132577. */
  132578. export class HemisphereBuilder {
  132579. /**
  132580. * Creates a hemisphere mesh
  132581. * @param name defines the name of the mesh
  132582. * @param options defines the options used to create the mesh
  132583. * @param scene defines the hosting scene
  132584. * @returns the hemisphere mesh
  132585. */
  132586. static CreateHemisphere(name: string, options: {
  132587. segments?: number;
  132588. diameter?: number;
  132589. sideOrientation?: number;
  132590. }, scene: any): Mesh;
  132591. }
  132592. }
  132593. declare module BABYLON {
  132594. /**
  132595. * A spot light is defined by a position, a direction, an angle, and an exponent.
  132596. * These values define a cone of light starting from the position, emitting toward the direction.
  132597. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  132598. * and the exponent defines the speed of the decay of the light with distance (reach).
  132599. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132600. */
  132601. export class SpotLight extends ShadowLight {
  132602. private _angle;
  132603. private _innerAngle;
  132604. private _cosHalfAngle;
  132605. private _lightAngleScale;
  132606. private _lightAngleOffset;
  132607. /**
  132608. * Gets the cone angle of the spot light in Radians.
  132609. */
  132610. get angle(): number;
  132611. /**
  132612. * Sets the cone angle of the spot light in Radians.
  132613. */
  132614. set angle(value: number);
  132615. /**
  132616. * Only used in gltf falloff mode, this defines the angle where
  132617. * the directional falloff will start before cutting at angle which could be seen
  132618. * as outer angle.
  132619. */
  132620. get innerAngle(): number;
  132621. /**
  132622. * Only used in gltf falloff mode, this defines the angle where
  132623. * the directional falloff will start before cutting at angle which could be seen
  132624. * as outer angle.
  132625. */
  132626. set innerAngle(value: number);
  132627. private _shadowAngleScale;
  132628. /**
  132629. * Allows scaling the angle of the light for shadow generation only.
  132630. */
  132631. get shadowAngleScale(): number;
  132632. /**
  132633. * Allows scaling the angle of the light for shadow generation only.
  132634. */
  132635. set shadowAngleScale(value: number);
  132636. /**
  132637. * The light decay speed with the distance from the emission spot.
  132638. */
  132639. exponent: number;
  132640. private _projectionTextureMatrix;
  132641. /**
  132642. * Allows reading the projecton texture
  132643. */
  132644. get projectionTextureMatrix(): Matrix;
  132645. protected _projectionTextureLightNear: number;
  132646. /**
  132647. * Gets the near clip of the Spotlight for texture projection.
  132648. */
  132649. get projectionTextureLightNear(): number;
  132650. /**
  132651. * Sets the near clip of the Spotlight for texture projection.
  132652. */
  132653. set projectionTextureLightNear(value: number);
  132654. protected _projectionTextureLightFar: number;
  132655. /**
  132656. * Gets the far clip of the Spotlight for texture projection.
  132657. */
  132658. get projectionTextureLightFar(): number;
  132659. /**
  132660. * Sets the far clip of the Spotlight for texture projection.
  132661. */
  132662. set projectionTextureLightFar(value: number);
  132663. protected _projectionTextureUpDirection: Vector3;
  132664. /**
  132665. * Gets the Up vector of the Spotlight for texture projection.
  132666. */
  132667. get projectionTextureUpDirection(): Vector3;
  132668. /**
  132669. * Sets the Up vector of the Spotlight for texture projection.
  132670. */
  132671. set projectionTextureUpDirection(value: Vector3);
  132672. private _projectionTexture;
  132673. /**
  132674. * Gets the projection texture of the light.
  132675. */
  132676. get projectionTexture(): Nullable<BaseTexture>;
  132677. /**
  132678. * Sets the projection texture of the light.
  132679. */
  132680. set projectionTexture(value: Nullable<BaseTexture>);
  132681. private _projectionTextureViewLightDirty;
  132682. private _projectionTextureProjectionLightDirty;
  132683. private _projectionTextureDirty;
  132684. private _projectionTextureViewTargetVector;
  132685. private _projectionTextureViewLightMatrix;
  132686. private _projectionTextureProjectionLightMatrix;
  132687. private _projectionTextureScalingMatrix;
  132688. /**
  132689. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  132690. * It can cast shadows.
  132691. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132692. * @param name The light friendly name
  132693. * @param position The position of the spot light in the scene
  132694. * @param direction The direction of the light in the scene
  132695. * @param angle The cone angle of the light in Radians
  132696. * @param exponent The light decay speed with the distance from the emission spot
  132697. * @param scene The scene the lights belongs to
  132698. */
  132699. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  132700. /**
  132701. * Returns the string "SpotLight".
  132702. * @returns the class name
  132703. */
  132704. getClassName(): string;
  132705. /**
  132706. * Returns the integer 2.
  132707. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132708. */
  132709. getTypeID(): number;
  132710. /**
  132711. * Overrides the direction setter to recompute the projection texture view light Matrix.
  132712. */
  132713. protected _setDirection(value: Vector3): void;
  132714. /**
  132715. * Overrides the position setter to recompute the projection texture view light Matrix.
  132716. */
  132717. protected _setPosition(value: Vector3): void;
  132718. /**
  132719. * 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.
  132720. * Returns the SpotLight.
  132721. */
  132722. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132723. protected _computeProjectionTextureViewLightMatrix(): void;
  132724. protected _computeProjectionTextureProjectionLightMatrix(): void;
  132725. /**
  132726. * Main function for light texture projection matrix computing.
  132727. */
  132728. protected _computeProjectionTextureMatrix(): void;
  132729. protected _buildUniformLayout(): void;
  132730. private _computeAngleValues;
  132731. /**
  132732. * Sets the passed Effect "effect" with the Light textures.
  132733. * @param effect The effect to update
  132734. * @param lightIndex The index of the light in the effect to update
  132735. * @returns The light
  132736. */
  132737. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  132738. /**
  132739. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  132740. * @param effect The effect to update
  132741. * @param lightIndex The index of the light in the effect to update
  132742. * @returns The spot light
  132743. */
  132744. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  132745. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  132746. /**
  132747. * Disposes the light and the associated resources.
  132748. */
  132749. dispose(): void;
  132750. /**
  132751. * Prepares the list of defines specific to the light type.
  132752. * @param defines the list of defines
  132753. * @param lightIndex defines the index of the light for the effect
  132754. */
  132755. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132756. }
  132757. }
  132758. declare module BABYLON {
  132759. /**
  132760. * Gizmo that enables viewing a light
  132761. */
  132762. export class LightGizmo extends Gizmo {
  132763. private _lightMesh;
  132764. private _material;
  132765. private _cachedPosition;
  132766. private _cachedForward;
  132767. private _attachedMeshParent;
  132768. /**
  132769. * Creates a LightGizmo
  132770. * @param gizmoLayer The utility layer the gizmo will be added to
  132771. */
  132772. constructor(gizmoLayer?: UtilityLayerRenderer);
  132773. private _light;
  132774. /**
  132775. * The light that the gizmo is attached to
  132776. */
  132777. set light(light: Nullable<Light>);
  132778. get light(): Nullable<Light>;
  132779. /**
  132780. * Gets the material used to render the light gizmo
  132781. */
  132782. get material(): StandardMaterial;
  132783. /**
  132784. * @hidden
  132785. * Updates the gizmo to match the attached mesh's position/rotation
  132786. */
  132787. protected _update(): void;
  132788. private static _Scale;
  132789. /**
  132790. * Creates the lines for a light mesh
  132791. */
  132792. private static _CreateLightLines;
  132793. /**
  132794. * Disposes of the light gizmo
  132795. */
  132796. dispose(): void;
  132797. private static _CreateHemisphericLightMesh;
  132798. private static _CreatePointLightMesh;
  132799. private static _CreateSpotLightMesh;
  132800. private static _CreateDirectionalLightMesh;
  132801. }
  132802. }
  132803. declare module BABYLON {
  132804. /** @hidden */
  132805. export var backgroundFragmentDeclaration: {
  132806. name: string;
  132807. shader: string;
  132808. };
  132809. }
  132810. declare module BABYLON {
  132811. /** @hidden */
  132812. export var backgroundUboDeclaration: {
  132813. name: string;
  132814. shader: string;
  132815. };
  132816. }
  132817. declare module BABYLON {
  132818. /** @hidden */
  132819. export var backgroundPixelShader: {
  132820. name: string;
  132821. shader: string;
  132822. };
  132823. }
  132824. declare module BABYLON {
  132825. /** @hidden */
  132826. export var backgroundVertexDeclaration: {
  132827. name: string;
  132828. shader: string;
  132829. };
  132830. }
  132831. declare module BABYLON {
  132832. /** @hidden */
  132833. export var backgroundVertexShader: {
  132834. name: string;
  132835. shader: string;
  132836. };
  132837. }
  132838. declare module BABYLON {
  132839. /**
  132840. * Background material used to create an efficient environement around your scene.
  132841. */
  132842. export class BackgroundMaterial extends PushMaterial {
  132843. /**
  132844. * Standard reflectance value at parallel view angle.
  132845. */
  132846. static StandardReflectance0: number;
  132847. /**
  132848. * Standard reflectance value at grazing angle.
  132849. */
  132850. static StandardReflectance90: number;
  132851. protected _primaryColor: Color3;
  132852. /**
  132853. * Key light Color (multiply against the environement texture)
  132854. */
  132855. primaryColor: Color3;
  132856. protected __perceptualColor: Nullable<Color3>;
  132857. /**
  132858. * Experimental Internal Use Only.
  132859. *
  132860. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  132861. * This acts as a helper to set the primary color to a more "human friendly" value.
  132862. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  132863. * output color as close as possible from the chosen value.
  132864. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  132865. * part of lighting setup.)
  132866. */
  132867. get _perceptualColor(): Nullable<Color3>;
  132868. set _perceptualColor(value: Nullable<Color3>);
  132869. protected _primaryColorShadowLevel: float;
  132870. /**
  132871. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  132872. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  132873. */
  132874. get primaryColorShadowLevel(): float;
  132875. set primaryColorShadowLevel(value: float);
  132876. protected _primaryColorHighlightLevel: float;
  132877. /**
  132878. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  132879. * The primary color is used at the level chosen to define what the white area would look.
  132880. */
  132881. get primaryColorHighlightLevel(): float;
  132882. set primaryColorHighlightLevel(value: float);
  132883. protected _reflectionTexture: Nullable<BaseTexture>;
  132884. /**
  132885. * Reflection Texture used in the material.
  132886. * Should be author in a specific way for the best result (refer to the documentation).
  132887. */
  132888. reflectionTexture: Nullable<BaseTexture>;
  132889. protected _reflectionBlur: float;
  132890. /**
  132891. * Reflection Texture level of blur.
  132892. *
  132893. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  132894. * texture twice.
  132895. */
  132896. reflectionBlur: float;
  132897. protected _diffuseTexture: Nullable<BaseTexture>;
  132898. /**
  132899. * Diffuse Texture used in the material.
  132900. * Should be author in a specific way for the best result (refer to the documentation).
  132901. */
  132902. diffuseTexture: Nullable<BaseTexture>;
  132903. protected _shadowLights: Nullable<IShadowLight[]>;
  132904. /**
  132905. * Specify the list of lights casting shadow on the material.
  132906. * All scene shadow lights will be included if null.
  132907. */
  132908. shadowLights: Nullable<IShadowLight[]>;
  132909. protected _shadowLevel: float;
  132910. /**
  132911. * Helps adjusting the shadow to a softer level if required.
  132912. * 0 means black shadows and 1 means no shadows.
  132913. */
  132914. shadowLevel: float;
  132915. protected _sceneCenter: Vector3;
  132916. /**
  132917. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  132918. * It is usually zero but might be interesting to modify according to your setup.
  132919. */
  132920. sceneCenter: Vector3;
  132921. protected _opacityFresnel: boolean;
  132922. /**
  132923. * This helps specifying that the material is falling off to the sky box at grazing angle.
  132924. * This helps ensuring a nice transition when the camera goes under the ground.
  132925. */
  132926. opacityFresnel: boolean;
  132927. protected _reflectionFresnel: boolean;
  132928. /**
  132929. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  132930. * This helps adding a mirror texture on the ground.
  132931. */
  132932. reflectionFresnel: boolean;
  132933. protected _reflectionFalloffDistance: number;
  132934. /**
  132935. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  132936. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  132937. */
  132938. reflectionFalloffDistance: number;
  132939. protected _reflectionAmount: number;
  132940. /**
  132941. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  132942. */
  132943. reflectionAmount: number;
  132944. protected _reflectionReflectance0: number;
  132945. /**
  132946. * This specifies the weight of the reflection at grazing angle.
  132947. */
  132948. reflectionReflectance0: number;
  132949. protected _reflectionReflectance90: number;
  132950. /**
  132951. * This specifies the weight of the reflection at a perpendicular point of view.
  132952. */
  132953. reflectionReflectance90: number;
  132954. /**
  132955. * Sets the reflection reflectance fresnel values according to the default standard
  132956. * empirically know to work well :-)
  132957. */
  132958. set reflectionStandardFresnelWeight(value: number);
  132959. protected _useRGBColor: boolean;
  132960. /**
  132961. * Helps to directly use the maps channels instead of their level.
  132962. */
  132963. useRGBColor: boolean;
  132964. protected _enableNoise: boolean;
  132965. /**
  132966. * This helps reducing the banding effect that could occur on the background.
  132967. */
  132968. enableNoise: boolean;
  132969. /**
  132970. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132971. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  132972. * Recommended to be keep at 1.0 except for special cases.
  132973. */
  132974. get fovMultiplier(): number;
  132975. set fovMultiplier(value: number);
  132976. private _fovMultiplier;
  132977. /**
  132978. * Enable the FOV adjustment feature controlled by fovMultiplier.
  132979. */
  132980. useEquirectangularFOV: boolean;
  132981. private _maxSimultaneousLights;
  132982. /**
  132983. * Number of Simultaneous lights allowed on the material.
  132984. */
  132985. maxSimultaneousLights: int;
  132986. private _shadowOnly;
  132987. /**
  132988. * Make the material only render shadows
  132989. */
  132990. shadowOnly: boolean;
  132991. /**
  132992. * Default configuration related to image processing available in the Background Material.
  132993. */
  132994. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132995. /**
  132996. * Keep track of the image processing observer to allow dispose and replace.
  132997. */
  132998. private _imageProcessingObserver;
  132999. /**
  133000. * Attaches a new image processing configuration to the PBR Material.
  133001. * @param configuration (if null the scene configuration will be use)
  133002. */
  133003. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133004. /**
  133005. * Gets the image processing configuration used either in this material.
  133006. */
  133007. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  133008. /**
  133009. * Sets the Default image processing configuration used either in the this material.
  133010. *
  133011. * If sets to null, the scene one is in use.
  133012. */
  133013. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  133014. /**
  133015. * Gets wether the color curves effect is enabled.
  133016. */
  133017. get cameraColorCurvesEnabled(): boolean;
  133018. /**
  133019. * Sets wether the color curves effect is enabled.
  133020. */
  133021. set cameraColorCurvesEnabled(value: boolean);
  133022. /**
  133023. * Gets wether the color grading effect is enabled.
  133024. */
  133025. get cameraColorGradingEnabled(): boolean;
  133026. /**
  133027. * Gets wether the color grading effect is enabled.
  133028. */
  133029. set cameraColorGradingEnabled(value: boolean);
  133030. /**
  133031. * Gets wether tonemapping is enabled or not.
  133032. */
  133033. get cameraToneMappingEnabled(): boolean;
  133034. /**
  133035. * Sets wether tonemapping is enabled or not
  133036. */
  133037. set cameraToneMappingEnabled(value: boolean);
  133038. /**
  133039. * The camera exposure used on this material.
  133040. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133041. * This corresponds to a photographic exposure.
  133042. */
  133043. get cameraExposure(): float;
  133044. /**
  133045. * The camera exposure used on this material.
  133046. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133047. * This corresponds to a photographic exposure.
  133048. */
  133049. set cameraExposure(value: float);
  133050. /**
  133051. * Gets The camera contrast used on this material.
  133052. */
  133053. get cameraContrast(): float;
  133054. /**
  133055. * Sets The camera contrast used on this material.
  133056. */
  133057. set cameraContrast(value: float);
  133058. /**
  133059. * Gets the Color Grading 2D Lookup Texture.
  133060. */
  133061. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133062. /**
  133063. * Sets the Color Grading 2D Lookup Texture.
  133064. */
  133065. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133066. /**
  133067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133069. * 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;
  133070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133071. */
  133072. get cameraColorCurves(): Nullable<ColorCurves>;
  133073. /**
  133074. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133075. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133076. * 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;
  133077. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133078. */
  133079. set cameraColorCurves(value: Nullable<ColorCurves>);
  133080. /**
  133081. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  133082. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  133083. */
  133084. switchToBGR: boolean;
  133085. private _renderTargets;
  133086. private _reflectionControls;
  133087. private _white;
  133088. private _primaryShadowColor;
  133089. private _primaryHighlightColor;
  133090. /**
  133091. * Instantiates a Background Material in the given scene
  133092. * @param name The friendly name of the material
  133093. * @param scene The scene to add the material to
  133094. */
  133095. constructor(name: string, scene: Scene);
  133096. /**
  133097. * Gets a boolean indicating that current material needs to register RTT
  133098. */
  133099. get hasRenderTargetTextures(): boolean;
  133100. /**
  133101. * The entire material has been created in order to prevent overdraw.
  133102. * @returns false
  133103. */
  133104. needAlphaTesting(): boolean;
  133105. /**
  133106. * The entire material has been created in order to prevent overdraw.
  133107. * @returns true if blending is enable
  133108. */
  133109. needAlphaBlending(): boolean;
  133110. /**
  133111. * Checks wether the material is ready to be rendered for a given mesh.
  133112. * @param mesh The mesh to render
  133113. * @param subMesh The submesh to check against
  133114. * @param useInstances Specify wether or not the material is used with instances
  133115. * @returns true if all the dependencies are ready (Textures, Effects...)
  133116. */
  133117. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133118. /**
  133119. * Compute the primary color according to the chosen perceptual color.
  133120. */
  133121. private _computePrimaryColorFromPerceptualColor;
  133122. /**
  133123. * Compute the highlights and shadow colors according to their chosen levels.
  133124. */
  133125. private _computePrimaryColors;
  133126. /**
  133127. * Build the uniform buffer used in the material.
  133128. */
  133129. buildUniformLayout(): void;
  133130. /**
  133131. * Unbind the material.
  133132. */
  133133. unbind(): void;
  133134. /**
  133135. * Bind only the world matrix to the material.
  133136. * @param world The world matrix to bind.
  133137. */
  133138. bindOnlyWorldMatrix(world: Matrix): void;
  133139. /**
  133140. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  133141. * @param world The world matrix to bind.
  133142. * @param subMesh The submesh to bind for.
  133143. */
  133144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133145. /**
  133146. * Checks to see if a texture is used in the material.
  133147. * @param texture - Base texture to use.
  133148. * @returns - Boolean specifying if a texture is used in the material.
  133149. */
  133150. hasTexture(texture: BaseTexture): boolean;
  133151. /**
  133152. * Dispose the material.
  133153. * @param forceDisposeEffect Force disposal of the associated effect.
  133154. * @param forceDisposeTextures Force disposal of the associated textures.
  133155. */
  133156. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133157. /**
  133158. * Clones the material.
  133159. * @param name The cloned name.
  133160. * @returns The cloned material.
  133161. */
  133162. clone(name: string): BackgroundMaterial;
  133163. /**
  133164. * Serializes the current material to its JSON representation.
  133165. * @returns The JSON representation.
  133166. */
  133167. serialize(): any;
  133168. /**
  133169. * Gets the class name of the material
  133170. * @returns "BackgroundMaterial"
  133171. */
  133172. getClassName(): string;
  133173. /**
  133174. * Parse a JSON input to create back a background material.
  133175. * @param source The JSON data to parse
  133176. * @param scene The scene to create the parsed material in
  133177. * @param rootUrl The root url of the assets the material depends upon
  133178. * @returns the instantiated BackgroundMaterial.
  133179. */
  133180. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  133181. }
  133182. }
  133183. declare module BABYLON {
  133184. /**
  133185. * Represents the different options available during the creation of
  133186. * a Environment helper.
  133187. *
  133188. * This can control the default ground, skybox and image processing setup of your scene.
  133189. */
  133190. export interface IEnvironmentHelperOptions {
  133191. /**
  133192. * Specifies whether or not to create a ground.
  133193. * True by default.
  133194. */
  133195. createGround: boolean;
  133196. /**
  133197. * Specifies the ground size.
  133198. * 15 by default.
  133199. */
  133200. groundSize: number;
  133201. /**
  133202. * The texture used on the ground for the main color.
  133203. * Comes from the BabylonJS CDN by default.
  133204. *
  133205. * Remarks: Can be either a texture or a url.
  133206. */
  133207. groundTexture: string | BaseTexture;
  133208. /**
  133209. * The color mixed in the ground texture by default.
  133210. * BabylonJS clearColor by default.
  133211. */
  133212. groundColor: Color3;
  133213. /**
  133214. * Specifies the ground opacity.
  133215. * 1 by default.
  133216. */
  133217. groundOpacity: number;
  133218. /**
  133219. * Enables the ground to receive shadows.
  133220. * True by default.
  133221. */
  133222. enableGroundShadow: boolean;
  133223. /**
  133224. * Helps preventing the shadow to be fully black on the ground.
  133225. * 0.5 by default.
  133226. */
  133227. groundShadowLevel: number;
  133228. /**
  133229. * Creates a mirror texture attach to the ground.
  133230. * false by default.
  133231. */
  133232. enableGroundMirror: boolean;
  133233. /**
  133234. * Specifies the ground mirror size ratio.
  133235. * 0.3 by default as the default kernel is 64.
  133236. */
  133237. groundMirrorSizeRatio: number;
  133238. /**
  133239. * Specifies the ground mirror blur kernel size.
  133240. * 64 by default.
  133241. */
  133242. groundMirrorBlurKernel: number;
  133243. /**
  133244. * Specifies the ground mirror visibility amount.
  133245. * 1 by default
  133246. */
  133247. groundMirrorAmount: number;
  133248. /**
  133249. * Specifies the ground mirror reflectance weight.
  133250. * This uses the standard weight of the background material to setup the fresnel effect
  133251. * of the mirror.
  133252. * 1 by default.
  133253. */
  133254. groundMirrorFresnelWeight: number;
  133255. /**
  133256. * Specifies the ground mirror Falloff distance.
  133257. * This can helps reducing the size of the reflection.
  133258. * 0 by Default.
  133259. */
  133260. groundMirrorFallOffDistance: number;
  133261. /**
  133262. * Specifies the ground mirror texture type.
  133263. * Unsigned Int by Default.
  133264. */
  133265. groundMirrorTextureType: number;
  133266. /**
  133267. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  133268. * the shown objects.
  133269. */
  133270. groundYBias: number;
  133271. /**
  133272. * Specifies whether or not to create a skybox.
  133273. * True by default.
  133274. */
  133275. createSkybox: boolean;
  133276. /**
  133277. * Specifies the skybox size.
  133278. * 20 by default.
  133279. */
  133280. skyboxSize: number;
  133281. /**
  133282. * The texture used on the skybox for the main color.
  133283. * Comes from the BabylonJS CDN by default.
  133284. *
  133285. * Remarks: Can be either a texture or a url.
  133286. */
  133287. skyboxTexture: string | BaseTexture;
  133288. /**
  133289. * The color mixed in the skybox texture by default.
  133290. * BabylonJS clearColor by default.
  133291. */
  133292. skyboxColor: Color3;
  133293. /**
  133294. * The background rotation around the Y axis of the scene.
  133295. * This helps aligning the key lights of your scene with the background.
  133296. * 0 by default.
  133297. */
  133298. backgroundYRotation: number;
  133299. /**
  133300. * Compute automatically the size of the elements to best fit with the scene.
  133301. */
  133302. sizeAuto: boolean;
  133303. /**
  133304. * Default position of the rootMesh if autoSize is not true.
  133305. */
  133306. rootPosition: Vector3;
  133307. /**
  133308. * Sets up the image processing in the scene.
  133309. * true by default.
  133310. */
  133311. setupImageProcessing: boolean;
  133312. /**
  133313. * The texture used as your environment texture in the scene.
  133314. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  133315. *
  133316. * Remarks: Can be either a texture or a url.
  133317. */
  133318. environmentTexture: string | BaseTexture;
  133319. /**
  133320. * The value of the exposure to apply to the scene.
  133321. * 0.6 by default if setupImageProcessing is true.
  133322. */
  133323. cameraExposure: number;
  133324. /**
  133325. * The value of the contrast to apply to the scene.
  133326. * 1.6 by default if setupImageProcessing is true.
  133327. */
  133328. cameraContrast: number;
  133329. /**
  133330. * Specifies whether or not tonemapping should be enabled in the scene.
  133331. * true by default if setupImageProcessing is true.
  133332. */
  133333. toneMappingEnabled: boolean;
  133334. }
  133335. /**
  133336. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  133337. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  133338. * It also helps with the default setup of your imageProcessing configuration.
  133339. */
  133340. export class EnvironmentHelper {
  133341. /**
  133342. * Default ground texture URL.
  133343. */
  133344. private static _groundTextureCDNUrl;
  133345. /**
  133346. * Default skybox texture URL.
  133347. */
  133348. private static _skyboxTextureCDNUrl;
  133349. /**
  133350. * Default environment texture URL.
  133351. */
  133352. private static _environmentTextureCDNUrl;
  133353. /**
  133354. * Creates the default options for the helper.
  133355. */
  133356. private static _getDefaultOptions;
  133357. private _rootMesh;
  133358. /**
  133359. * Gets the root mesh created by the helper.
  133360. */
  133361. get rootMesh(): Mesh;
  133362. private _skybox;
  133363. /**
  133364. * Gets the skybox created by the helper.
  133365. */
  133366. get skybox(): Nullable<Mesh>;
  133367. private _skyboxTexture;
  133368. /**
  133369. * Gets the skybox texture created by the helper.
  133370. */
  133371. get skyboxTexture(): Nullable<BaseTexture>;
  133372. private _skyboxMaterial;
  133373. /**
  133374. * Gets the skybox material created by the helper.
  133375. */
  133376. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  133377. private _ground;
  133378. /**
  133379. * Gets the ground mesh created by the helper.
  133380. */
  133381. get ground(): Nullable<Mesh>;
  133382. private _groundTexture;
  133383. /**
  133384. * Gets the ground texture created by the helper.
  133385. */
  133386. get groundTexture(): Nullable<BaseTexture>;
  133387. private _groundMirror;
  133388. /**
  133389. * Gets the ground mirror created by the helper.
  133390. */
  133391. get groundMirror(): Nullable<MirrorTexture>;
  133392. /**
  133393. * Gets the ground mirror render list to helps pushing the meshes
  133394. * you wish in the ground reflection.
  133395. */
  133396. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  133397. private _groundMaterial;
  133398. /**
  133399. * Gets the ground material created by the helper.
  133400. */
  133401. get groundMaterial(): Nullable<BackgroundMaterial>;
  133402. /**
  133403. * Stores the creation options.
  133404. */
  133405. private readonly _scene;
  133406. private _options;
  133407. /**
  133408. * This observable will be notified with any error during the creation of the environment,
  133409. * mainly texture creation errors.
  133410. */
  133411. onErrorObservable: Observable<{
  133412. message?: string;
  133413. exception?: any;
  133414. }>;
  133415. /**
  133416. * constructor
  133417. * @param options Defines the options we want to customize the helper
  133418. * @param scene The scene to add the material to
  133419. */
  133420. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  133421. /**
  133422. * Updates the background according to the new options
  133423. * @param options
  133424. */
  133425. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  133426. /**
  133427. * Sets the primary color of all the available elements.
  133428. * @param color the main color to affect to the ground and the background
  133429. */
  133430. setMainColor(color: Color3): void;
  133431. /**
  133432. * Setup the image processing according to the specified options.
  133433. */
  133434. private _setupImageProcessing;
  133435. /**
  133436. * Setup the environment texture according to the specified options.
  133437. */
  133438. private _setupEnvironmentTexture;
  133439. /**
  133440. * Setup the background according to the specified options.
  133441. */
  133442. private _setupBackground;
  133443. /**
  133444. * Get the scene sizes according to the setup.
  133445. */
  133446. private _getSceneSize;
  133447. /**
  133448. * Setup the ground according to the specified options.
  133449. */
  133450. private _setupGround;
  133451. /**
  133452. * Setup the ground material according to the specified options.
  133453. */
  133454. private _setupGroundMaterial;
  133455. /**
  133456. * Setup the ground diffuse texture according to the specified options.
  133457. */
  133458. private _setupGroundDiffuseTexture;
  133459. /**
  133460. * Setup the ground mirror texture according to the specified options.
  133461. */
  133462. private _setupGroundMirrorTexture;
  133463. /**
  133464. * Setup the ground to receive the mirror texture.
  133465. */
  133466. private _setupMirrorInGroundMaterial;
  133467. /**
  133468. * Setup the skybox according to the specified options.
  133469. */
  133470. private _setupSkybox;
  133471. /**
  133472. * Setup the skybox material according to the specified options.
  133473. */
  133474. private _setupSkyboxMaterial;
  133475. /**
  133476. * Setup the skybox reflection texture according to the specified options.
  133477. */
  133478. private _setupSkyboxReflectionTexture;
  133479. private _errorHandler;
  133480. /**
  133481. * Dispose all the elements created by the Helper.
  133482. */
  133483. dispose(): void;
  133484. }
  133485. }
  133486. declare module BABYLON {
  133487. /**
  133488. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  133489. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  133490. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  133491. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133492. */
  133493. export class PhotoDome extends TransformNode {
  133494. /**
  133495. * Define the image as a Monoscopic panoramic 360 image.
  133496. */
  133497. static readonly MODE_MONOSCOPIC: number;
  133498. /**
  133499. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133500. */
  133501. static readonly MODE_TOPBOTTOM: number;
  133502. /**
  133503. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133504. */
  133505. static readonly MODE_SIDEBYSIDE: number;
  133506. private _useDirectMapping;
  133507. /**
  133508. * The texture being displayed on the sphere
  133509. */
  133510. protected _photoTexture: Texture;
  133511. /**
  133512. * Gets or sets the texture being displayed on the sphere
  133513. */
  133514. get photoTexture(): Texture;
  133515. set photoTexture(value: Texture);
  133516. /**
  133517. * Observable raised when an error occured while loading the 360 image
  133518. */
  133519. onLoadErrorObservable: Observable<string>;
  133520. /**
  133521. * The skybox material
  133522. */
  133523. protected _material: BackgroundMaterial;
  133524. /**
  133525. * The surface used for the skybox
  133526. */
  133527. protected _mesh: Mesh;
  133528. /**
  133529. * Gets the mesh used for the skybox.
  133530. */
  133531. get mesh(): Mesh;
  133532. /**
  133533. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133534. * Also see the options.resolution property.
  133535. */
  133536. get fovMultiplier(): number;
  133537. set fovMultiplier(value: number);
  133538. private _imageMode;
  133539. /**
  133540. * Gets or set the current video mode for the video. It can be:
  133541. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  133542. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133543. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133544. */
  133545. get imageMode(): number;
  133546. set imageMode(value: number);
  133547. /**
  133548. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  133549. * @param name Element's name, child elements will append suffixes for their own names.
  133550. * @param urlsOfPhoto defines the url of the photo to display
  133551. * @param options defines an object containing optional or exposed sub element properties
  133552. * @param onError defines a callback called when an error occured while loading the texture
  133553. */
  133554. constructor(name: string, urlOfPhoto: string, options: {
  133555. resolution?: number;
  133556. size?: number;
  133557. useDirectMapping?: boolean;
  133558. faceForward?: boolean;
  133559. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  133560. private _onBeforeCameraRenderObserver;
  133561. private _changeImageMode;
  133562. /**
  133563. * Releases resources associated with this node.
  133564. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133565. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133566. */
  133567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133568. }
  133569. }
  133570. declare module BABYLON {
  133571. /**
  133572. * Class used to host RGBD texture specific utilities
  133573. */
  133574. export class RGBDTextureTools {
  133575. /**
  133576. * Expand the RGBD Texture from RGBD to Half Float if possible.
  133577. * @param texture the texture to expand.
  133578. */
  133579. static ExpandRGBDTexture(texture: Texture): void;
  133580. }
  133581. }
  133582. declare module BABYLON {
  133583. /**
  133584. * Class used to host texture specific utilities
  133585. */
  133586. export class BRDFTextureTools {
  133587. /**
  133588. * Prevents texture cache collision
  133589. */
  133590. private static _instanceNumber;
  133591. /**
  133592. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  133593. * @param scene defines the hosting scene
  133594. * @returns the environment BRDF texture
  133595. */
  133596. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  133597. private static _environmentBRDFBase64Texture;
  133598. }
  133599. }
  133600. declare module BABYLON {
  133601. /**
  133602. * @hidden
  133603. */
  133604. export interface IMaterialClearCoatDefines {
  133605. CLEARCOAT: boolean;
  133606. CLEARCOAT_DEFAULTIOR: boolean;
  133607. CLEARCOAT_TEXTURE: boolean;
  133608. CLEARCOAT_TEXTUREDIRECTUV: number;
  133609. CLEARCOAT_BUMP: boolean;
  133610. CLEARCOAT_BUMPDIRECTUV: number;
  133611. CLEARCOAT_TINT: boolean;
  133612. CLEARCOAT_TINT_TEXTURE: boolean;
  133613. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133614. /** @hidden */
  133615. _areTexturesDirty: boolean;
  133616. }
  133617. /**
  133618. * Define the code related to the clear coat parameters of the pbr material.
  133619. */
  133620. export class PBRClearCoatConfiguration {
  133621. /**
  133622. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133623. * The default fits with a polyurethane material.
  133624. */
  133625. private static readonly _DefaultIndexOfRefraction;
  133626. private _isEnabled;
  133627. /**
  133628. * Defines if the clear coat is enabled in the material.
  133629. */
  133630. isEnabled: boolean;
  133631. /**
  133632. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  133633. */
  133634. intensity: number;
  133635. /**
  133636. * Defines the clear coat layer roughness.
  133637. */
  133638. roughness: number;
  133639. private _indexOfRefraction;
  133640. /**
  133641. * Defines the index of refraction of the clear coat.
  133642. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133643. * The default fits with a polyurethane material.
  133644. * Changing the default value is more performance intensive.
  133645. */
  133646. indexOfRefraction: number;
  133647. private _texture;
  133648. /**
  133649. * Stores the clear coat values in a texture.
  133650. */
  133651. texture: Nullable<BaseTexture>;
  133652. private _bumpTexture;
  133653. /**
  133654. * Define the clear coat specific bump texture.
  133655. */
  133656. bumpTexture: Nullable<BaseTexture>;
  133657. private _isTintEnabled;
  133658. /**
  133659. * Defines if the clear coat tint is enabled in the material.
  133660. */
  133661. isTintEnabled: boolean;
  133662. /**
  133663. * Defines the clear coat tint of the material.
  133664. * This is only use if tint is enabled
  133665. */
  133666. tintColor: Color3;
  133667. /**
  133668. * Defines the distance at which the tint color should be found in the
  133669. * clear coat media.
  133670. * This is only use if tint is enabled
  133671. */
  133672. tintColorAtDistance: number;
  133673. /**
  133674. * Defines the clear coat layer thickness.
  133675. * This is only use if tint is enabled
  133676. */
  133677. tintThickness: number;
  133678. private _tintTexture;
  133679. /**
  133680. * Stores the clear tint values in a texture.
  133681. * rgb is tint
  133682. * a is a thickness factor
  133683. */
  133684. tintTexture: Nullable<BaseTexture>;
  133685. /** @hidden */
  133686. private _internalMarkAllSubMeshesAsTexturesDirty;
  133687. /** @hidden */
  133688. _markAllSubMeshesAsTexturesDirty(): void;
  133689. /**
  133690. * Instantiate a new istance of clear coat configuration.
  133691. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133692. */
  133693. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133694. /**
  133695. * Gets wehter the submesh is ready to be used or not.
  133696. * @param defines the list of "defines" to update.
  133697. * @param scene defines the scene the material belongs to.
  133698. * @param engine defines the engine the material belongs to.
  133699. * @param disableBumpMap defines wether the material disables bump or not.
  133700. * @returns - boolean indicating that the submesh is ready or not.
  133701. */
  133702. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  133703. /**
  133704. * Checks to see if a texture is used in the material.
  133705. * @param defines the list of "defines" to update.
  133706. * @param scene defines the scene to the material belongs to.
  133707. */
  133708. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  133709. /**
  133710. * Binds the material data.
  133711. * @param uniformBuffer defines the Uniform buffer to fill in.
  133712. * @param scene defines the scene the material belongs to.
  133713. * @param engine defines the engine the material belongs to.
  133714. * @param disableBumpMap defines wether the material disables bump or not.
  133715. * @param isFrozen defines wether the material is frozen or not.
  133716. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133717. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133718. */
  133719. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  133720. /**
  133721. * Checks to see if a texture is used in the material.
  133722. * @param texture - Base texture to use.
  133723. * @returns - Boolean specifying if a texture is used in the material.
  133724. */
  133725. hasTexture(texture: BaseTexture): boolean;
  133726. /**
  133727. * Returns an array of the actively used textures.
  133728. * @param activeTextures Array of BaseTextures
  133729. */
  133730. getActiveTextures(activeTextures: BaseTexture[]): void;
  133731. /**
  133732. * Returns the animatable textures.
  133733. * @param animatables Array of animatable textures.
  133734. */
  133735. getAnimatables(animatables: IAnimatable[]): void;
  133736. /**
  133737. * Disposes the resources of the material.
  133738. * @param forceDisposeTextures - Forces the disposal of all textures.
  133739. */
  133740. dispose(forceDisposeTextures?: boolean): void;
  133741. /**
  133742. * Get the current class name of the texture useful for serialization or dynamic coding.
  133743. * @returns "PBRClearCoatConfiguration"
  133744. */
  133745. getClassName(): string;
  133746. /**
  133747. * Add fallbacks to the effect fallbacks list.
  133748. * @param defines defines the Base texture to use.
  133749. * @param fallbacks defines the current fallback list.
  133750. * @param currentRank defines the current fallback rank.
  133751. * @returns the new fallback rank.
  133752. */
  133753. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133754. /**
  133755. * Add the required uniforms to the current list.
  133756. * @param uniforms defines the current uniform list.
  133757. */
  133758. static AddUniforms(uniforms: string[]): void;
  133759. /**
  133760. * Add the required samplers to the current list.
  133761. * @param samplers defines the current sampler list.
  133762. */
  133763. static AddSamplers(samplers: string[]): void;
  133764. /**
  133765. * Add the required uniforms to the current buffer.
  133766. * @param uniformBuffer defines the current uniform buffer.
  133767. */
  133768. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133769. /**
  133770. * Makes a duplicate of the current configuration into another one.
  133771. * @param clearCoatConfiguration define the config where to copy the info
  133772. */
  133773. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  133774. /**
  133775. * Serializes this clear coat configuration.
  133776. * @returns - An object with the serialized config.
  133777. */
  133778. serialize(): any;
  133779. /**
  133780. * Parses a anisotropy Configuration from a serialized object.
  133781. * @param source - Serialized object.
  133782. * @param scene Defines the scene we are parsing for
  133783. * @param rootUrl Defines the rootUrl to load from
  133784. */
  133785. parse(source: any, scene: Scene, rootUrl: string): void;
  133786. }
  133787. }
  133788. declare module BABYLON {
  133789. /**
  133790. * @hidden
  133791. */
  133792. export interface IMaterialAnisotropicDefines {
  133793. ANISOTROPIC: boolean;
  133794. ANISOTROPIC_TEXTURE: boolean;
  133795. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133796. MAINUV1: boolean;
  133797. _areTexturesDirty: boolean;
  133798. _needUVs: boolean;
  133799. }
  133800. /**
  133801. * Define the code related to the anisotropic parameters of the pbr material.
  133802. */
  133803. export class PBRAnisotropicConfiguration {
  133804. private _isEnabled;
  133805. /**
  133806. * Defines if the anisotropy is enabled in the material.
  133807. */
  133808. isEnabled: boolean;
  133809. /**
  133810. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  133811. */
  133812. intensity: number;
  133813. /**
  133814. * Defines if the effect is along the tangents, bitangents or in between.
  133815. * By default, the effect is "strectching" the highlights along the tangents.
  133816. */
  133817. direction: Vector2;
  133818. private _texture;
  133819. /**
  133820. * Stores the anisotropy values in a texture.
  133821. * rg is direction (like normal from -1 to 1)
  133822. * b is a intensity
  133823. */
  133824. texture: Nullable<BaseTexture>;
  133825. /** @hidden */
  133826. private _internalMarkAllSubMeshesAsTexturesDirty;
  133827. /** @hidden */
  133828. _markAllSubMeshesAsTexturesDirty(): void;
  133829. /**
  133830. * Instantiate a new istance of anisotropy configuration.
  133831. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133832. */
  133833. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133834. /**
  133835. * Specifies that the submesh is ready to be used.
  133836. * @param defines the list of "defines" to update.
  133837. * @param scene defines the scene the material belongs to.
  133838. * @returns - boolean indicating that the submesh is ready or not.
  133839. */
  133840. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  133841. /**
  133842. * Checks to see if a texture is used in the material.
  133843. * @param defines the list of "defines" to update.
  133844. * @param mesh the mesh we are preparing the defines for.
  133845. * @param scene defines the scene the material belongs to.
  133846. */
  133847. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  133848. /**
  133849. * Binds the material data.
  133850. * @param uniformBuffer defines the Uniform buffer to fill in.
  133851. * @param scene defines the scene the material belongs to.
  133852. * @param isFrozen defines wether the material is frozen or not.
  133853. */
  133854. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  133855. /**
  133856. * Checks to see if a texture is used in the material.
  133857. * @param texture - Base texture to use.
  133858. * @returns - Boolean specifying if a texture is used in the material.
  133859. */
  133860. hasTexture(texture: BaseTexture): boolean;
  133861. /**
  133862. * Returns an array of the actively used textures.
  133863. * @param activeTextures Array of BaseTextures
  133864. */
  133865. getActiveTextures(activeTextures: BaseTexture[]): void;
  133866. /**
  133867. * Returns the animatable textures.
  133868. * @param animatables Array of animatable textures.
  133869. */
  133870. getAnimatables(animatables: IAnimatable[]): void;
  133871. /**
  133872. * Disposes the resources of the material.
  133873. * @param forceDisposeTextures - Forces the disposal of all textures.
  133874. */
  133875. dispose(forceDisposeTextures?: boolean): void;
  133876. /**
  133877. * Get the current class name of the texture useful for serialization or dynamic coding.
  133878. * @returns "PBRAnisotropicConfiguration"
  133879. */
  133880. getClassName(): string;
  133881. /**
  133882. * Add fallbacks to the effect fallbacks list.
  133883. * @param defines defines the Base texture to use.
  133884. * @param fallbacks defines the current fallback list.
  133885. * @param currentRank defines the current fallback rank.
  133886. * @returns the new fallback rank.
  133887. */
  133888. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133889. /**
  133890. * Add the required uniforms to the current list.
  133891. * @param uniforms defines the current uniform list.
  133892. */
  133893. static AddUniforms(uniforms: string[]): void;
  133894. /**
  133895. * Add the required uniforms to the current buffer.
  133896. * @param uniformBuffer defines the current uniform buffer.
  133897. */
  133898. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133899. /**
  133900. * Add the required samplers to the current list.
  133901. * @param samplers defines the current sampler list.
  133902. */
  133903. static AddSamplers(samplers: string[]): void;
  133904. /**
  133905. * Makes a duplicate of the current configuration into another one.
  133906. * @param anisotropicConfiguration define the config where to copy the info
  133907. */
  133908. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  133909. /**
  133910. * Serializes this anisotropy configuration.
  133911. * @returns - An object with the serialized config.
  133912. */
  133913. serialize(): any;
  133914. /**
  133915. * Parses a anisotropy Configuration from a serialized object.
  133916. * @param source - Serialized object.
  133917. * @param scene Defines the scene we are parsing for
  133918. * @param rootUrl Defines the rootUrl to load from
  133919. */
  133920. parse(source: any, scene: Scene, rootUrl: string): void;
  133921. }
  133922. }
  133923. declare module BABYLON {
  133924. /**
  133925. * @hidden
  133926. */
  133927. export interface IMaterialBRDFDefines {
  133928. BRDF_V_HEIGHT_CORRELATED: boolean;
  133929. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133930. SPHERICAL_HARMONICS: boolean;
  133931. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133932. /** @hidden */
  133933. _areMiscDirty: boolean;
  133934. }
  133935. /**
  133936. * Define the code related to the BRDF parameters of the pbr material.
  133937. */
  133938. export class PBRBRDFConfiguration {
  133939. /**
  133940. * Default value used for the energy conservation.
  133941. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133942. */
  133943. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  133944. /**
  133945. * Default value used for the Smith Visibility Height Correlated mode.
  133946. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133947. */
  133948. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  133949. /**
  133950. * Default value used for the IBL diffuse part.
  133951. * This can help switching back to the polynomials mode globally which is a tiny bit
  133952. * less GPU intensive at the drawback of a lower quality.
  133953. */
  133954. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  133955. /**
  133956. * Default value used for activating energy conservation for the specular workflow.
  133957. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133958. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133959. */
  133960. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  133961. private _useEnergyConservation;
  133962. /**
  133963. * Defines if the material uses energy conservation.
  133964. */
  133965. useEnergyConservation: boolean;
  133966. private _useSmithVisibilityHeightCorrelated;
  133967. /**
  133968. * LEGACY Mode set to false
  133969. * Defines if the material uses height smith correlated visibility term.
  133970. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  133971. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  133972. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  133973. * Not relying on height correlated will also disable energy conservation.
  133974. */
  133975. useSmithVisibilityHeightCorrelated: boolean;
  133976. private _useSphericalHarmonics;
  133977. /**
  133978. * LEGACY Mode set to false
  133979. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  133980. * diffuse part of the IBL.
  133981. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  133982. * to the ground truth.
  133983. */
  133984. useSphericalHarmonics: boolean;
  133985. private _useSpecularGlossinessInputEnergyConservation;
  133986. /**
  133987. * Defines if the material uses energy conservation, when the specular workflow is active.
  133988. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133989. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133990. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  133991. */
  133992. useSpecularGlossinessInputEnergyConservation: boolean;
  133993. /** @hidden */
  133994. private _internalMarkAllSubMeshesAsMiscDirty;
  133995. /** @hidden */
  133996. _markAllSubMeshesAsMiscDirty(): void;
  133997. /**
  133998. * Instantiate a new istance of clear coat configuration.
  133999. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  134000. */
  134001. constructor(markAllSubMeshesAsMiscDirty: () => void);
  134002. /**
  134003. * Checks to see if a texture is used in the material.
  134004. * @param defines the list of "defines" to update.
  134005. */
  134006. prepareDefines(defines: IMaterialBRDFDefines): void;
  134007. /**
  134008. * Get the current class name of the texture useful for serialization or dynamic coding.
  134009. * @returns "PBRClearCoatConfiguration"
  134010. */
  134011. getClassName(): string;
  134012. /**
  134013. * Makes a duplicate of the current configuration into another one.
  134014. * @param brdfConfiguration define the config where to copy the info
  134015. */
  134016. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  134017. /**
  134018. * Serializes this BRDF configuration.
  134019. * @returns - An object with the serialized config.
  134020. */
  134021. serialize(): any;
  134022. /**
  134023. * Parses a anisotropy Configuration from a serialized object.
  134024. * @param source - Serialized object.
  134025. * @param scene Defines the scene we are parsing for
  134026. * @param rootUrl Defines the rootUrl to load from
  134027. */
  134028. parse(source: any, scene: Scene, rootUrl: string): void;
  134029. }
  134030. }
  134031. declare module BABYLON {
  134032. /**
  134033. * @hidden
  134034. */
  134035. export interface IMaterialSheenDefines {
  134036. SHEEN: boolean;
  134037. SHEEN_TEXTURE: boolean;
  134038. SHEEN_TEXTUREDIRECTUV: number;
  134039. SHEEN_LINKWITHALBEDO: boolean;
  134040. SHEEN_ROUGHNESS: boolean;
  134041. SHEEN_ALBEDOSCALING: boolean;
  134042. /** @hidden */
  134043. _areTexturesDirty: boolean;
  134044. }
  134045. /**
  134046. * Define the code related to the Sheen parameters of the pbr material.
  134047. */
  134048. export class PBRSheenConfiguration {
  134049. private _isEnabled;
  134050. /**
  134051. * Defines if the material uses sheen.
  134052. */
  134053. isEnabled: boolean;
  134054. private _linkSheenWithAlbedo;
  134055. /**
  134056. * Defines if the sheen is linked to the sheen color.
  134057. */
  134058. linkSheenWithAlbedo: boolean;
  134059. /**
  134060. * Defines the sheen intensity.
  134061. */
  134062. intensity: number;
  134063. /**
  134064. * Defines the sheen color.
  134065. */
  134066. color: Color3;
  134067. private _texture;
  134068. /**
  134069. * Stores the sheen tint values in a texture.
  134070. * rgb is tint
  134071. * a is a intensity or roughness if roughness has been defined
  134072. */
  134073. texture: Nullable<BaseTexture>;
  134074. private _roughness;
  134075. /**
  134076. * Defines the sheen roughness.
  134077. * It is not taken into account if linkSheenWithAlbedo is true.
  134078. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  134079. */
  134080. roughness: Nullable<number>;
  134081. private _albedoScaling;
  134082. /**
  134083. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  134084. * It allows the strength of the sheen effect to not depend on the base color of the material,
  134085. * making it easier to setup and tweak the effect
  134086. */
  134087. albedoScaling: boolean;
  134088. /** @hidden */
  134089. private _internalMarkAllSubMeshesAsTexturesDirty;
  134090. /** @hidden */
  134091. _markAllSubMeshesAsTexturesDirty(): void;
  134092. /**
  134093. * Instantiate a new istance of clear coat configuration.
  134094. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134095. */
  134096. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134097. /**
  134098. * Specifies that the submesh is ready to be used.
  134099. * @param defines the list of "defines" to update.
  134100. * @param scene defines the scene the material belongs to.
  134101. * @returns - boolean indicating that the submesh is ready or not.
  134102. */
  134103. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  134104. /**
  134105. * Checks to see if a texture is used in the material.
  134106. * @param defines the list of "defines" to update.
  134107. * @param scene defines the scene the material belongs to.
  134108. */
  134109. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  134110. /**
  134111. * Binds the material data.
  134112. * @param uniformBuffer defines the Uniform buffer to fill in.
  134113. * @param scene defines the scene the material belongs to.
  134114. * @param isFrozen defines wether the material is frozen or not.
  134115. */
  134116. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134117. /**
  134118. * Checks to see if a texture is used in the material.
  134119. * @param texture - Base texture to use.
  134120. * @returns - Boolean specifying if a texture is used in the material.
  134121. */
  134122. hasTexture(texture: BaseTexture): boolean;
  134123. /**
  134124. * Returns an array of the actively used textures.
  134125. * @param activeTextures Array of BaseTextures
  134126. */
  134127. getActiveTextures(activeTextures: BaseTexture[]): void;
  134128. /**
  134129. * Returns the animatable textures.
  134130. * @param animatables Array of animatable textures.
  134131. */
  134132. getAnimatables(animatables: IAnimatable[]): void;
  134133. /**
  134134. * Disposes the resources of the material.
  134135. * @param forceDisposeTextures - Forces the disposal of all textures.
  134136. */
  134137. dispose(forceDisposeTextures?: boolean): void;
  134138. /**
  134139. * Get the current class name of the texture useful for serialization or dynamic coding.
  134140. * @returns "PBRSheenConfiguration"
  134141. */
  134142. getClassName(): string;
  134143. /**
  134144. * Add fallbacks to the effect fallbacks list.
  134145. * @param defines defines the Base texture to use.
  134146. * @param fallbacks defines the current fallback list.
  134147. * @param currentRank defines the current fallback rank.
  134148. * @returns the new fallback rank.
  134149. */
  134150. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134151. /**
  134152. * Add the required uniforms to the current list.
  134153. * @param uniforms defines the current uniform list.
  134154. */
  134155. static AddUniforms(uniforms: string[]): void;
  134156. /**
  134157. * Add the required uniforms to the current buffer.
  134158. * @param uniformBuffer defines the current uniform buffer.
  134159. */
  134160. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134161. /**
  134162. * Add the required samplers to the current list.
  134163. * @param samplers defines the current sampler list.
  134164. */
  134165. static AddSamplers(samplers: string[]): void;
  134166. /**
  134167. * Makes a duplicate of the current configuration into another one.
  134168. * @param sheenConfiguration define the config where to copy the info
  134169. */
  134170. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  134171. /**
  134172. * Serializes this BRDF configuration.
  134173. * @returns - An object with the serialized config.
  134174. */
  134175. serialize(): any;
  134176. /**
  134177. * Parses a anisotropy Configuration from a serialized object.
  134178. * @param source - Serialized object.
  134179. * @param scene Defines the scene we are parsing for
  134180. * @param rootUrl Defines the rootUrl to load from
  134181. */
  134182. parse(source: any, scene: Scene, rootUrl: string): void;
  134183. }
  134184. }
  134185. declare module BABYLON {
  134186. /**
  134187. * @hidden
  134188. */
  134189. export interface IMaterialSubSurfaceDefines {
  134190. SUBSURFACE: boolean;
  134191. SS_REFRACTION: boolean;
  134192. SS_TRANSLUCENCY: boolean;
  134193. SS_SCATTERING: boolean;
  134194. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134195. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134196. SS_REFRACTIONMAP_3D: boolean;
  134197. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134198. SS_LODINREFRACTIONALPHA: boolean;
  134199. SS_GAMMAREFRACTION: boolean;
  134200. SS_RGBDREFRACTION: boolean;
  134201. SS_LINEARSPECULARREFRACTION: boolean;
  134202. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134203. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134204. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134205. /** @hidden */
  134206. _areTexturesDirty: boolean;
  134207. }
  134208. /**
  134209. * Define the code related to the sub surface parameters of the pbr material.
  134210. */
  134211. export class PBRSubSurfaceConfiguration {
  134212. private _isRefractionEnabled;
  134213. /**
  134214. * Defines if the refraction is enabled in the material.
  134215. */
  134216. isRefractionEnabled: boolean;
  134217. private _isTranslucencyEnabled;
  134218. /**
  134219. * Defines if the translucency is enabled in the material.
  134220. */
  134221. isTranslucencyEnabled: boolean;
  134222. private _isScatteringEnabled;
  134223. /**
  134224. * Defines if the sub surface scattering is enabled in the material.
  134225. */
  134226. isScatteringEnabled: boolean;
  134227. private _scatteringDiffusionProfileIndex;
  134228. /**
  134229. * Diffusion profile for subsurface scattering.
  134230. * Useful for better scattering in the skins or foliages.
  134231. */
  134232. get scatteringDiffusionProfile(): Nullable<Color3>;
  134233. set scatteringDiffusionProfile(c: Nullable<Color3>);
  134234. /**
  134235. * Defines the refraction intensity of the material.
  134236. * The refraction when enabled replaces the Diffuse part of the material.
  134237. * The intensity helps transitionning between diffuse and refraction.
  134238. */
  134239. refractionIntensity: number;
  134240. /**
  134241. * Defines the translucency intensity of the material.
  134242. * When translucency has been enabled, this defines how much of the "translucency"
  134243. * is addded to the diffuse part of the material.
  134244. */
  134245. translucencyIntensity: number;
  134246. /**
  134247. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  134248. */
  134249. useAlbedoToTintRefraction: boolean;
  134250. private _thicknessTexture;
  134251. /**
  134252. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  134253. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  134254. * 0 would mean minimumThickness
  134255. * 1 would mean maximumThickness
  134256. * The other channels might be use as a mask to vary the different effects intensity.
  134257. */
  134258. thicknessTexture: Nullable<BaseTexture>;
  134259. private _refractionTexture;
  134260. /**
  134261. * Defines the texture to use for refraction.
  134262. */
  134263. refractionTexture: Nullable<BaseTexture>;
  134264. private _indexOfRefraction;
  134265. /**
  134266. * Index of refraction of the material base layer.
  134267. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134268. *
  134269. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134270. *
  134271. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134272. */
  134273. indexOfRefraction: number;
  134274. private _volumeIndexOfRefraction;
  134275. /**
  134276. * Index of refraction of the material's volume.
  134277. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134278. *
  134279. * This ONLY impacts refraction. If not provided or given a non-valid value,
  134280. * the volume will use the same IOR as the surface.
  134281. */
  134282. get volumeIndexOfRefraction(): number;
  134283. set volumeIndexOfRefraction(value: number);
  134284. private _invertRefractionY;
  134285. /**
  134286. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134287. */
  134288. invertRefractionY: boolean;
  134289. private _linkRefractionWithTransparency;
  134290. /**
  134291. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134292. * Materials half opaque for instance using refraction could benefit from this control.
  134293. */
  134294. linkRefractionWithTransparency: boolean;
  134295. /**
  134296. * Defines the minimum thickness stored in the thickness map.
  134297. * If no thickness map is defined, this value will be used to simulate thickness.
  134298. */
  134299. minimumThickness: number;
  134300. /**
  134301. * Defines the maximum thickness stored in the thickness map.
  134302. */
  134303. maximumThickness: number;
  134304. /**
  134305. * Defines the volume tint of the material.
  134306. * This is used for both translucency and scattering.
  134307. */
  134308. tintColor: Color3;
  134309. /**
  134310. * Defines the distance at which the tint color should be found in the media.
  134311. * This is used for refraction only.
  134312. */
  134313. tintColorAtDistance: number;
  134314. /**
  134315. * Defines how far each channel transmit through the media.
  134316. * It is defined as a color to simplify it selection.
  134317. */
  134318. diffusionDistance: Color3;
  134319. private _useMaskFromThicknessTexture;
  134320. /**
  134321. * Stores the intensity of the different subsurface effects in the thickness texture.
  134322. * * the green channel is the translucency intensity.
  134323. * * the blue channel is the scattering intensity.
  134324. * * the alpha channel is the refraction intensity.
  134325. */
  134326. useMaskFromThicknessTexture: boolean;
  134327. private _scene;
  134328. /** @hidden */
  134329. private _internalMarkAllSubMeshesAsTexturesDirty;
  134330. private _internalMarkScenePrePassDirty;
  134331. /** @hidden */
  134332. _markAllSubMeshesAsTexturesDirty(): void;
  134333. /** @hidden */
  134334. _markScenePrePassDirty(): void;
  134335. /**
  134336. * Instantiate a new istance of sub surface configuration.
  134337. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134338. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  134339. * @param scene The scene
  134340. */
  134341. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  134342. /**
  134343. * Gets wehter the submesh is ready to be used or not.
  134344. * @param defines the list of "defines" to update.
  134345. * @param scene defines the scene the material belongs to.
  134346. * @returns - boolean indicating that the submesh is ready or not.
  134347. */
  134348. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  134349. /**
  134350. * Checks to see if a texture is used in the material.
  134351. * @param defines the list of "defines" to update.
  134352. * @param scene defines the scene to the material belongs to.
  134353. */
  134354. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  134355. /**
  134356. * Binds the material data.
  134357. * @param uniformBuffer defines the Uniform buffer to fill in.
  134358. * @param scene defines the scene the material belongs to.
  134359. * @param engine defines the engine the material belongs to.
  134360. * @param isFrozen defines whether the material is frozen or not.
  134361. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  134362. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  134363. */
  134364. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  134365. /**
  134366. * Unbinds the material from the mesh.
  134367. * @param activeEffect defines the effect that should be unbound from.
  134368. * @returns true if unbound, otherwise false
  134369. */
  134370. unbind(activeEffect: Effect): boolean;
  134371. /**
  134372. * Returns the texture used for refraction or null if none is used.
  134373. * @param scene defines the scene the material belongs to.
  134374. * @returns - Refraction texture if present. If no refraction texture and refraction
  134375. * is linked with transparency, returns environment texture. Otherwise, returns null.
  134376. */
  134377. private _getRefractionTexture;
  134378. /**
  134379. * Returns true if alpha blending should be disabled.
  134380. */
  134381. get disableAlphaBlending(): boolean;
  134382. /**
  134383. * Fills the list of render target textures.
  134384. * @param renderTargets the list of render targets to update
  134385. */
  134386. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  134387. /**
  134388. * Checks to see if a texture is used in the material.
  134389. * @param texture - Base texture to use.
  134390. * @returns - Boolean specifying if a texture is used in the material.
  134391. */
  134392. hasTexture(texture: BaseTexture): boolean;
  134393. /**
  134394. * Gets a boolean indicating that current material needs to register RTT
  134395. * @returns true if this uses a render target otherwise false.
  134396. */
  134397. hasRenderTargetTextures(): boolean;
  134398. /**
  134399. * Returns an array of the actively used textures.
  134400. * @param activeTextures Array of BaseTextures
  134401. */
  134402. getActiveTextures(activeTextures: BaseTexture[]): void;
  134403. /**
  134404. * Returns the animatable textures.
  134405. * @param animatables Array of animatable textures.
  134406. */
  134407. getAnimatables(animatables: IAnimatable[]): void;
  134408. /**
  134409. * Disposes the resources of the material.
  134410. * @param forceDisposeTextures - Forces the disposal of all textures.
  134411. */
  134412. dispose(forceDisposeTextures?: boolean): void;
  134413. /**
  134414. * Get the current class name of the texture useful for serialization or dynamic coding.
  134415. * @returns "PBRSubSurfaceConfiguration"
  134416. */
  134417. getClassName(): string;
  134418. /**
  134419. * Add fallbacks to the effect fallbacks list.
  134420. * @param defines defines the Base texture to use.
  134421. * @param fallbacks defines the current fallback list.
  134422. * @param currentRank defines the current fallback rank.
  134423. * @returns the new fallback rank.
  134424. */
  134425. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134426. /**
  134427. * Add the required uniforms to the current list.
  134428. * @param uniforms defines the current uniform list.
  134429. */
  134430. static AddUniforms(uniforms: string[]): void;
  134431. /**
  134432. * Add the required samplers to the current list.
  134433. * @param samplers defines the current sampler list.
  134434. */
  134435. static AddSamplers(samplers: string[]): void;
  134436. /**
  134437. * Add the required uniforms to the current buffer.
  134438. * @param uniformBuffer defines the current uniform buffer.
  134439. */
  134440. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134441. /**
  134442. * Makes a duplicate of the current configuration into another one.
  134443. * @param configuration define the config where to copy the info
  134444. */
  134445. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  134446. /**
  134447. * Serializes this Sub Surface configuration.
  134448. * @returns - An object with the serialized config.
  134449. */
  134450. serialize(): any;
  134451. /**
  134452. * Parses a anisotropy Configuration from a serialized object.
  134453. * @param source - Serialized object.
  134454. * @param scene Defines the scene we are parsing for
  134455. * @param rootUrl Defines the rootUrl to load from
  134456. */
  134457. parse(source: any, scene: Scene, rootUrl: string): void;
  134458. }
  134459. }
  134460. declare module BABYLON {
  134461. /** @hidden */
  134462. export var pbrFragmentDeclaration: {
  134463. name: string;
  134464. shader: string;
  134465. };
  134466. }
  134467. declare module BABYLON {
  134468. /** @hidden */
  134469. export var pbrUboDeclaration: {
  134470. name: string;
  134471. shader: string;
  134472. };
  134473. }
  134474. declare module BABYLON {
  134475. /** @hidden */
  134476. export var pbrFragmentExtraDeclaration: {
  134477. name: string;
  134478. shader: string;
  134479. };
  134480. }
  134481. declare module BABYLON {
  134482. /** @hidden */
  134483. export var pbrFragmentSamplersDeclaration: {
  134484. name: string;
  134485. shader: string;
  134486. };
  134487. }
  134488. declare module BABYLON {
  134489. /** @hidden */
  134490. export var importanceSampling: {
  134491. name: string;
  134492. shader: string;
  134493. };
  134494. }
  134495. declare module BABYLON {
  134496. /** @hidden */
  134497. export var pbrHelperFunctions: {
  134498. name: string;
  134499. shader: string;
  134500. };
  134501. }
  134502. declare module BABYLON {
  134503. /** @hidden */
  134504. export var harmonicsFunctions: {
  134505. name: string;
  134506. shader: string;
  134507. };
  134508. }
  134509. declare module BABYLON {
  134510. /** @hidden */
  134511. export var pbrDirectLightingSetupFunctions: {
  134512. name: string;
  134513. shader: string;
  134514. };
  134515. }
  134516. declare module BABYLON {
  134517. /** @hidden */
  134518. export var pbrDirectLightingFalloffFunctions: {
  134519. name: string;
  134520. shader: string;
  134521. };
  134522. }
  134523. declare module BABYLON {
  134524. /** @hidden */
  134525. export var pbrBRDFFunctions: {
  134526. name: string;
  134527. shader: string;
  134528. };
  134529. }
  134530. declare module BABYLON {
  134531. /** @hidden */
  134532. export var hdrFilteringFunctions: {
  134533. name: string;
  134534. shader: string;
  134535. };
  134536. }
  134537. declare module BABYLON {
  134538. /** @hidden */
  134539. export var pbrDirectLightingFunctions: {
  134540. name: string;
  134541. shader: string;
  134542. };
  134543. }
  134544. declare module BABYLON {
  134545. /** @hidden */
  134546. export var pbrIBLFunctions: {
  134547. name: string;
  134548. shader: string;
  134549. };
  134550. }
  134551. declare module BABYLON {
  134552. /** @hidden */
  134553. export var pbrBlockAlbedoOpacity: {
  134554. name: string;
  134555. shader: string;
  134556. };
  134557. }
  134558. declare module BABYLON {
  134559. /** @hidden */
  134560. export var pbrBlockReflectivity: {
  134561. name: string;
  134562. shader: string;
  134563. };
  134564. }
  134565. declare module BABYLON {
  134566. /** @hidden */
  134567. export var pbrBlockAmbientOcclusion: {
  134568. name: string;
  134569. shader: string;
  134570. };
  134571. }
  134572. declare module BABYLON {
  134573. /** @hidden */
  134574. export var pbrBlockAlphaFresnel: {
  134575. name: string;
  134576. shader: string;
  134577. };
  134578. }
  134579. declare module BABYLON {
  134580. /** @hidden */
  134581. export var pbrBlockAnisotropic: {
  134582. name: string;
  134583. shader: string;
  134584. };
  134585. }
  134586. declare module BABYLON {
  134587. /** @hidden */
  134588. export var pbrBlockReflection: {
  134589. name: string;
  134590. shader: string;
  134591. };
  134592. }
  134593. declare module BABYLON {
  134594. /** @hidden */
  134595. export var pbrBlockSheen: {
  134596. name: string;
  134597. shader: string;
  134598. };
  134599. }
  134600. declare module BABYLON {
  134601. /** @hidden */
  134602. export var pbrBlockClearcoat: {
  134603. name: string;
  134604. shader: string;
  134605. };
  134606. }
  134607. declare module BABYLON {
  134608. /** @hidden */
  134609. export var pbrBlockSubSurface: {
  134610. name: string;
  134611. shader: string;
  134612. };
  134613. }
  134614. declare module BABYLON {
  134615. /** @hidden */
  134616. export var pbrBlockNormalGeometric: {
  134617. name: string;
  134618. shader: string;
  134619. };
  134620. }
  134621. declare module BABYLON {
  134622. /** @hidden */
  134623. export var pbrBlockNormalFinal: {
  134624. name: string;
  134625. shader: string;
  134626. };
  134627. }
  134628. declare module BABYLON {
  134629. /** @hidden */
  134630. export var pbrBlockLightmapInit: {
  134631. name: string;
  134632. shader: string;
  134633. };
  134634. }
  134635. declare module BABYLON {
  134636. /** @hidden */
  134637. export var pbrBlockGeometryInfo: {
  134638. name: string;
  134639. shader: string;
  134640. };
  134641. }
  134642. declare module BABYLON {
  134643. /** @hidden */
  134644. export var pbrBlockReflectance0: {
  134645. name: string;
  134646. shader: string;
  134647. };
  134648. }
  134649. declare module BABYLON {
  134650. /** @hidden */
  134651. export var pbrBlockReflectance: {
  134652. name: string;
  134653. shader: string;
  134654. };
  134655. }
  134656. declare module BABYLON {
  134657. /** @hidden */
  134658. export var pbrBlockDirectLighting: {
  134659. name: string;
  134660. shader: string;
  134661. };
  134662. }
  134663. declare module BABYLON {
  134664. /** @hidden */
  134665. export var pbrBlockFinalLitComponents: {
  134666. name: string;
  134667. shader: string;
  134668. };
  134669. }
  134670. declare module BABYLON {
  134671. /** @hidden */
  134672. export var pbrBlockFinalUnlitComponents: {
  134673. name: string;
  134674. shader: string;
  134675. };
  134676. }
  134677. declare module BABYLON {
  134678. /** @hidden */
  134679. export var pbrBlockFinalColorComposition: {
  134680. name: string;
  134681. shader: string;
  134682. };
  134683. }
  134684. declare module BABYLON {
  134685. /** @hidden */
  134686. export var pbrBlockImageProcessing: {
  134687. name: string;
  134688. shader: string;
  134689. };
  134690. }
  134691. declare module BABYLON {
  134692. /** @hidden */
  134693. export var pbrDebug: {
  134694. name: string;
  134695. shader: string;
  134696. };
  134697. }
  134698. declare module BABYLON {
  134699. /** @hidden */
  134700. export var pbrPixelShader: {
  134701. name: string;
  134702. shader: string;
  134703. };
  134704. }
  134705. declare module BABYLON {
  134706. /** @hidden */
  134707. export var pbrVertexDeclaration: {
  134708. name: string;
  134709. shader: string;
  134710. };
  134711. }
  134712. declare module BABYLON {
  134713. /** @hidden */
  134714. export var pbrVertexShader: {
  134715. name: string;
  134716. shader: string;
  134717. };
  134718. }
  134719. declare module BABYLON {
  134720. /**
  134721. * Manages the defines for the PBR Material.
  134722. * @hidden
  134723. */
  134724. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  134725. PBR: boolean;
  134726. NUM_SAMPLES: string;
  134727. REALTIME_FILTERING: boolean;
  134728. MAINUV1: boolean;
  134729. MAINUV2: boolean;
  134730. UV1: boolean;
  134731. UV2: boolean;
  134732. ALBEDO: boolean;
  134733. GAMMAALBEDO: boolean;
  134734. ALBEDODIRECTUV: number;
  134735. VERTEXCOLOR: boolean;
  134736. DETAIL: boolean;
  134737. DETAILDIRECTUV: number;
  134738. DETAIL_NORMALBLENDMETHOD: number;
  134739. AMBIENT: boolean;
  134740. AMBIENTDIRECTUV: number;
  134741. AMBIENTINGRAYSCALE: boolean;
  134742. OPACITY: boolean;
  134743. VERTEXALPHA: boolean;
  134744. OPACITYDIRECTUV: number;
  134745. OPACITYRGB: boolean;
  134746. ALPHATEST: boolean;
  134747. DEPTHPREPASS: boolean;
  134748. ALPHABLEND: boolean;
  134749. ALPHAFROMALBEDO: boolean;
  134750. ALPHATESTVALUE: string;
  134751. SPECULAROVERALPHA: boolean;
  134752. RADIANCEOVERALPHA: boolean;
  134753. ALPHAFRESNEL: boolean;
  134754. LINEARALPHAFRESNEL: boolean;
  134755. PREMULTIPLYALPHA: boolean;
  134756. EMISSIVE: boolean;
  134757. EMISSIVEDIRECTUV: number;
  134758. REFLECTIVITY: boolean;
  134759. REFLECTIVITYDIRECTUV: number;
  134760. SPECULARTERM: boolean;
  134761. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  134762. MICROSURFACEAUTOMATIC: boolean;
  134763. LODBASEDMICROSFURACE: boolean;
  134764. MICROSURFACEMAP: boolean;
  134765. MICROSURFACEMAPDIRECTUV: number;
  134766. METALLICWORKFLOW: boolean;
  134767. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  134768. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  134769. METALLNESSSTOREINMETALMAPBLUE: boolean;
  134770. AOSTOREINMETALMAPRED: boolean;
  134771. METALLIC_REFLECTANCE: boolean;
  134772. METALLIC_REFLECTANCEDIRECTUV: number;
  134773. ENVIRONMENTBRDF: boolean;
  134774. ENVIRONMENTBRDF_RGBD: boolean;
  134775. NORMAL: boolean;
  134776. TANGENT: boolean;
  134777. BUMP: boolean;
  134778. BUMPDIRECTUV: number;
  134779. OBJECTSPACE_NORMALMAP: boolean;
  134780. PARALLAX: boolean;
  134781. PARALLAXOCCLUSION: boolean;
  134782. NORMALXYSCALE: boolean;
  134783. LIGHTMAP: boolean;
  134784. LIGHTMAPDIRECTUV: number;
  134785. USELIGHTMAPASSHADOWMAP: boolean;
  134786. GAMMALIGHTMAP: boolean;
  134787. RGBDLIGHTMAP: boolean;
  134788. REFLECTION: boolean;
  134789. REFLECTIONMAP_3D: boolean;
  134790. REFLECTIONMAP_SPHERICAL: boolean;
  134791. REFLECTIONMAP_PLANAR: boolean;
  134792. REFLECTIONMAP_CUBIC: boolean;
  134793. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  134794. REFLECTIONMAP_PROJECTION: boolean;
  134795. REFLECTIONMAP_SKYBOX: boolean;
  134796. REFLECTIONMAP_EXPLICIT: boolean;
  134797. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  134798. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  134799. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  134800. INVERTCUBICMAP: boolean;
  134801. USESPHERICALFROMREFLECTIONMAP: boolean;
  134802. USEIRRADIANCEMAP: boolean;
  134803. SPHERICAL_HARMONICS: boolean;
  134804. USESPHERICALINVERTEX: boolean;
  134805. REFLECTIONMAP_OPPOSITEZ: boolean;
  134806. LODINREFLECTIONALPHA: boolean;
  134807. GAMMAREFLECTION: boolean;
  134808. RGBDREFLECTION: boolean;
  134809. LINEARSPECULARREFLECTION: boolean;
  134810. RADIANCEOCCLUSION: boolean;
  134811. HORIZONOCCLUSION: boolean;
  134812. INSTANCES: boolean;
  134813. THIN_INSTANCES: boolean;
  134814. PREPASS: boolean;
  134815. SCENE_MRT_COUNT: number;
  134816. NUM_BONE_INFLUENCERS: number;
  134817. BonesPerMesh: number;
  134818. BONETEXTURE: boolean;
  134819. NONUNIFORMSCALING: boolean;
  134820. MORPHTARGETS: boolean;
  134821. MORPHTARGETS_NORMAL: boolean;
  134822. MORPHTARGETS_TANGENT: boolean;
  134823. MORPHTARGETS_UV: boolean;
  134824. NUM_MORPH_INFLUENCERS: number;
  134825. IMAGEPROCESSING: boolean;
  134826. VIGNETTE: boolean;
  134827. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134828. VIGNETTEBLENDMODEOPAQUE: boolean;
  134829. TONEMAPPING: boolean;
  134830. TONEMAPPING_ACES: boolean;
  134831. CONTRAST: boolean;
  134832. COLORCURVES: boolean;
  134833. COLORGRADING: boolean;
  134834. COLORGRADING3D: boolean;
  134835. SAMPLER3DGREENDEPTH: boolean;
  134836. SAMPLER3DBGRMAP: boolean;
  134837. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134838. EXPOSURE: boolean;
  134839. MULTIVIEW: boolean;
  134840. USEPHYSICALLIGHTFALLOFF: boolean;
  134841. USEGLTFLIGHTFALLOFF: boolean;
  134842. TWOSIDEDLIGHTING: boolean;
  134843. SHADOWFLOAT: boolean;
  134844. CLIPPLANE: boolean;
  134845. CLIPPLANE2: boolean;
  134846. CLIPPLANE3: boolean;
  134847. CLIPPLANE4: boolean;
  134848. CLIPPLANE5: boolean;
  134849. CLIPPLANE6: boolean;
  134850. POINTSIZE: boolean;
  134851. FOG: boolean;
  134852. LOGARITHMICDEPTH: boolean;
  134853. FORCENORMALFORWARD: boolean;
  134854. SPECULARAA: boolean;
  134855. CLEARCOAT: boolean;
  134856. CLEARCOAT_DEFAULTIOR: boolean;
  134857. CLEARCOAT_TEXTURE: boolean;
  134858. CLEARCOAT_TEXTUREDIRECTUV: number;
  134859. CLEARCOAT_BUMP: boolean;
  134860. CLEARCOAT_BUMPDIRECTUV: number;
  134861. CLEARCOAT_TINT: boolean;
  134862. CLEARCOAT_TINT_TEXTURE: boolean;
  134863. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134864. ANISOTROPIC: boolean;
  134865. ANISOTROPIC_TEXTURE: boolean;
  134866. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134867. BRDF_V_HEIGHT_CORRELATED: boolean;
  134868. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134869. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134870. SHEEN: boolean;
  134871. SHEEN_TEXTURE: boolean;
  134872. SHEEN_TEXTUREDIRECTUV: number;
  134873. SHEEN_LINKWITHALBEDO: boolean;
  134874. SHEEN_ROUGHNESS: boolean;
  134875. SHEEN_ALBEDOSCALING: boolean;
  134876. SUBSURFACE: boolean;
  134877. SS_REFRACTION: boolean;
  134878. SS_TRANSLUCENCY: boolean;
  134879. SS_SCATTERING: boolean;
  134880. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134881. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134882. SS_REFRACTIONMAP_3D: boolean;
  134883. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134884. SS_LODINREFRACTIONALPHA: boolean;
  134885. SS_GAMMAREFRACTION: boolean;
  134886. SS_RGBDREFRACTION: boolean;
  134887. SS_LINEARSPECULARREFRACTION: boolean;
  134888. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134889. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134890. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134891. UNLIT: boolean;
  134892. DEBUGMODE: number;
  134893. /**
  134894. * Initializes the PBR Material defines.
  134895. */
  134896. constructor();
  134897. /**
  134898. * Resets the PBR Material defines.
  134899. */
  134900. reset(): void;
  134901. }
  134902. /**
  134903. * The Physically based material base class of BJS.
  134904. *
  134905. * This offers the main features of a standard PBR material.
  134906. * For more information, please refer to the documentation :
  134907. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134908. */
  134909. export abstract class PBRBaseMaterial extends PushMaterial {
  134910. /**
  134911. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134912. */
  134913. static readonly PBRMATERIAL_OPAQUE: number;
  134914. /**
  134915. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134916. */
  134917. static readonly PBRMATERIAL_ALPHATEST: number;
  134918. /**
  134919. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134920. */
  134921. static readonly PBRMATERIAL_ALPHABLEND: number;
  134922. /**
  134923. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134924. * They are also discarded below the alpha cutoff threshold to improve performances.
  134925. */
  134926. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134927. /**
  134928. * Defines the default value of how much AO map is occluding the analytical lights
  134929. * (point spot...).
  134930. */
  134931. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134932. /**
  134933. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  134934. */
  134935. static readonly LIGHTFALLOFF_PHYSICAL: number;
  134936. /**
  134937. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  134938. * to enhance interoperability with other engines.
  134939. */
  134940. static readonly LIGHTFALLOFF_GLTF: number;
  134941. /**
  134942. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  134943. * to enhance interoperability with other materials.
  134944. */
  134945. static readonly LIGHTFALLOFF_STANDARD: number;
  134946. /**
  134947. * Intensity of the direct lights e.g. the four lights available in your scene.
  134948. * This impacts both the direct diffuse and specular highlights.
  134949. */
  134950. protected _directIntensity: number;
  134951. /**
  134952. * Intensity of the emissive part of the material.
  134953. * This helps controlling the emissive effect without modifying the emissive color.
  134954. */
  134955. protected _emissiveIntensity: number;
  134956. /**
  134957. * Intensity of the environment e.g. how much the environment will light the object
  134958. * either through harmonics for rough material or through the refelction for shiny ones.
  134959. */
  134960. protected _environmentIntensity: number;
  134961. /**
  134962. * This is a special control allowing the reduction of the specular highlights coming from the
  134963. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134964. */
  134965. protected _specularIntensity: number;
  134966. /**
  134967. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  134968. */
  134969. private _lightingInfos;
  134970. /**
  134971. * Debug Control allowing disabling the bump map on this material.
  134972. */
  134973. protected _disableBumpMap: boolean;
  134974. /**
  134975. * AKA Diffuse Texture in standard nomenclature.
  134976. */
  134977. protected _albedoTexture: Nullable<BaseTexture>;
  134978. /**
  134979. * AKA Occlusion Texture in other nomenclature.
  134980. */
  134981. protected _ambientTexture: Nullable<BaseTexture>;
  134982. /**
  134983. * AKA Occlusion Texture Intensity in other nomenclature.
  134984. */
  134985. protected _ambientTextureStrength: number;
  134986. /**
  134987. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134988. * 1 means it completely occludes it
  134989. * 0 mean it has no impact
  134990. */
  134991. protected _ambientTextureImpactOnAnalyticalLights: number;
  134992. /**
  134993. * Stores the alpha values in a texture.
  134994. */
  134995. protected _opacityTexture: Nullable<BaseTexture>;
  134996. /**
  134997. * Stores the reflection values in a texture.
  134998. */
  134999. protected _reflectionTexture: Nullable<BaseTexture>;
  135000. /**
  135001. * Stores the emissive values in a texture.
  135002. */
  135003. protected _emissiveTexture: Nullable<BaseTexture>;
  135004. /**
  135005. * AKA Specular texture in other nomenclature.
  135006. */
  135007. protected _reflectivityTexture: Nullable<BaseTexture>;
  135008. /**
  135009. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135010. */
  135011. protected _metallicTexture: Nullable<BaseTexture>;
  135012. /**
  135013. * Specifies the metallic scalar of the metallic/roughness workflow.
  135014. * Can also be used to scale the metalness values of the metallic texture.
  135015. */
  135016. protected _metallic: Nullable<number>;
  135017. /**
  135018. * Specifies the roughness scalar of the metallic/roughness workflow.
  135019. * Can also be used to scale the roughness values of the metallic texture.
  135020. */
  135021. protected _roughness: Nullable<number>;
  135022. /**
  135023. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135024. * By default the indexOfrefraction is used to compute F0;
  135025. *
  135026. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135027. *
  135028. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135029. * F90 = metallicReflectanceColor;
  135030. */
  135031. protected _metallicF0Factor: number;
  135032. /**
  135033. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135034. * By default the F90 is always 1;
  135035. *
  135036. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135037. *
  135038. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135039. * F90 = metallicReflectanceColor;
  135040. */
  135041. protected _metallicReflectanceColor: Color3;
  135042. /**
  135043. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135044. * This is multiply against the scalar values defined in the material.
  135045. */
  135046. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  135047. /**
  135048. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135049. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135050. */
  135051. protected _microSurfaceTexture: Nullable<BaseTexture>;
  135052. /**
  135053. * Stores surface normal data used to displace a mesh in a texture.
  135054. */
  135055. protected _bumpTexture: Nullable<BaseTexture>;
  135056. /**
  135057. * Stores the pre-calculated light information of a mesh in a texture.
  135058. */
  135059. protected _lightmapTexture: Nullable<BaseTexture>;
  135060. /**
  135061. * The color of a material in ambient lighting.
  135062. */
  135063. protected _ambientColor: Color3;
  135064. /**
  135065. * AKA Diffuse Color in other nomenclature.
  135066. */
  135067. protected _albedoColor: Color3;
  135068. /**
  135069. * AKA Specular Color in other nomenclature.
  135070. */
  135071. protected _reflectivityColor: Color3;
  135072. /**
  135073. * The color applied when light is reflected from a material.
  135074. */
  135075. protected _reflectionColor: Color3;
  135076. /**
  135077. * The color applied when light is emitted from a material.
  135078. */
  135079. protected _emissiveColor: Color3;
  135080. /**
  135081. * AKA Glossiness in other nomenclature.
  135082. */
  135083. protected _microSurface: number;
  135084. /**
  135085. * Specifies that the material will use the light map as a show map.
  135086. */
  135087. protected _useLightmapAsShadowmap: boolean;
  135088. /**
  135089. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135090. * makes the reflect vector face the model (under horizon).
  135091. */
  135092. protected _useHorizonOcclusion: boolean;
  135093. /**
  135094. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135095. * too much the area relying on ambient texture to define their ambient occlusion.
  135096. */
  135097. protected _useRadianceOcclusion: boolean;
  135098. /**
  135099. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135100. */
  135101. protected _useAlphaFromAlbedoTexture: boolean;
  135102. /**
  135103. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  135104. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135105. */
  135106. protected _useSpecularOverAlpha: boolean;
  135107. /**
  135108. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135109. */
  135110. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135111. /**
  135112. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135113. */
  135114. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  135115. /**
  135116. * Specifies if the metallic texture contains the roughness information in its green channel.
  135117. */
  135118. protected _useRoughnessFromMetallicTextureGreen: boolean;
  135119. /**
  135120. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135121. */
  135122. protected _useMetallnessFromMetallicTextureBlue: boolean;
  135123. /**
  135124. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135125. */
  135126. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  135127. /**
  135128. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135129. */
  135130. protected _useAmbientInGrayScale: boolean;
  135131. /**
  135132. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135133. * The material will try to infer what glossiness each pixel should be.
  135134. */
  135135. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  135136. /**
  135137. * Defines the falloff type used in this material.
  135138. * It by default is Physical.
  135139. */
  135140. protected _lightFalloff: number;
  135141. /**
  135142. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135143. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135144. */
  135145. protected _useRadianceOverAlpha: boolean;
  135146. /**
  135147. * Allows using an object space normal map (instead of tangent space).
  135148. */
  135149. protected _useObjectSpaceNormalMap: boolean;
  135150. /**
  135151. * Allows using the bump map in parallax mode.
  135152. */
  135153. protected _useParallax: boolean;
  135154. /**
  135155. * Allows using the bump map in parallax occlusion mode.
  135156. */
  135157. protected _useParallaxOcclusion: boolean;
  135158. /**
  135159. * Controls the scale bias of the parallax mode.
  135160. */
  135161. protected _parallaxScaleBias: number;
  135162. /**
  135163. * If sets to true, disables all the lights affecting the material.
  135164. */
  135165. protected _disableLighting: boolean;
  135166. /**
  135167. * Number of Simultaneous lights allowed on the material.
  135168. */
  135169. protected _maxSimultaneousLights: number;
  135170. /**
  135171. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135172. */
  135173. protected _invertNormalMapX: boolean;
  135174. /**
  135175. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135176. */
  135177. protected _invertNormalMapY: boolean;
  135178. /**
  135179. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135180. */
  135181. protected _twoSidedLighting: boolean;
  135182. /**
  135183. * Defines the alpha limits in alpha test mode.
  135184. */
  135185. protected _alphaCutOff: number;
  135186. /**
  135187. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135188. */
  135189. protected _forceAlphaTest: boolean;
  135190. /**
  135191. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135192. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135193. */
  135194. protected _useAlphaFresnel: boolean;
  135195. /**
  135196. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135197. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135198. */
  135199. protected _useLinearAlphaFresnel: boolean;
  135200. /**
  135201. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  135202. * from cos thetav and roughness:
  135203. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  135204. */
  135205. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  135206. /**
  135207. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135208. */
  135209. protected _forceIrradianceInFragment: boolean;
  135210. private _realTimeFiltering;
  135211. /**
  135212. * Enables realtime filtering on the texture.
  135213. */
  135214. get realTimeFiltering(): boolean;
  135215. set realTimeFiltering(b: boolean);
  135216. private _realTimeFilteringQuality;
  135217. /**
  135218. * Quality switch for realtime filtering
  135219. */
  135220. get realTimeFilteringQuality(): number;
  135221. set realTimeFilteringQuality(n: number);
  135222. /**
  135223. * Can this material render to several textures at once
  135224. */
  135225. get canRenderToMRT(): boolean;
  135226. /**
  135227. * Force normal to face away from face.
  135228. */
  135229. protected _forceNormalForward: boolean;
  135230. /**
  135231. * Enables specular anti aliasing in the PBR shader.
  135232. * It will both interacts on the Geometry for analytical and IBL lighting.
  135233. * It also prefilter the roughness map based on the bump values.
  135234. */
  135235. protected _enableSpecularAntiAliasing: boolean;
  135236. /**
  135237. * Default configuration related to image processing available in the PBR Material.
  135238. */
  135239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135240. /**
  135241. * Keep track of the image processing observer to allow dispose and replace.
  135242. */
  135243. private _imageProcessingObserver;
  135244. /**
  135245. * Attaches a new image processing configuration to the PBR Material.
  135246. * @param configuration
  135247. */
  135248. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135249. /**
  135250. * Stores the available render targets.
  135251. */
  135252. private _renderTargets;
  135253. /**
  135254. * Sets the global ambient color for the material used in lighting calculations.
  135255. */
  135256. private _globalAmbientColor;
  135257. /**
  135258. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  135259. */
  135260. private _useLogarithmicDepth;
  135261. /**
  135262. * If set to true, no lighting calculations will be applied.
  135263. */
  135264. private _unlit;
  135265. private _debugMode;
  135266. /**
  135267. * @hidden
  135268. * This is reserved for the inspector.
  135269. * Defines the material debug mode.
  135270. * It helps seeing only some components of the material while troubleshooting.
  135271. */
  135272. debugMode: number;
  135273. /**
  135274. * @hidden
  135275. * This is reserved for the inspector.
  135276. * Specify from where on screen the debug mode should start.
  135277. * The value goes from -1 (full screen) to 1 (not visible)
  135278. * It helps with side by side comparison against the final render
  135279. * This defaults to -1
  135280. */
  135281. private debugLimit;
  135282. /**
  135283. * @hidden
  135284. * This is reserved for the inspector.
  135285. * As the default viewing range might not be enough (if the ambient is really small for instance)
  135286. * You can use the factor to better multiply the final value.
  135287. */
  135288. private debugFactor;
  135289. /**
  135290. * Defines the clear coat layer parameters for the material.
  135291. */
  135292. readonly clearCoat: PBRClearCoatConfiguration;
  135293. /**
  135294. * Defines the anisotropic parameters for the material.
  135295. */
  135296. readonly anisotropy: PBRAnisotropicConfiguration;
  135297. /**
  135298. * Defines the BRDF parameters for the material.
  135299. */
  135300. readonly brdf: PBRBRDFConfiguration;
  135301. /**
  135302. * Defines the Sheen parameters for the material.
  135303. */
  135304. readonly sheen: PBRSheenConfiguration;
  135305. /**
  135306. * Defines the SubSurface parameters for the material.
  135307. */
  135308. readonly subSurface: PBRSubSurfaceConfiguration;
  135309. /**
  135310. * Defines the detail map parameters for the material.
  135311. */
  135312. readonly detailMap: DetailMapConfiguration;
  135313. protected _rebuildInParallel: boolean;
  135314. /**
  135315. * Instantiates a new PBRMaterial instance.
  135316. *
  135317. * @param name The material name
  135318. * @param scene The scene the material will be use in.
  135319. */
  135320. constructor(name: string, scene: Scene);
  135321. /**
  135322. * Gets a boolean indicating that current material needs to register RTT
  135323. */
  135324. get hasRenderTargetTextures(): boolean;
  135325. /**
  135326. * Gets the name of the material class.
  135327. */
  135328. getClassName(): string;
  135329. /**
  135330. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135331. */
  135332. get useLogarithmicDepth(): boolean;
  135333. /**
  135334. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135335. */
  135336. set useLogarithmicDepth(value: boolean);
  135337. /**
  135338. * Returns true if alpha blending should be disabled.
  135339. */
  135340. protected get _disableAlphaBlending(): boolean;
  135341. /**
  135342. * Specifies whether or not this material should be rendered in alpha blend mode.
  135343. */
  135344. needAlphaBlending(): boolean;
  135345. /**
  135346. * Specifies whether or not this material should be rendered in alpha test mode.
  135347. */
  135348. needAlphaTesting(): boolean;
  135349. /**
  135350. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  135351. */
  135352. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  135353. /**
  135354. * Gets the texture used for the alpha test.
  135355. */
  135356. getAlphaTestTexture(): Nullable<BaseTexture>;
  135357. /**
  135358. * Specifies that the submesh is ready to be used.
  135359. * @param mesh - BJS mesh.
  135360. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  135361. * @param useInstances - Specifies that instances should be used.
  135362. * @returns - boolean indicating that the submesh is ready or not.
  135363. */
  135364. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135365. /**
  135366. * Specifies if the material uses metallic roughness workflow.
  135367. * @returns boolean specifiying if the material uses metallic roughness workflow.
  135368. */
  135369. isMetallicWorkflow(): boolean;
  135370. private _prepareEffect;
  135371. private _prepareDefines;
  135372. /**
  135373. * Force shader compilation
  135374. */
  135375. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  135376. /**
  135377. * Initializes the uniform buffer layout for the shader.
  135378. */
  135379. buildUniformLayout(): void;
  135380. /**
  135381. * Unbinds the material from the mesh
  135382. */
  135383. unbind(): void;
  135384. /**
  135385. * Binds the submesh data.
  135386. * @param world - The world matrix.
  135387. * @param mesh - The BJS mesh.
  135388. * @param subMesh - A submesh of the BJS mesh.
  135389. */
  135390. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135391. /**
  135392. * Returns the animatable textures.
  135393. * @returns - Array of animatable textures.
  135394. */
  135395. getAnimatables(): IAnimatable[];
  135396. /**
  135397. * Returns the texture used for reflections.
  135398. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  135399. */
  135400. private _getReflectionTexture;
  135401. /**
  135402. * Returns an array of the actively used textures.
  135403. * @returns - Array of BaseTextures
  135404. */
  135405. getActiveTextures(): BaseTexture[];
  135406. /**
  135407. * Checks to see if a texture is used in the material.
  135408. * @param texture - Base texture to use.
  135409. * @returns - Boolean specifying if a texture is used in the material.
  135410. */
  135411. hasTexture(texture: BaseTexture): boolean;
  135412. /**
  135413. * Sets the required values to the prepass renderer.
  135414. * @param prePassRenderer defines the prepass renderer to setup
  135415. */
  135416. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  135417. /**
  135418. * Disposes the resources of the material.
  135419. * @param forceDisposeEffect - Forces the disposal of effects.
  135420. * @param forceDisposeTextures - Forces the disposal of all textures.
  135421. */
  135422. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135423. }
  135424. }
  135425. declare module BABYLON {
  135426. /**
  135427. * The Physically based material of BJS.
  135428. *
  135429. * This offers the main features of a standard PBR material.
  135430. * For more information, please refer to the documentation :
  135431. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135432. */
  135433. export class PBRMaterial extends PBRBaseMaterial {
  135434. /**
  135435. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135436. */
  135437. static readonly PBRMATERIAL_OPAQUE: number;
  135438. /**
  135439. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135440. */
  135441. static readonly PBRMATERIAL_ALPHATEST: number;
  135442. /**
  135443. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135444. */
  135445. static readonly PBRMATERIAL_ALPHABLEND: number;
  135446. /**
  135447. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135448. * They are also discarded below the alpha cutoff threshold to improve performances.
  135449. */
  135450. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135451. /**
  135452. * Defines the default value of how much AO map is occluding the analytical lights
  135453. * (point spot...).
  135454. */
  135455. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135456. /**
  135457. * Intensity of the direct lights e.g. the four lights available in your scene.
  135458. * This impacts both the direct diffuse and specular highlights.
  135459. */
  135460. directIntensity: number;
  135461. /**
  135462. * Intensity of the emissive part of the material.
  135463. * This helps controlling the emissive effect without modifying the emissive color.
  135464. */
  135465. emissiveIntensity: number;
  135466. /**
  135467. * Intensity of the environment e.g. how much the environment will light the object
  135468. * either through harmonics for rough material or through the refelction for shiny ones.
  135469. */
  135470. environmentIntensity: number;
  135471. /**
  135472. * This is a special control allowing the reduction of the specular highlights coming from the
  135473. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135474. */
  135475. specularIntensity: number;
  135476. /**
  135477. * Debug Control allowing disabling the bump map on this material.
  135478. */
  135479. disableBumpMap: boolean;
  135480. /**
  135481. * AKA Diffuse Texture in standard nomenclature.
  135482. */
  135483. albedoTexture: BaseTexture;
  135484. /**
  135485. * AKA Occlusion Texture in other nomenclature.
  135486. */
  135487. ambientTexture: BaseTexture;
  135488. /**
  135489. * AKA Occlusion Texture Intensity in other nomenclature.
  135490. */
  135491. ambientTextureStrength: number;
  135492. /**
  135493. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135494. * 1 means it completely occludes it
  135495. * 0 mean it has no impact
  135496. */
  135497. ambientTextureImpactOnAnalyticalLights: number;
  135498. /**
  135499. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  135500. */
  135501. opacityTexture: BaseTexture;
  135502. /**
  135503. * Stores the reflection values in a texture.
  135504. */
  135505. reflectionTexture: Nullable<BaseTexture>;
  135506. /**
  135507. * Stores the emissive values in a texture.
  135508. */
  135509. emissiveTexture: BaseTexture;
  135510. /**
  135511. * AKA Specular texture in other nomenclature.
  135512. */
  135513. reflectivityTexture: BaseTexture;
  135514. /**
  135515. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135516. */
  135517. metallicTexture: BaseTexture;
  135518. /**
  135519. * Specifies the metallic scalar of the metallic/roughness workflow.
  135520. * Can also be used to scale the metalness values of the metallic texture.
  135521. */
  135522. metallic: Nullable<number>;
  135523. /**
  135524. * Specifies the roughness scalar of the metallic/roughness workflow.
  135525. * Can also be used to scale the roughness values of the metallic texture.
  135526. */
  135527. roughness: Nullable<number>;
  135528. /**
  135529. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135530. * By default the indexOfrefraction is used to compute F0;
  135531. *
  135532. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135533. *
  135534. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135535. * F90 = metallicReflectanceColor;
  135536. */
  135537. metallicF0Factor: number;
  135538. /**
  135539. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135540. * By default the F90 is always 1;
  135541. *
  135542. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135543. *
  135544. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135545. * F90 = metallicReflectanceColor;
  135546. */
  135547. metallicReflectanceColor: Color3;
  135548. /**
  135549. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135550. * This is multiply against the scalar values defined in the material.
  135551. */
  135552. metallicReflectanceTexture: Nullable<BaseTexture>;
  135553. /**
  135554. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135555. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135556. */
  135557. microSurfaceTexture: BaseTexture;
  135558. /**
  135559. * Stores surface normal data used to displace a mesh in a texture.
  135560. */
  135561. bumpTexture: BaseTexture;
  135562. /**
  135563. * Stores the pre-calculated light information of a mesh in a texture.
  135564. */
  135565. lightmapTexture: BaseTexture;
  135566. /**
  135567. * Stores the refracted light information in a texture.
  135568. */
  135569. get refractionTexture(): Nullable<BaseTexture>;
  135570. set refractionTexture(value: Nullable<BaseTexture>);
  135571. /**
  135572. * The color of a material in ambient lighting.
  135573. */
  135574. ambientColor: Color3;
  135575. /**
  135576. * AKA Diffuse Color in other nomenclature.
  135577. */
  135578. albedoColor: Color3;
  135579. /**
  135580. * AKA Specular Color in other nomenclature.
  135581. */
  135582. reflectivityColor: Color3;
  135583. /**
  135584. * The color reflected from the material.
  135585. */
  135586. reflectionColor: Color3;
  135587. /**
  135588. * The color emitted from the material.
  135589. */
  135590. emissiveColor: Color3;
  135591. /**
  135592. * AKA Glossiness in other nomenclature.
  135593. */
  135594. microSurface: number;
  135595. /**
  135596. * Index of refraction of the material base layer.
  135597. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135598. *
  135599. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135600. *
  135601. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135602. */
  135603. get indexOfRefraction(): number;
  135604. set indexOfRefraction(value: number);
  135605. /**
  135606. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135607. */
  135608. get invertRefractionY(): boolean;
  135609. set invertRefractionY(value: boolean);
  135610. /**
  135611. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135612. * Materials half opaque for instance using refraction could benefit from this control.
  135613. */
  135614. get linkRefractionWithTransparency(): boolean;
  135615. set linkRefractionWithTransparency(value: boolean);
  135616. /**
  135617. * If true, the light map contains occlusion information instead of lighting info.
  135618. */
  135619. useLightmapAsShadowmap: boolean;
  135620. /**
  135621. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135622. */
  135623. useAlphaFromAlbedoTexture: boolean;
  135624. /**
  135625. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135626. */
  135627. forceAlphaTest: boolean;
  135628. /**
  135629. * Defines the alpha limits in alpha test mode.
  135630. */
  135631. alphaCutOff: number;
  135632. /**
  135633. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  135634. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135635. */
  135636. useSpecularOverAlpha: boolean;
  135637. /**
  135638. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135639. */
  135640. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135641. /**
  135642. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135643. */
  135644. useRoughnessFromMetallicTextureAlpha: boolean;
  135645. /**
  135646. * Specifies if the metallic texture contains the roughness information in its green channel.
  135647. */
  135648. useRoughnessFromMetallicTextureGreen: boolean;
  135649. /**
  135650. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135651. */
  135652. useMetallnessFromMetallicTextureBlue: boolean;
  135653. /**
  135654. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135655. */
  135656. useAmbientOcclusionFromMetallicTextureRed: boolean;
  135657. /**
  135658. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135659. */
  135660. useAmbientInGrayScale: boolean;
  135661. /**
  135662. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135663. * The material will try to infer what glossiness each pixel should be.
  135664. */
  135665. useAutoMicroSurfaceFromReflectivityMap: boolean;
  135666. /**
  135667. * BJS is using an harcoded light falloff based on a manually sets up range.
  135668. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135669. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135670. */
  135671. get usePhysicalLightFalloff(): boolean;
  135672. /**
  135673. * BJS is using an harcoded light falloff based on a manually sets up range.
  135674. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135675. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135676. */
  135677. set usePhysicalLightFalloff(value: boolean);
  135678. /**
  135679. * In order to support the falloff compatibility with gltf, a special mode has been added
  135680. * to reproduce the gltf light falloff.
  135681. */
  135682. get useGLTFLightFalloff(): boolean;
  135683. /**
  135684. * In order to support the falloff compatibility with gltf, a special mode has been added
  135685. * to reproduce the gltf light falloff.
  135686. */
  135687. set useGLTFLightFalloff(value: boolean);
  135688. /**
  135689. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135690. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135691. */
  135692. useRadianceOverAlpha: boolean;
  135693. /**
  135694. * Allows using an object space normal map (instead of tangent space).
  135695. */
  135696. useObjectSpaceNormalMap: boolean;
  135697. /**
  135698. * Allows using the bump map in parallax mode.
  135699. */
  135700. useParallax: boolean;
  135701. /**
  135702. * Allows using the bump map in parallax occlusion mode.
  135703. */
  135704. useParallaxOcclusion: boolean;
  135705. /**
  135706. * Controls the scale bias of the parallax mode.
  135707. */
  135708. parallaxScaleBias: number;
  135709. /**
  135710. * If sets to true, disables all the lights affecting the material.
  135711. */
  135712. disableLighting: boolean;
  135713. /**
  135714. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135715. */
  135716. forceIrradianceInFragment: boolean;
  135717. /**
  135718. * Number of Simultaneous lights allowed on the material.
  135719. */
  135720. maxSimultaneousLights: number;
  135721. /**
  135722. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  135723. */
  135724. invertNormalMapX: boolean;
  135725. /**
  135726. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  135727. */
  135728. invertNormalMapY: boolean;
  135729. /**
  135730. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135731. */
  135732. twoSidedLighting: boolean;
  135733. /**
  135734. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135735. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135736. */
  135737. useAlphaFresnel: boolean;
  135738. /**
  135739. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135740. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135741. */
  135742. useLinearAlphaFresnel: boolean;
  135743. /**
  135744. * Let user defines the brdf lookup texture used for IBL.
  135745. * A default 8bit version is embedded but you could point at :
  135746. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  135747. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  135748. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  135749. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  135750. */
  135751. environmentBRDFTexture: Nullable<BaseTexture>;
  135752. /**
  135753. * Force normal to face away from face.
  135754. */
  135755. forceNormalForward: boolean;
  135756. /**
  135757. * Enables specular anti aliasing in the PBR shader.
  135758. * It will both interacts on the Geometry for analytical and IBL lighting.
  135759. * It also prefilter the roughness map based on the bump values.
  135760. */
  135761. enableSpecularAntiAliasing: boolean;
  135762. /**
  135763. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135764. * makes the reflect vector face the model (under horizon).
  135765. */
  135766. useHorizonOcclusion: boolean;
  135767. /**
  135768. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135769. * too much the area relying on ambient texture to define their ambient occlusion.
  135770. */
  135771. useRadianceOcclusion: boolean;
  135772. /**
  135773. * If set to true, no lighting calculations will be applied.
  135774. */
  135775. unlit: boolean;
  135776. /**
  135777. * Gets the image processing configuration used either in this material.
  135778. */
  135779. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  135780. /**
  135781. * Sets the Default image processing configuration used either in the this material.
  135782. *
  135783. * If sets to null, the scene one is in use.
  135784. */
  135785. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  135786. /**
  135787. * Gets wether the color curves effect is enabled.
  135788. */
  135789. get cameraColorCurvesEnabled(): boolean;
  135790. /**
  135791. * Sets wether the color curves effect is enabled.
  135792. */
  135793. set cameraColorCurvesEnabled(value: boolean);
  135794. /**
  135795. * Gets wether the color grading effect is enabled.
  135796. */
  135797. get cameraColorGradingEnabled(): boolean;
  135798. /**
  135799. * Gets wether the color grading effect is enabled.
  135800. */
  135801. set cameraColorGradingEnabled(value: boolean);
  135802. /**
  135803. * Gets wether tonemapping is enabled or not.
  135804. */
  135805. get cameraToneMappingEnabled(): boolean;
  135806. /**
  135807. * Sets wether tonemapping is enabled or not
  135808. */
  135809. set cameraToneMappingEnabled(value: boolean);
  135810. /**
  135811. * The camera exposure used on this material.
  135812. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135813. * This corresponds to a photographic exposure.
  135814. */
  135815. get cameraExposure(): number;
  135816. /**
  135817. * The camera exposure used on this material.
  135818. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135819. * This corresponds to a photographic exposure.
  135820. */
  135821. set cameraExposure(value: number);
  135822. /**
  135823. * Gets The camera contrast used on this material.
  135824. */
  135825. get cameraContrast(): number;
  135826. /**
  135827. * Sets The camera contrast used on this material.
  135828. */
  135829. set cameraContrast(value: number);
  135830. /**
  135831. * Gets the Color Grading 2D Lookup Texture.
  135832. */
  135833. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135834. /**
  135835. * Sets the Color Grading 2D Lookup Texture.
  135836. */
  135837. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135838. /**
  135839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135841. * 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;
  135842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135843. */
  135844. get cameraColorCurves(): Nullable<ColorCurves>;
  135845. /**
  135846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135848. * 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;
  135849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135850. */
  135851. set cameraColorCurves(value: Nullable<ColorCurves>);
  135852. /**
  135853. * Instantiates a new PBRMaterial instance.
  135854. *
  135855. * @param name The material name
  135856. * @param scene The scene the material will be use in.
  135857. */
  135858. constructor(name: string, scene: Scene);
  135859. /**
  135860. * Returns the name of this material class.
  135861. */
  135862. getClassName(): string;
  135863. /**
  135864. * Makes a duplicate of the current material.
  135865. * @param name - name to use for the new material.
  135866. */
  135867. clone(name: string): PBRMaterial;
  135868. /**
  135869. * Serializes this PBR Material.
  135870. * @returns - An object with the serialized material.
  135871. */
  135872. serialize(): any;
  135873. /**
  135874. * Parses a PBR Material from a serialized object.
  135875. * @param source - Serialized object.
  135876. * @param scene - BJS scene instance.
  135877. * @param rootUrl - url for the scene object
  135878. * @returns - PBRMaterial
  135879. */
  135880. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  135881. }
  135882. }
  135883. declare module BABYLON {
  135884. /**
  135885. * Direct draw surface info
  135886. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  135887. */
  135888. export interface DDSInfo {
  135889. /**
  135890. * Width of the texture
  135891. */
  135892. width: number;
  135893. /**
  135894. * Width of the texture
  135895. */
  135896. height: number;
  135897. /**
  135898. * Number of Mipmaps for the texture
  135899. * @see https://en.wikipedia.org/wiki/Mipmap
  135900. */
  135901. mipmapCount: number;
  135902. /**
  135903. * If the textures format is a known fourCC format
  135904. * @see https://www.fourcc.org/
  135905. */
  135906. isFourCC: boolean;
  135907. /**
  135908. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  135909. */
  135910. isRGB: boolean;
  135911. /**
  135912. * If the texture is a lumincance format
  135913. */
  135914. isLuminance: boolean;
  135915. /**
  135916. * If this is a cube texture
  135917. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  135918. */
  135919. isCube: boolean;
  135920. /**
  135921. * If the texture is a compressed format eg. FOURCC_DXT1
  135922. */
  135923. isCompressed: boolean;
  135924. /**
  135925. * The dxgiFormat of the texture
  135926. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  135927. */
  135928. dxgiFormat: number;
  135929. /**
  135930. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  135931. */
  135932. textureType: number;
  135933. /**
  135934. * Sphericle polynomial created for the dds texture
  135935. */
  135936. sphericalPolynomial?: SphericalPolynomial;
  135937. }
  135938. /**
  135939. * Class used to provide DDS decompression tools
  135940. */
  135941. export class DDSTools {
  135942. /**
  135943. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  135944. */
  135945. static StoreLODInAlphaChannel: boolean;
  135946. /**
  135947. * Gets DDS information from an array buffer
  135948. * @param data defines the array buffer view to read data from
  135949. * @returns the DDS information
  135950. */
  135951. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  135952. private static _FloatView;
  135953. private static _Int32View;
  135954. private static _ToHalfFloat;
  135955. private static _FromHalfFloat;
  135956. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  135957. private static _GetHalfFloatRGBAArrayBuffer;
  135958. private static _GetFloatRGBAArrayBuffer;
  135959. private static _GetFloatAsUIntRGBAArrayBuffer;
  135960. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  135961. private static _GetRGBAArrayBuffer;
  135962. private static _ExtractLongWordOrder;
  135963. private static _GetRGBArrayBuffer;
  135964. private static _GetLuminanceArrayBuffer;
  135965. /**
  135966. * Uploads DDS Levels to a Babylon Texture
  135967. * @hidden
  135968. */
  135969. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  135970. }
  135971. interface ThinEngine {
  135972. /**
  135973. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  135974. * @param rootUrl defines the url where the file to load is located
  135975. * @param scene defines the current scene
  135976. * @param lodScale defines scale to apply to the mip map selection
  135977. * @param lodOffset defines offset to apply to the mip map selection
  135978. * @param onLoad defines an optional callback raised when the texture is loaded
  135979. * @param onError defines an optional callback raised if there is an issue to load the texture
  135980. * @param format defines the format of the data
  135981. * @param forcedExtension defines the extension to use to pick the right loader
  135982. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  135983. * @returns the cube texture as an InternalTexture
  135984. */
  135985. 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;
  135986. }
  135987. }
  135988. declare module BABYLON {
  135989. /**
  135990. * Implementation of the DDS Texture Loader.
  135991. * @hidden
  135992. */
  135993. export class _DDSTextureLoader implements IInternalTextureLoader {
  135994. /**
  135995. * Defines wether the loader supports cascade loading the different faces.
  135996. */
  135997. readonly supportCascades: boolean;
  135998. /**
  135999. * This returns if the loader support the current file information.
  136000. * @param extension defines the file extension of the file being loaded
  136001. * @returns true if the loader can load the specified file
  136002. */
  136003. canLoad(extension: string): boolean;
  136004. /**
  136005. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136006. * @param data contains the texture data
  136007. * @param texture defines the BabylonJS internal texture
  136008. * @param createPolynomials will be true if polynomials have been requested
  136009. * @param onLoad defines the callback to trigger once the texture is ready
  136010. * @param onError defines the callback to trigger in case of error
  136011. */
  136012. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136013. /**
  136014. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136015. * @param data contains the texture data
  136016. * @param texture defines the BabylonJS internal texture
  136017. * @param callback defines the method to call once ready to upload
  136018. */
  136019. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136020. }
  136021. }
  136022. declare module BABYLON {
  136023. /**
  136024. * Implementation of the ENV Texture Loader.
  136025. * @hidden
  136026. */
  136027. export class _ENVTextureLoader implements IInternalTextureLoader {
  136028. /**
  136029. * Defines wether the loader supports cascade loading the different faces.
  136030. */
  136031. readonly supportCascades: boolean;
  136032. /**
  136033. * This returns if the loader support the current file information.
  136034. * @param extension defines the file extension of the file being loaded
  136035. * @returns true if the loader can load the specified file
  136036. */
  136037. canLoad(extension: string): boolean;
  136038. /**
  136039. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136040. * @param data contains the texture data
  136041. * @param texture defines the BabylonJS internal texture
  136042. * @param createPolynomials will be true if polynomials have been requested
  136043. * @param onLoad defines the callback to trigger once the texture is ready
  136044. * @param onError defines the callback to trigger in case of error
  136045. */
  136046. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136047. /**
  136048. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136049. * @param data contains the texture data
  136050. * @param texture defines the BabylonJS internal texture
  136051. * @param callback defines the method to call once ready to upload
  136052. */
  136053. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136054. }
  136055. }
  136056. declare module BABYLON {
  136057. /**
  136058. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136059. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136060. */
  136061. export class KhronosTextureContainer {
  136062. /** contents of the KTX container file */
  136063. data: ArrayBufferView;
  136064. private static HEADER_LEN;
  136065. private static COMPRESSED_2D;
  136066. private static COMPRESSED_3D;
  136067. private static TEX_2D;
  136068. private static TEX_3D;
  136069. /**
  136070. * Gets the openGL type
  136071. */
  136072. glType: number;
  136073. /**
  136074. * Gets the openGL type size
  136075. */
  136076. glTypeSize: number;
  136077. /**
  136078. * Gets the openGL format
  136079. */
  136080. glFormat: number;
  136081. /**
  136082. * Gets the openGL internal format
  136083. */
  136084. glInternalFormat: number;
  136085. /**
  136086. * Gets the base internal format
  136087. */
  136088. glBaseInternalFormat: number;
  136089. /**
  136090. * Gets image width in pixel
  136091. */
  136092. pixelWidth: number;
  136093. /**
  136094. * Gets image height in pixel
  136095. */
  136096. pixelHeight: number;
  136097. /**
  136098. * Gets image depth in pixels
  136099. */
  136100. pixelDepth: number;
  136101. /**
  136102. * Gets the number of array elements
  136103. */
  136104. numberOfArrayElements: number;
  136105. /**
  136106. * Gets the number of faces
  136107. */
  136108. numberOfFaces: number;
  136109. /**
  136110. * Gets the number of mipmap levels
  136111. */
  136112. numberOfMipmapLevels: number;
  136113. /**
  136114. * Gets the bytes of key value data
  136115. */
  136116. bytesOfKeyValueData: number;
  136117. /**
  136118. * Gets the load type
  136119. */
  136120. loadType: number;
  136121. /**
  136122. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  136123. */
  136124. isInvalid: boolean;
  136125. /**
  136126. * Creates a new KhronosTextureContainer
  136127. * @param data contents of the KTX container file
  136128. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  136129. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  136130. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  136131. */
  136132. constructor(
  136133. /** contents of the KTX container file */
  136134. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  136135. /**
  136136. * Uploads KTX content to a Babylon Texture.
  136137. * It is assumed that the texture has already been created & is currently bound
  136138. * @hidden
  136139. */
  136140. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  136141. private _upload2DCompressedLevels;
  136142. /**
  136143. * Checks if the given data starts with a KTX file identifier.
  136144. * @param data the data to check
  136145. * @returns true if the data is a KTX file or false otherwise
  136146. */
  136147. static IsValid(data: ArrayBufferView): boolean;
  136148. }
  136149. }
  136150. declare module BABYLON {
  136151. /**
  136152. * Class for loading KTX2 files
  136153. * !!! Experimental Extension Subject to Changes !!!
  136154. * @hidden
  136155. */
  136156. export class KhronosTextureContainer2 {
  136157. private static _ModulePromise;
  136158. private static _TranscodeFormat;
  136159. constructor(engine: ThinEngine);
  136160. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  136161. private _determineTranscodeFormat;
  136162. /**
  136163. * Checks if the given data starts with a KTX2 file identifier.
  136164. * @param data the data to check
  136165. * @returns true if the data is a KTX2 file or false otherwise
  136166. */
  136167. static IsValid(data: ArrayBufferView): boolean;
  136168. }
  136169. }
  136170. declare module BABYLON {
  136171. /**
  136172. * Implementation of the KTX Texture Loader.
  136173. * @hidden
  136174. */
  136175. export class _KTXTextureLoader implements IInternalTextureLoader {
  136176. /**
  136177. * Defines wether the loader supports cascade loading the different faces.
  136178. */
  136179. readonly supportCascades: boolean;
  136180. /**
  136181. * This returns if the loader support the current file information.
  136182. * @param extension defines the file extension of the file being loaded
  136183. * @param mimeType defines the optional mime type of the file being loaded
  136184. * @returns true if the loader can load the specified file
  136185. */
  136186. canLoad(extension: string, mimeType?: string): boolean;
  136187. /**
  136188. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136189. * @param data contains the texture data
  136190. * @param texture defines the BabylonJS internal texture
  136191. * @param createPolynomials will be true if polynomials have been requested
  136192. * @param onLoad defines the callback to trigger once the texture is ready
  136193. * @param onError defines the callback to trigger in case of error
  136194. */
  136195. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136196. /**
  136197. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136198. * @param data contains the texture data
  136199. * @param texture defines the BabylonJS internal texture
  136200. * @param callback defines the method to call once ready to upload
  136201. */
  136202. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  136203. }
  136204. }
  136205. declare module BABYLON {
  136206. /** @hidden */
  136207. export var _forceSceneHelpersToBundle: boolean;
  136208. interface Scene {
  136209. /**
  136210. * Creates a default light for the scene.
  136211. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  136212. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  136213. */
  136214. createDefaultLight(replace?: boolean): void;
  136215. /**
  136216. * Creates a default camera for the scene.
  136217. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  136218. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136219. * @param replace has default false, when true replaces the active camera in the scene
  136220. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  136221. */
  136222. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136223. /**
  136224. * Creates a default camera and a default light.
  136225. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  136226. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136227. * @param replace has the default false, when true replaces the active camera/light in the scene
  136228. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  136229. */
  136230. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136231. /**
  136232. * Creates a new sky box
  136233. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  136234. * @param environmentTexture defines the texture to use as environment texture
  136235. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  136236. * @param scale defines the overall scale of the skybox
  136237. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  136238. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  136239. * @returns a new mesh holding the sky box
  136240. */
  136241. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  136242. /**
  136243. * Creates a new environment
  136244. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  136245. * @param options defines the options you can use to configure the environment
  136246. * @returns the new EnvironmentHelper
  136247. */
  136248. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  136249. /**
  136250. * Creates a new VREXperienceHelper
  136251. * @see https://doc.babylonjs.com/how_to/webvr_helper
  136252. * @param webVROptions defines the options used to create the new VREXperienceHelper
  136253. * @returns a new VREXperienceHelper
  136254. */
  136255. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  136256. /**
  136257. * Creates a new WebXRDefaultExperience
  136258. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  136259. * @param options experience options
  136260. * @returns a promise for a new WebXRDefaultExperience
  136261. */
  136262. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  136263. }
  136264. }
  136265. declare module BABYLON {
  136266. /**
  136267. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  136268. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  136269. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  136270. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  136271. */
  136272. export class VideoDome extends TransformNode {
  136273. /**
  136274. * Define the video source as a Monoscopic panoramic 360 video.
  136275. */
  136276. static readonly MODE_MONOSCOPIC: number;
  136277. /**
  136278. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136279. */
  136280. static readonly MODE_TOPBOTTOM: number;
  136281. /**
  136282. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136283. */
  136284. static readonly MODE_SIDEBYSIDE: number;
  136285. private _halfDome;
  136286. private _useDirectMapping;
  136287. /**
  136288. * The video texture being displayed on the sphere
  136289. */
  136290. protected _videoTexture: VideoTexture;
  136291. /**
  136292. * Gets the video texture being displayed on the sphere
  136293. */
  136294. get videoTexture(): VideoTexture;
  136295. /**
  136296. * The skybox material
  136297. */
  136298. protected _material: BackgroundMaterial;
  136299. /**
  136300. * The surface used for the video dome
  136301. */
  136302. protected _mesh: Mesh;
  136303. /**
  136304. * Gets the mesh used for the video dome.
  136305. */
  136306. get mesh(): Mesh;
  136307. /**
  136308. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  136309. */
  136310. private _halfDomeMask;
  136311. /**
  136312. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  136313. * Also see the options.resolution property.
  136314. */
  136315. get fovMultiplier(): number;
  136316. set fovMultiplier(value: number);
  136317. private _videoMode;
  136318. /**
  136319. * Gets or set the current video mode for the video. It can be:
  136320. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  136321. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136322. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136323. */
  136324. get videoMode(): number;
  136325. set videoMode(value: number);
  136326. /**
  136327. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  136328. *
  136329. */
  136330. get halfDome(): boolean;
  136331. /**
  136332. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  136333. */
  136334. set halfDome(enabled: boolean);
  136335. /**
  136336. * Oberserver used in Stereoscopic VR Mode.
  136337. */
  136338. private _onBeforeCameraRenderObserver;
  136339. /**
  136340. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  136341. * @param name Element's name, child elements will append suffixes for their own names.
  136342. * @param urlsOrVideo defines the url(s) or the video element to use
  136343. * @param options An object containing optional or exposed sub element properties
  136344. */
  136345. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  136346. resolution?: number;
  136347. clickToPlay?: boolean;
  136348. autoPlay?: boolean;
  136349. loop?: boolean;
  136350. size?: number;
  136351. poster?: string;
  136352. faceForward?: boolean;
  136353. useDirectMapping?: boolean;
  136354. halfDomeMode?: boolean;
  136355. }, scene: Scene);
  136356. private _changeVideoMode;
  136357. /**
  136358. * Releases resources associated with this node.
  136359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  136360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  136361. */
  136362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  136363. }
  136364. }
  136365. declare module BABYLON {
  136366. /**
  136367. * This class can be used to get instrumentation data from a Babylon engine
  136368. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136369. */
  136370. export class EngineInstrumentation implements IDisposable {
  136371. /**
  136372. * Define the instrumented engine.
  136373. */
  136374. engine: Engine;
  136375. private _captureGPUFrameTime;
  136376. private _gpuFrameTimeToken;
  136377. private _gpuFrameTime;
  136378. private _captureShaderCompilationTime;
  136379. private _shaderCompilationTime;
  136380. private _onBeginFrameObserver;
  136381. private _onEndFrameObserver;
  136382. private _onBeforeShaderCompilationObserver;
  136383. private _onAfterShaderCompilationObserver;
  136384. /**
  136385. * Gets the perf counter used for GPU frame time
  136386. */
  136387. get gpuFrameTimeCounter(): PerfCounter;
  136388. /**
  136389. * Gets the GPU frame time capture status
  136390. */
  136391. get captureGPUFrameTime(): boolean;
  136392. /**
  136393. * Enable or disable the GPU frame time capture
  136394. */
  136395. set captureGPUFrameTime(value: boolean);
  136396. /**
  136397. * Gets the perf counter used for shader compilation time
  136398. */
  136399. get shaderCompilationTimeCounter(): PerfCounter;
  136400. /**
  136401. * Gets the shader compilation time capture status
  136402. */
  136403. get captureShaderCompilationTime(): boolean;
  136404. /**
  136405. * Enable or disable the shader compilation time capture
  136406. */
  136407. set captureShaderCompilationTime(value: boolean);
  136408. /**
  136409. * Instantiates a new engine instrumentation.
  136410. * This class can be used to get instrumentation data from a Babylon engine
  136411. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136412. * @param engine Defines the engine to instrument
  136413. */
  136414. constructor(
  136415. /**
  136416. * Define the instrumented engine.
  136417. */
  136418. engine: Engine);
  136419. /**
  136420. * Dispose and release associated resources.
  136421. */
  136422. dispose(): void;
  136423. }
  136424. }
  136425. declare module BABYLON {
  136426. /**
  136427. * This class can be used to get instrumentation data from a Babylon engine
  136428. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136429. */
  136430. export class SceneInstrumentation implements IDisposable {
  136431. /**
  136432. * Defines the scene to instrument
  136433. */
  136434. scene: Scene;
  136435. private _captureActiveMeshesEvaluationTime;
  136436. private _activeMeshesEvaluationTime;
  136437. private _captureRenderTargetsRenderTime;
  136438. private _renderTargetsRenderTime;
  136439. private _captureFrameTime;
  136440. private _frameTime;
  136441. private _captureRenderTime;
  136442. private _renderTime;
  136443. private _captureInterFrameTime;
  136444. private _interFrameTime;
  136445. private _captureParticlesRenderTime;
  136446. private _particlesRenderTime;
  136447. private _captureSpritesRenderTime;
  136448. private _spritesRenderTime;
  136449. private _capturePhysicsTime;
  136450. private _physicsTime;
  136451. private _captureAnimationsTime;
  136452. private _animationsTime;
  136453. private _captureCameraRenderTime;
  136454. private _cameraRenderTime;
  136455. private _onBeforeActiveMeshesEvaluationObserver;
  136456. private _onAfterActiveMeshesEvaluationObserver;
  136457. private _onBeforeRenderTargetsRenderObserver;
  136458. private _onAfterRenderTargetsRenderObserver;
  136459. private _onAfterRenderObserver;
  136460. private _onBeforeDrawPhaseObserver;
  136461. private _onAfterDrawPhaseObserver;
  136462. private _onBeforeAnimationsObserver;
  136463. private _onBeforeParticlesRenderingObserver;
  136464. private _onAfterParticlesRenderingObserver;
  136465. private _onBeforeSpritesRenderingObserver;
  136466. private _onAfterSpritesRenderingObserver;
  136467. private _onBeforePhysicsObserver;
  136468. private _onAfterPhysicsObserver;
  136469. private _onAfterAnimationsObserver;
  136470. private _onBeforeCameraRenderObserver;
  136471. private _onAfterCameraRenderObserver;
  136472. /**
  136473. * Gets the perf counter used for active meshes evaluation time
  136474. */
  136475. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  136476. /**
  136477. * Gets the active meshes evaluation time capture status
  136478. */
  136479. get captureActiveMeshesEvaluationTime(): boolean;
  136480. /**
  136481. * Enable or disable the active meshes evaluation time capture
  136482. */
  136483. set captureActiveMeshesEvaluationTime(value: boolean);
  136484. /**
  136485. * Gets the perf counter used for render targets render time
  136486. */
  136487. get renderTargetsRenderTimeCounter(): PerfCounter;
  136488. /**
  136489. * Gets the render targets render time capture status
  136490. */
  136491. get captureRenderTargetsRenderTime(): boolean;
  136492. /**
  136493. * Enable or disable the render targets render time capture
  136494. */
  136495. set captureRenderTargetsRenderTime(value: boolean);
  136496. /**
  136497. * Gets the perf counter used for particles render time
  136498. */
  136499. get particlesRenderTimeCounter(): PerfCounter;
  136500. /**
  136501. * Gets the particles render time capture status
  136502. */
  136503. get captureParticlesRenderTime(): boolean;
  136504. /**
  136505. * Enable or disable the particles render time capture
  136506. */
  136507. set captureParticlesRenderTime(value: boolean);
  136508. /**
  136509. * Gets the perf counter used for sprites render time
  136510. */
  136511. get spritesRenderTimeCounter(): PerfCounter;
  136512. /**
  136513. * Gets the sprites render time capture status
  136514. */
  136515. get captureSpritesRenderTime(): boolean;
  136516. /**
  136517. * Enable or disable the sprites render time capture
  136518. */
  136519. set captureSpritesRenderTime(value: boolean);
  136520. /**
  136521. * Gets the perf counter used for physics time
  136522. */
  136523. get physicsTimeCounter(): PerfCounter;
  136524. /**
  136525. * Gets the physics time capture status
  136526. */
  136527. get capturePhysicsTime(): boolean;
  136528. /**
  136529. * Enable or disable the physics time capture
  136530. */
  136531. set capturePhysicsTime(value: boolean);
  136532. /**
  136533. * Gets the perf counter used for animations time
  136534. */
  136535. get animationsTimeCounter(): PerfCounter;
  136536. /**
  136537. * Gets the animations time capture status
  136538. */
  136539. get captureAnimationsTime(): boolean;
  136540. /**
  136541. * Enable or disable the animations time capture
  136542. */
  136543. set captureAnimationsTime(value: boolean);
  136544. /**
  136545. * Gets the perf counter used for frame time capture
  136546. */
  136547. get frameTimeCounter(): PerfCounter;
  136548. /**
  136549. * Gets the frame time capture status
  136550. */
  136551. get captureFrameTime(): boolean;
  136552. /**
  136553. * Enable or disable the frame time capture
  136554. */
  136555. set captureFrameTime(value: boolean);
  136556. /**
  136557. * Gets the perf counter used for inter-frames time capture
  136558. */
  136559. get interFrameTimeCounter(): PerfCounter;
  136560. /**
  136561. * Gets the inter-frames time capture status
  136562. */
  136563. get captureInterFrameTime(): boolean;
  136564. /**
  136565. * Enable or disable the inter-frames time capture
  136566. */
  136567. set captureInterFrameTime(value: boolean);
  136568. /**
  136569. * Gets the perf counter used for render time capture
  136570. */
  136571. get renderTimeCounter(): PerfCounter;
  136572. /**
  136573. * Gets the render time capture status
  136574. */
  136575. get captureRenderTime(): boolean;
  136576. /**
  136577. * Enable or disable the render time capture
  136578. */
  136579. set captureRenderTime(value: boolean);
  136580. /**
  136581. * Gets the perf counter used for camera render time capture
  136582. */
  136583. get cameraRenderTimeCounter(): PerfCounter;
  136584. /**
  136585. * Gets the camera render time capture status
  136586. */
  136587. get captureCameraRenderTime(): boolean;
  136588. /**
  136589. * Enable or disable the camera render time capture
  136590. */
  136591. set captureCameraRenderTime(value: boolean);
  136592. /**
  136593. * Gets the perf counter used for draw calls
  136594. */
  136595. get drawCallsCounter(): PerfCounter;
  136596. /**
  136597. * Instantiates a new scene instrumentation.
  136598. * This class can be used to get instrumentation data from a Babylon engine
  136599. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136600. * @param scene Defines the scene to instrument
  136601. */
  136602. constructor(
  136603. /**
  136604. * Defines the scene to instrument
  136605. */
  136606. scene: Scene);
  136607. /**
  136608. * Dispose and release associated resources.
  136609. */
  136610. dispose(): void;
  136611. }
  136612. }
  136613. declare module BABYLON {
  136614. /** @hidden */
  136615. export var glowMapGenerationPixelShader: {
  136616. name: string;
  136617. shader: string;
  136618. };
  136619. }
  136620. declare module BABYLON {
  136621. /** @hidden */
  136622. export var glowMapGenerationVertexShader: {
  136623. name: string;
  136624. shader: string;
  136625. };
  136626. }
  136627. declare module BABYLON {
  136628. /**
  136629. * Effect layer options. This helps customizing the behaviour
  136630. * of the effect layer.
  136631. */
  136632. export interface IEffectLayerOptions {
  136633. /**
  136634. * Multiplication factor apply to the canvas size to compute the render target size
  136635. * used to generated the objects (the smaller the faster).
  136636. */
  136637. mainTextureRatio: number;
  136638. /**
  136639. * Enforces a fixed size texture to ensure effect stability across devices.
  136640. */
  136641. mainTextureFixedSize?: number;
  136642. /**
  136643. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  136644. */
  136645. alphaBlendingMode: number;
  136646. /**
  136647. * The camera attached to the layer.
  136648. */
  136649. camera: Nullable<Camera>;
  136650. /**
  136651. * The rendering group to draw the layer in.
  136652. */
  136653. renderingGroupId: number;
  136654. }
  136655. /**
  136656. * The effect layer Helps adding post process effect blended with the main pass.
  136657. *
  136658. * This can be for instance use to generate glow or higlight effects on the scene.
  136659. *
  136660. * The effect layer class can not be used directly and is intented to inherited from to be
  136661. * customized per effects.
  136662. */
  136663. export abstract class EffectLayer {
  136664. private _vertexBuffers;
  136665. private _indexBuffer;
  136666. private _cachedDefines;
  136667. private _effectLayerMapGenerationEffect;
  136668. private _effectLayerOptions;
  136669. private _mergeEffect;
  136670. protected _scene: Scene;
  136671. protected _engine: Engine;
  136672. protected _maxSize: number;
  136673. protected _mainTextureDesiredSize: ISize;
  136674. protected _mainTexture: RenderTargetTexture;
  136675. protected _shouldRender: boolean;
  136676. protected _postProcesses: PostProcess[];
  136677. protected _textures: BaseTexture[];
  136678. protected _emissiveTextureAndColor: {
  136679. texture: Nullable<BaseTexture>;
  136680. color: Color4;
  136681. };
  136682. /**
  136683. * The name of the layer
  136684. */
  136685. name: string;
  136686. /**
  136687. * The clear color of the texture used to generate the glow map.
  136688. */
  136689. neutralColor: Color4;
  136690. /**
  136691. * Specifies whether the highlight layer is enabled or not.
  136692. */
  136693. isEnabled: boolean;
  136694. /**
  136695. * Gets the camera attached to the layer.
  136696. */
  136697. get camera(): Nullable<Camera>;
  136698. /**
  136699. * Gets the rendering group id the layer should render in.
  136700. */
  136701. get renderingGroupId(): number;
  136702. set renderingGroupId(renderingGroupId: number);
  136703. /**
  136704. * An event triggered when the effect layer has been disposed.
  136705. */
  136706. onDisposeObservable: Observable<EffectLayer>;
  136707. /**
  136708. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  136709. */
  136710. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  136711. /**
  136712. * An event triggered when the generated texture is being merged in the scene.
  136713. */
  136714. onBeforeComposeObservable: Observable<EffectLayer>;
  136715. /**
  136716. * An event triggered when the mesh is rendered into the effect render target.
  136717. */
  136718. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  136719. /**
  136720. * An event triggered after the mesh has been rendered into the effect render target.
  136721. */
  136722. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  136723. /**
  136724. * An event triggered when the generated texture has been merged in the scene.
  136725. */
  136726. onAfterComposeObservable: Observable<EffectLayer>;
  136727. /**
  136728. * An event triggered when the efffect layer changes its size.
  136729. */
  136730. onSizeChangedObservable: Observable<EffectLayer>;
  136731. /** @hidden */
  136732. static _SceneComponentInitialization: (scene: Scene) => void;
  136733. /**
  136734. * Instantiates a new effect Layer and references it in the scene.
  136735. * @param name The name of the layer
  136736. * @param scene The scene to use the layer in
  136737. */
  136738. constructor(
  136739. /** The Friendly of the effect in the scene */
  136740. name: string, scene: Scene);
  136741. /**
  136742. * Get the effect name of the layer.
  136743. * @return The effect name
  136744. */
  136745. abstract getEffectName(): string;
  136746. /**
  136747. * Checks for the readiness of the element composing the layer.
  136748. * @param subMesh the mesh to check for
  136749. * @param useInstances specify whether or not to use instances to render the mesh
  136750. * @return true if ready otherwise, false
  136751. */
  136752. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136753. /**
  136754. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136755. * @returns true if the effect requires stencil during the main canvas render pass.
  136756. */
  136757. abstract needStencil(): boolean;
  136758. /**
  136759. * Create the merge effect. This is the shader use to blit the information back
  136760. * to the main canvas at the end of the scene rendering.
  136761. * @returns The effect containing the shader used to merge the effect on the main canvas
  136762. */
  136763. protected abstract _createMergeEffect(): Effect;
  136764. /**
  136765. * Creates the render target textures and post processes used in the effect layer.
  136766. */
  136767. protected abstract _createTextureAndPostProcesses(): void;
  136768. /**
  136769. * Implementation specific of rendering the generating effect on the main canvas.
  136770. * @param effect The effect used to render through
  136771. */
  136772. protected abstract _internalRender(effect: Effect): void;
  136773. /**
  136774. * Sets the required values for both the emissive texture and and the main color.
  136775. */
  136776. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136777. /**
  136778. * Free any resources and references associated to a mesh.
  136779. * Internal use
  136780. * @param mesh The mesh to free.
  136781. */
  136782. abstract _disposeMesh(mesh: Mesh): void;
  136783. /**
  136784. * Serializes this layer (Glow or Highlight for example)
  136785. * @returns a serialized layer object
  136786. */
  136787. abstract serialize?(): any;
  136788. /**
  136789. * Initializes the effect layer with the required options.
  136790. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  136791. */
  136792. protected _init(options: Partial<IEffectLayerOptions>): void;
  136793. /**
  136794. * Generates the index buffer of the full screen quad blending to the main canvas.
  136795. */
  136796. private _generateIndexBuffer;
  136797. /**
  136798. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  136799. */
  136800. private _generateVertexBuffer;
  136801. /**
  136802. * Sets the main texture desired size which is the closest power of two
  136803. * of the engine canvas size.
  136804. */
  136805. private _setMainTextureSize;
  136806. /**
  136807. * Creates the main texture for the effect layer.
  136808. */
  136809. protected _createMainTexture(): void;
  136810. /**
  136811. * Adds specific effects defines.
  136812. * @param defines The defines to add specifics to.
  136813. */
  136814. protected _addCustomEffectDefines(defines: string[]): void;
  136815. /**
  136816. * Checks for the readiness of the element composing the layer.
  136817. * @param subMesh the mesh to check for
  136818. * @param useInstances specify whether or not to use instances to render the mesh
  136819. * @param emissiveTexture the associated emissive texture used to generate the glow
  136820. * @return true if ready otherwise, false
  136821. */
  136822. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  136823. /**
  136824. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  136825. */
  136826. render(): void;
  136827. /**
  136828. * Determine if a given mesh will be used in the current effect.
  136829. * @param mesh mesh to test
  136830. * @returns true if the mesh will be used
  136831. */
  136832. hasMesh(mesh: AbstractMesh): boolean;
  136833. /**
  136834. * Returns true if the layer contains information to display, otherwise false.
  136835. * @returns true if the glow layer should be rendered
  136836. */
  136837. shouldRender(): boolean;
  136838. /**
  136839. * Returns true if the mesh should render, otherwise false.
  136840. * @param mesh The mesh to render
  136841. * @returns true if it should render otherwise false
  136842. */
  136843. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  136844. /**
  136845. * Returns true if the mesh can be rendered, otherwise false.
  136846. * @param mesh The mesh to render
  136847. * @param material The material used on the mesh
  136848. * @returns true if it can be rendered otherwise false
  136849. */
  136850. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136851. /**
  136852. * Returns true if the mesh should render, otherwise false.
  136853. * @param mesh The mesh to render
  136854. * @returns true if it should render otherwise false
  136855. */
  136856. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  136857. /**
  136858. * Renders the submesh passed in parameter to the generation map.
  136859. */
  136860. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  136861. /**
  136862. * Defines whether the current material of the mesh should be use to render the effect.
  136863. * @param mesh defines the current mesh to render
  136864. */
  136865. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136866. /**
  136867. * Rebuild the required buffers.
  136868. * @hidden Internal use only.
  136869. */
  136870. _rebuild(): void;
  136871. /**
  136872. * Dispose only the render target textures and post process.
  136873. */
  136874. private _disposeTextureAndPostProcesses;
  136875. /**
  136876. * Dispose the highlight layer and free resources.
  136877. */
  136878. dispose(): void;
  136879. /**
  136880. * Gets the class name of the effect layer
  136881. * @returns the string with the class name of the effect layer
  136882. */
  136883. getClassName(): string;
  136884. /**
  136885. * Creates an effect layer from parsed effect layer data
  136886. * @param parsedEffectLayer defines effect layer data
  136887. * @param scene defines the current scene
  136888. * @param rootUrl defines the root URL containing the effect layer information
  136889. * @returns a parsed effect Layer
  136890. */
  136891. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  136892. }
  136893. }
  136894. declare module BABYLON {
  136895. interface AbstractScene {
  136896. /**
  136897. * The list of effect layers (highlights/glow) added to the scene
  136898. * @see https://doc.babylonjs.com/how_to/highlight_layer
  136899. * @see https://doc.babylonjs.com/how_to/glow_layer
  136900. */
  136901. effectLayers: Array<EffectLayer>;
  136902. /**
  136903. * Removes the given effect layer from this scene.
  136904. * @param toRemove defines the effect layer to remove
  136905. * @returns the index of the removed effect layer
  136906. */
  136907. removeEffectLayer(toRemove: EffectLayer): number;
  136908. /**
  136909. * Adds the given effect layer to this scene
  136910. * @param newEffectLayer defines the effect layer to add
  136911. */
  136912. addEffectLayer(newEffectLayer: EffectLayer): void;
  136913. }
  136914. /**
  136915. * Defines the layer scene component responsible to manage any effect layers
  136916. * in a given scene.
  136917. */
  136918. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  136919. /**
  136920. * The component name helpfull to identify the component in the list of scene components.
  136921. */
  136922. readonly name: string;
  136923. /**
  136924. * The scene the component belongs to.
  136925. */
  136926. scene: Scene;
  136927. private _engine;
  136928. private _renderEffects;
  136929. private _needStencil;
  136930. private _previousStencilState;
  136931. /**
  136932. * Creates a new instance of the component for the given scene
  136933. * @param scene Defines the scene to register the component in
  136934. */
  136935. constructor(scene: Scene);
  136936. /**
  136937. * Registers the component in a given scene
  136938. */
  136939. register(): void;
  136940. /**
  136941. * Rebuilds the elements related to this component in case of
  136942. * context lost for instance.
  136943. */
  136944. rebuild(): void;
  136945. /**
  136946. * Serializes the component data to the specified json object
  136947. * @param serializationObject The object to serialize to
  136948. */
  136949. serialize(serializationObject: any): void;
  136950. /**
  136951. * Adds all the elements from the container to the scene
  136952. * @param container the container holding the elements
  136953. */
  136954. addFromContainer(container: AbstractScene): void;
  136955. /**
  136956. * Removes all the elements in the container from the scene
  136957. * @param container contains the elements to remove
  136958. * @param dispose if the removed element should be disposed (default: false)
  136959. */
  136960. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136961. /**
  136962. * Disposes the component and the associated ressources.
  136963. */
  136964. dispose(): void;
  136965. private _isReadyForMesh;
  136966. private _renderMainTexture;
  136967. private _setStencil;
  136968. private _setStencilBack;
  136969. private _draw;
  136970. private _drawCamera;
  136971. private _drawRenderingGroup;
  136972. }
  136973. }
  136974. declare module BABYLON {
  136975. /** @hidden */
  136976. export var glowMapMergePixelShader: {
  136977. name: string;
  136978. shader: string;
  136979. };
  136980. }
  136981. declare module BABYLON {
  136982. /** @hidden */
  136983. export var glowMapMergeVertexShader: {
  136984. name: string;
  136985. shader: string;
  136986. };
  136987. }
  136988. declare module BABYLON {
  136989. interface AbstractScene {
  136990. /**
  136991. * Return a the first highlight layer of the scene with a given name.
  136992. * @param name The name of the highlight layer to look for.
  136993. * @return The highlight layer if found otherwise null.
  136994. */
  136995. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  136996. }
  136997. /**
  136998. * Glow layer options. This helps customizing the behaviour
  136999. * of the glow layer.
  137000. */
  137001. export interface IGlowLayerOptions {
  137002. /**
  137003. * Multiplication factor apply to the canvas size to compute the render target size
  137004. * used to generated the glowing objects (the smaller the faster).
  137005. */
  137006. mainTextureRatio: number;
  137007. /**
  137008. * Enforces a fixed size texture to ensure resize independant blur.
  137009. */
  137010. mainTextureFixedSize?: number;
  137011. /**
  137012. * How big is the kernel of the blur texture.
  137013. */
  137014. blurKernelSize: number;
  137015. /**
  137016. * The camera attached to the layer.
  137017. */
  137018. camera: Nullable<Camera>;
  137019. /**
  137020. * Enable MSAA by chosing the number of samples.
  137021. */
  137022. mainTextureSamples?: number;
  137023. /**
  137024. * The rendering group to draw the layer in.
  137025. */
  137026. renderingGroupId: number;
  137027. }
  137028. /**
  137029. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  137030. *
  137031. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  137032. *
  137033. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  137034. */
  137035. export class GlowLayer extends EffectLayer {
  137036. /**
  137037. * Effect Name of the layer.
  137038. */
  137039. static readonly EffectName: string;
  137040. /**
  137041. * The default blur kernel size used for the glow.
  137042. */
  137043. static DefaultBlurKernelSize: number;
  137044. /**
  137045. * The default texture size ratio used for the glow.
  137046. */
  137047. static DefaultTextureRatio: number;
  137048. /**
  137049. * Sets the kernel size of the blur.
  137050. */
  137051. set blurKernelSize(value: number);
  137052. /**
  137053. * Gets the kernel size of the blur.
  137054. */
  137055. get blurKernelSize(): number;
  137056. /**
  137057. * Sets the glow intensity.
  137058. */
  137059. set intensity(value: number);
  137060. /**
  137061. * Gets the glow intensity.
  137062. */
  137063. get intensity(): number;
  137064. private _options;
  137065. private _intensity;
  137066. private _horizontalBlurPostprocess1;
  137067. private _verticalBlurPostprocess1;
  137068. private _horizontalBlurPostprocess2;
  137069. private _verticalBlurPostprocess2;
  137070. private _blurTexture1;
  137071. private _blurTexture2;
  137072. private _postProcesses1;
  137073. private _postProcesses2;
  137074. private _includedOnlyMeshes;
  137075. private _excludedMeshes;
  137076. private _meshesUsingTheirOwnMaterials;
  137077. /**
  137078. * Callback used to let the user override the color selection on a per mesh basis
  137079. */
  137080. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  137081. /**
  137082. * Callback used to let the user override the texture selection on a per mesh basis
  137083. */
  137084. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  137085. /**
  137086. * Instantiates a new glow Layer and references it to the scene.
  137087. * @param name The name of the layer
  137088. * @param scene The scene to use the layer in
  137089. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  137090. */
  137091. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  137092. /**
  137093. * Get the effect name of the layer.
  137094. * @return The effect name
  137095. */
  137096. getEffectName(): string;
  137097. /**
  137098. * Create the merge effect. This is the shader use to blit the information back
  137099. * to the main canvas at the end of the scene rendering.
  137100. */
  137101. protected _createMergeEffect(): Effect;
  137102. /**
  137103. * Creates the render target textures and post processes used in the glow layer.
  137104. */
  137105. protected _createTextureAndPostProcesses(): void;
  137106. /**
  137107. * Checks for the readiness of the element composing the layer.
  137108. * @param subMesh the mesh to check for
  137109. * @param useInstances specify wether or not to use instances to render the mesh
  137110. * @param emissiveTexture the associated emissive texture used to generate the glow
  137111. * @return true if ready otherwise, false
  137112. */
  137113. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137114. /**
  137115. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137116. */
  137117. needStencil(): boolean;
  137118. /**
  137119. * Returns true if the mesh can be rendered, otherwise false.
  137120. * @param mesh The mesh to render
  137121. * @param material The material used on the mesh
  137122. * @returns true if it can be rendered otherwise false
  137123. */
  137124. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137125. /**
  137126. * Implementation specific of rendering the generating effect on the main canvas.
  137127. * @param effect The effect used to render through
  137128. */
  137129. protected _internalRender(effect: Effect): void;
  137130. /**
  137131. * Sets the required values for both the emissive texture and and the main color.
  137132. */
  137133. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137134. /**
  137135. * Returns true if the mesh should render, otherwise false.
  137136. * @param mesh The mesh to render
  137137. * @returns true if it should render otherwise false
  137138. */
  137139. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137140. /**
  137141. * Adds specific effects defines.
  137142. * @param defines The defines to add specifics to.
  137143. */
  137144. protected _addCustomEffectDefines(defines: string[]): void;
  137145. /**
  137146. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  137147. * @param mesh The mesh to exclude from the glow layer
  137148. */
  137149. addExcludedMesh(mesh: Mesh): void;
  137150. /**
  137151. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  137152. * @param mesh The mesh to remove
  137153. */
  137154. removeExcludedMesh(mesh: Mesh): void;
  137155. /**
  137156. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  137157. * @param mesh The mesh to include in the glow layer
  137158. */
  137159. addIncludedOnlyMesh(mesh: Mesh): void;
  137160. /**
  137161. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  137162. * @param mesh The mesh to remove
  137163. */
  137164. removeIncludedOnlyMesh(mesh: Mesh): void;
  137165. /**
  137166. * Determine if a given mesh will be used in the glow layer
  137167. * @param mesh The mesh to test
  137168. * @returns true if the mesh will be highlighted by the current glow layer
  137169. */
  137170. hasMesh(mesh: AbstractMesh): boolean;
  137171. /**
  137172. * Defines whether the current material of the mesh should be use to render the effect.
  137173. * @param mesh defines the current mesh to render
  137174. */
  137175. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137176. /**
  137177. * Add a mesh to be rendered through its own material and not with emissive only.
  137178. * @param mesh The mesh for which we need to use its material
  137179. */
  137180. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  137181. /**
  137182. * Remove a mesh from being rendered through its own material and not with emissive only.
  137183. * @param mesh The mesh for which we need to not use its material
  137184. */
  137185. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  137186. /**
  137187. * Free any resources and references associated to a mesh.
  137188. * Internal use
  137189. * @param mesh The mesh to free.
  137190. * @hidden
  137191. */
  137192. _disposeMesh(mesh: Mesh): void;
  137193. /**
  137194. * Gets the class name of the effect layer
  137195. * @returns the string with the class name of the effect layer
  137196. */
  137197. getClassName(): string;
  137198. /**
  137199. * Serializes this glow layer
  137200. * @returns a serialized glow layer object
  137201. */
  137202. serialize(): any;
  137203. /**
  137204. * Creates a Glow Layer from parsed glow layer data
  137205. * @param parsedGlowLayer defines glow layer data
  137206. * @param scene defines the current scene
  137207. * @param rootUrl defines the root URL containing the glow layer information
  137208. * @returns a parsed Glow Layer
  137209. */
  137210. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  137211. }
  137212. }
  137213. declare module BABYLON {
  137214. /** @hidden */
  137215. export var glowBlurPostProcessPixelShader: {
  137216. name: string;
  137217. shader: string;
  137218. };
  137219. }
  137220. declare module BABYLON {
  137221. interface AbstractScene {
  137222. /**
  137223. * Return a the first highlight layer of the scene with a given name.
  137224. * @param name The name of the highlight layer to look for.
  137225. * @return The highlight layer if found otherwise null.
  137226. */
  137227. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  137228. }
  137229. /**
  137230. * Highlight layer options. This helps customizing the behaviour
  137231. * of the highlight layer.
  137232. */
  137233. export interface IHighlightLayerOptions {
  137234. /**
  137235. * Multiplication factor apply to the canvas size to compute the render target size
  137236. * used to generated the glowing objects (the smaller the faster).
  137237. */
  137238. mainTextureRatio: number;
  137239. /**
  137240. * Enforces a fixed size texture to ensure resize independant blur.
  137241. */
  137242. mainTextureFixedSize?: number;
  137243. /**
  137244. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  137245. * of the picture to blur (the smaller the faster).
  137246. */
  137247. blurTextureSizeRatio: number;
  137248. /**
  137249. * How big in texel of the blur texture is the vertical blur.
  137250. */
  137251. blurVerticalSize: number;
  137252. /**
  137253. * How big in texel of the blur texture is the horizontal blur.
  137254. */
  137255. blurHorizontalSize: number;
  137256. /**
  137257. * Alpha blending mode used to apply the blur. Default is combine.
  137258. */
  137259. alphaBlendingMode: number;
  137260. /**
  137261. * The camera attached to the layer.
  137262. */
  137263. camera: Nullable<Camera>;
  137264. /**
  137265. * Should we display highlight as a solid stroke?
  137266. */
  137267. isStroke?: boolean;
  137268. /**
  137269. * The rendering group to draw the layer in.
  137270. */
  137271. renderingGroupId: number;
  137272. }
  137273. /**
  137274. * The highlight layer Helps adding a glow effect around a mesh.
  137275. *
  137276. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  137277. * glowy meshes to your scene.
  137278. *
  137279. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  137280. */
  137281. export class HighlightLayer extends EffectLayer {
  137282. name: string;
  137283. /**
  137284. * Effect Name of the highlight layer.
  137285. */
  137286. static readonly EffectName: string;
  137287. /**
  137288. * The neutral color used during the preparation of the glow effect.
  137289. * This is black by default as the blend operation is a blend operation.
  137290. */
  137291. static NeutralColor: Color4;
  137292. /**
  137293. * Stencil value used for glowing meshes.
  137294. */
  137295. static GlowingMeshStencilReference: number;
  137296. /**
  137297. * Stencil value used for the other meshes in the scene.
  137298. */
  137299. static NormalMeshStencilReference: number;
  137300. /**
  137301. * Specifies whether or not the inner glow is ACTIVE in the layer.
  137302. */
  137303. innerGlow: boolean;
  137304. /**
  137305. * Specifies whether or not the outer glow is ACTIVE in the layer.
  137306. */
  137307. outerGlow: boolean;
  137308. /**
  137309. * Specifies the horizontal size of the blur.
  137310. */
  137311. set blurHorizontalSize(value: number);
  137312. /**
  137313. * Specifies the vertical size of the blur.
  137314. */
  137315. set blurVerticalSize(value: number);
  137316. /**
  137317. * Gets the horizontal size of the blur.
  137318. */
  137319. get blurHorizontalSize(): number;
  137320. /**
  137321. * Gets the vertical size of the blur.
  137322. */
  137323. get blurVerticalSize(): number;
  137324. /**
  137325. * An event triggered when the highlight layer is being blurred.
  137326. */
  137327. onBeforeBlurObservable: Observable<HighlightLayer>;
  137328. /**
  137329. * An event triggered when the highlight layer has been blurred.
  137330. */
  137331. onAfterBlurObservable: Observable<HighlightLayer>;
  137332. private _instanceGlowingMeshStencilReference;
  137333. private _options;
  137334. private _downSamplePostprocess;
  137335. private _horizontalBlurPostprocess;
  137336. private _verticalBlurPostprocess;
  137337. private _blurTexture;
  137338. private _meshes;
  137339. private _excludedMeshes;
  137340. /**
  137341. * Instantiates a new highlight Layer and references it to the scene..
  137342. * @param name The name of the layer
  137343. * @param scene The scene to use the layer in
  137344. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  137345. */
  137346. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  137347. /**
  137348. * Get the effect name of the layer.
  137349. * @return The effect name
  137350. */
  137351. getEffectName(): string;
  137352. /**
  137353. * Create the merge effect. This is the shader use to blit the information back
  137354. * to the main canvas at the end of the scene rendering.
  137355. */
  137356. protected _createMergeEffect(): Effect;
  137357. /**
  137358. * Creates the render target textures and post processes used in the highlight layer.
  137359. */
  137360. protected _createTextureAndPostProcesses(): void;
  137361. /**
  137362. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  137363. */
  137364. needStencil(): boolean;
  137365. /**
  137366. * Checks for the readiness of the element composing the layer.
  137367. * @param subMesh the mesh to check for
  137368. * @param useInstances specify wether or not to use instances to render the mesh
  137369. * @param emissiveTexture the associated emissive texture used to generate the glow
  137370. * @return true if ready otherwise, false
  137371. */
  137372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137373. /**
  137374. * Implementation specific of rendering the generating effect on the main canvas.
  137375. * @param effect The effect used to render through
  137376. */
  137377. protected _internalRender(effect: Effect): void;
  137378. /**
  137379. * Returns true if the layer contains information to display, otherwise false.
  137380. */
  137381. shouldRender(): boolean;
  137382. /**
  137383. * Returns true if the mesh should render, otherwise false.
  137384. * @param mesh The mesh to render
  137385. * @returns true if it should render otherwise false
  137386. */
  137387. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137388. /**
  137389. * Returns true if the mesh can be rendered, otherwise false.
  137390. * @param mesh The mesh to render
  137391. * @param material The material used on the mesh
  137392. * @returns true if it can be rendered otherwise false
  137393. */
  137394. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137395. /**
  137396. * Adds specific effects defines.
  137397. * @param defines The defines to add specifics to.
  137398. */
  137399. protected _addCustomEffectDefines(defines: string[]): void;
  137400. /**
  137401. * Sets the required values for both the emissive texture and and the main color.
  137402. */
  137403. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137404. /**
  137405. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  137406. * @param mesh The mesh to exclude from the highlight layer
  137407. */
  137408. addExcludedMesh(mesh: Mesh): void;
  137409. /**
  137410. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  137411. * @param mesh The mesh to highlight
  137412. */
  137413. removeExcludedMesh(mesh: Mesh): void;
  137414. /**
  137415. * Determine if a given mesh will be highlighted by the current HighlightLayer
  137416. * @param mesh mesh to test
  137417. * @returns true if the mesh will be highlighted by the current HighlightLayer
  137418. */
  137419. hasMesh(mesh: AbstractMesh): boolean;
  137420. /**
  137421. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  137422. * @param mesh The mesh to highlight
  137423. * @param color The color of the highlight
  137424. * @param glowEmissiveOnly Extract the glow from the emissive texture
  137425. */
  137426. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  137427. /**
  137428. * Remove a mesh from the highlight layer in order to make it stop glowing.
  137429. * @param mesh The mesh to highlight
  137430. */
  137431. removeMesh(mesh: Mesh): void;
  137432. /**
  137433. * Remove all the meshes currently referenced in the highlight layer
  137434. */
  137435. removeAllMeshes(): void;
  137436. /**
  137437. * Force the stencil to the normal expected value for none glowing parts
  137438. */
  137439. private _defaultStencilReference;
  137440. /**
  137441. * Free any resources and references associated to a mesh.
  137442. * Internal use
  137443. * @param mesh The mesh to free.
  137444. * @hidden
  137445. */
  137446. _disposeMesh(mesh: Mesh): void;
  137447. /**
  137448. * Dispose the highlight layer and free resources.
  137449. */
  137450. dispose(): void;
  137451. /**
  137452. * Gets the class name of the effect layer
  137453. * @returns the string with the class name of the effect layer
  137454. */
  137455. getClassName(): string;
  137456. /**
  137457. * Serializes this Highlight layer
  137458. * @returns a serialized Highlight layer object
  137459. */
  137460. serialize(): any;
  137461. /**
  137462. * Creates a Highlight layer from parsed Highlight layer data
  137463. * @param parsedHightlightLayer defines the Highlight layer data
  137464. * @param scene defines the current scene
  137465. * @param rootUrl defines the root URL containing the Highlight layer information
  137466. * @returns a parsed Highlight layer
  137467. */
  137468. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  137469. }
  137470. }
  137471. declare module BABYLON {
  137472. interface AbstractScene {
  137473. /**
  137474. * The list of layers (background and foreground) of the scene
  137475. */
  137476. layers: Array<Layer>;
  137477. }
  137478. /**
  137479. * Defines the layer scene component responsible to manage any layers
  137480. * in a given scene.
  137481. */
  137482. export class LayerSceneComponent implements ISceneComponent {
  137483. /**
  137484. * The component name helpfull to identify the component in the list of scene components.
  137485. */
  137486. readonly name: string;
  137487. /**
  137488. * The scene the component belongs to.
  137489. */
  137490. scene: Scene;
  137491. private _engine;
  137492. /**
  137493. * Creates a new instance of the component for the given scene
  137494. * @param scene Defines the scene to register the component in
  137495. */
  137496. constructor(scene: Scene);
  137497. /**
  137498. * Registers the component in a given scene
  137499. */
  137500. register(): void;
  137501. /**
  137502. * Rebuilds the elements related to this component in case of
  137503. * context lost for instance.
  137504. */
  137505. rebuild(): void;
  137506. /**
  137507. * Disposes the component and the associated ressources.
  137508. */
  137509. dispose(): void;
  137510. private _draw;
  137511. private _drawCameraPredicate;
  137512. private _drawCameraBackground;
  137513. private _drawCameraForeground;
  137514. private _drawRenderTargetPredicate;
  137515. private _drawRenderTargetBackground;
  137516. private _drawRenderTargetForeground;
  137517. /**
  137518. * Adds all the elements from the container to the scene
  137519. * @param container the container holding the elements
  137520. */
  137521. addFromContainer(container: AbstractScene): void;
  137522. /**
  137523. * Removes all the elements in the container from the scene
  137524. * @param container contains the elements to remove
  137525. * @param dispose if the removed element should be disposed (default: false)
  137526. */
  137527. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137528. }
  137529. }
  137530. declare module BABYLON {
  137531. /** @hidden */
  137532. export var layerPixelShader: {
  137533. name: string;
  137534. shader: string;
  137535. };
  137536. }
  137537. declare module BABYLON {
  137538. /** @hidden */
  137539. export var layerVertexShader: {
  137540. name: string;
  137541. shader: string;
  137542. };
  137543. }
  137544. declare module BABYLON {
  137545. /**
  137546. * This represents a full screen 2d layer.
  137547. * This can be useful to display a picture in the background of your scene for instance.
  137548. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137549. */
  137550. export class Layer {
  137551. /**
  137552. * Define the name of the layer.
  137553. */
  137554. name: string;
  137555. /**
  137556. * Define the texture the layer should display.
  137557. */
  137558. texture: Nullable<Texture>;
  137559. /**
  137560. * Is the layer in background or foreground.
  137561. */
  137562. isBackground: boolean;
  137563. /**
  137564. * Define the color of the layer (instead of texture).
  137565. */
  137566. color: Color4;
  137567. /**
  137568. * Define the scale of the layer in order to zoom in out of the texture.
  137569. */
  137570. scale: Vector2;
  137571. /**
  137572. * Define an offset for the layer in order to shift the texture.
  137573. */
  137574. offset: Vector2;
  137575. /**
  137576. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  137577. */
  137578. alphaBlendingMode: number;
  137579. /**
  137580. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  137581. * Alpha test will not mix with the background color in case of transparency.
  137582. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  137583. */
  137584. alphaTest: boolean;
  137585. /**
  137586. * Define a mask to restrict the layer to only some of the scene cameras.
  137587. */
  137588. layerMask: number;
  137589. /**
  137590. * Define the list of render target the layer is visible into.
  137591. */
  137592. renderTargetTextures: RenderTargetTexture[];
  137593. /**
  137594. * Define if the layer is only used in renderTarget or if it also
  137595. * renders in the main frame buffer of the canvas.
  137596. */
  137597. renderOnlyInRenderTargetTextures: boolean;
  137598. private _scene;
  137599. private _vertexBuffers;
  137600. private _indexBuffer;
  137601. private _effect;
  137602. private _previousDefines;
  137603. /**
  137604. * An event triggered when the layer is disposed.
  137605. */
  137606. onDisposeObservable: Observable<Layer>;
  137607. private _onDisposeObserver;
  137608. /**
  137609. * Back compatibility with callback before the onDisposeObservable existed.
  137610. * The set callback will be triggered when the layer has been disposed.
  137611. */
  137612. set onDispose(callback: () => void);
  137613. /**
  137614. * An event triggered before rendering the scene
  137615. */
  137616. onBeforeRenderObservable: Observable<Layer>;
  137617. private _onBeforeRenderObserver;
  137618. /**
  137619. * Back compatibility with callback before the onBeforeRenderObservable existed.
  137620. * The set callback will be triggered just before rendering the layer.
  137621. */
  137622. set onBeforeRender(callback: () => void);
  137623. /**
  137624. * An event triggered after rendering the scene
  137625. */
  137626. onAfterRenderObservable: Observable<Layer>;
  137627. private _onAfterRenderObserver;
  137628. /**
  137629. * Back compatibility with callback before the onAfterRenderObservable existed.
  137630. * The set callback will be triggered just after rendering the layer.
  137631. */
  137632. set onAfterRender(callback: () => void);
  137633. /**
  137634. * Instantiates a new layer.
  137635. * This represents a full screen 2d layer.
  137636. * This can be useful to display a picture in the background of your scene for instance.
  137637. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137638. * @param name Define the name of the layer in the scene
  137639. * @param imgUrl Define the url of the texture to display in the layer
  137640. * @param scene Define the scene the layer belongs to
  137641. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  137642. * @param color Defines a color for the layer
  137643. */
  137644. constructor(
  137645. /**
  137646. * Define the name of the layer.
  137647. */
  137648. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  137649. private _createIndexBuffer;
  137650. /** @hidden */
  137651. _rebuild(): void;
  137652. /**
  137653. * Renders the layer in the scene.
  137654. */
  137655. render(): void;
  137656. /**
  137657. * Disposes and releases the associated ressources.
  137658. */
  137659. dispose(): void;
  137660. }
  137661. }
  137662. declare module BABYLON {
  137663. /** @hidden */
  137664. export var lensFlarePixelShader: {
  137665. name: string;
  137666. shader: string;
  137667. };
  137668. }
  137669. declare module BABYLON {
  137670. /** @hidden */
  137671. export var lensFlareVertexShader: {
  137672. name: string;
  137673. shader: string;
  137674. };
  137675. }
  137676. declare module BABYLON {
  137677. /**
  137678. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137679. * It is usually composed of several `lensFlare`.
  137680. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137681. */
  137682. export class LensFlareSystem {
  137683. /**
  137684. * Define the name of the lens flare system
  137685. */
  137686. name: string;
  137687. /**
  137688. * List of lens flares used in this system.
  137689. */
  137690. lensFlares: LensFlare[];
  137691. /**
  137692. * Define a limit from the border the lens flare can be visible.
  137693. */
  137694. borderLimit: number;
  137695. /**
  137696. * Define a viewport border we do not want to see the lens flare in.
  137697. */
  137698. viewportBorder: number;
  137699. /**
  137700. * Define a predicate which could limit the list of meshes able to occlude the effect.
  137701. */
  137702. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  137703. /**
  137704. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  137705. */
  137706. layerMask: number;
  137707. /**
  137708. * Define the id of the lens flare system in the scene.
  137709. * (equal to name by default)
  137710. */
  137711. id: string;
  137712. private _scene;
  137713. private _emitter;
  137714. private _vertexBuffers;
  137715. private _indexBuffer;
  137716. private _effect;
  137717. private _positionX;
  137718. private _positionY;
  137719. private _isEnabled;
  137720. /** @hidden */
  137721. static _SceneComponentInitialization: (scene: Scene) => void;
  137722. /**
  137723. * Instantiates a lens flare system.
  137724. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137725. * It is usually composed of several `lensFlare`.
  137726. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137727. * @param name Define the name of the lens flare system in the scene
  137728. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  137729. * @param scene Define the scene the lens flare system belongs to
  137730. */
  137731. constructor(
  137732. /**
  137733. * Define the name of the lens flare system
  137734. */
  137735. name: string, emitter: any, scene: Scene);
  137736. /**
  137737. * Define if the lens flare system is enabled.
  137738. */
  137739. get isEnabled(): boolean;
  137740. set isEnabled(value: boolean);
  137741. /**
  137742. * Get the scene the effects belongs to.
  137743. * @returns the scene holding the lens flare system
  137744. */
  137745. getScene(): Scene;
  137746. /**
  137747. * Get the emitter of the lens flare system.
  137748. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137749. * @returns the emitter of the lens flare system
  137750. */
  137751. getEmitter(): any;
  137752. /**
  137753. * Set the emitter of the lens flare system.
  137754. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137755. * @param newEmitter Define the new emitter of the system
  137756. */
  137757. setEmitter(newEmitter: any): void;
  137758. /**
  137759. * Get the lens flare system emitter position.
  137760. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  137761. * @returns the position
  137762. */
  137763. getEmitterPosition(): Vector3;
  137764. /**
  137765. * @hidden
  137766. */
  137767. computeEffectivePosition(globalViewport: Viewport): boolean;
  137768. /** @hidden */
  137769. _isVisible(): boolean;
  137770. /**
  137771. * @hidden
  137772. */
  137773. render(): boolean;
  137774. /**
  137775. * Dispose and release the lens flare with its associated resources.
  137776. */
  137777. dispose(): void;
  137778. /**
  137779. * Parse a lens flare system from a JSON repressentation
  137780. * @param parsedLensFlareSystem Define the JSON to parse
  137781. * @param scene Define the scene the parsed system should be instantiated in
  137782. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  137783. * @returns the parsed system
  137784. */
  137785. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  137786. /**
  137787. * Serialize the current Lens Flare System into a JSON representation.
  137788. * @returns the serialized JSON
  137789. */
  137790. serialize(): any;
  137791. }
  137792. }
  137793. declare module BABYLON {
  137794. /**
  137795. * This represents one of the lens effect in a `lensFlareSystem`.
  137796. * It controls one of the indiviual texture used in the effect.
  137797. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137798. */
  137799. export class LensFlare {
  137800. /**
  137801. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137802. */
  137803. size: number;
  137804. /**
  137805. * 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.
  137806. */
  137807. position: number;
  137808. /**
  137809. * Define the lens color.
  137810. */
  137811. color: Color3;
  137812. /**
  137813. * Define the lens texture.
  137814. */
  137815. texture: Nullable<Texture>;
  137816. /**
  137817. * Define the alpha mode to render this particular lens.
  137818. */
  137819. alphaMode: number;
  137820. private _system;
  137821. /**
  137822. * Creates a new Lens Flare.
  137823. * This represents one of the lens effect in a `lensFlareSystem`.
  137824. * It controls one of the indiviual texture used in the effect.
  137825. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137826. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  137827. * @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.
  137828. * @param color Define the lens color
  137829. * @param imgUrl Define the lens texture url
  137830. * @param system Define the `lensFlareSystem` this flare is part of
  137831. * @returns The newly created Lens Flare
  137832. */
  137833. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  137834. /**
  137835. * Instantiates a new Lens Flare.
  137836. * This represents one of the lens effect in a `lensFlareSystem`.
  137837. * It controls one of the indiviual texture used in the effect.
  137838. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137839. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  137840. * @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.
  137841. * @param color Define the lens color
  137842. * @param imgUrl Define the lens texture url
  137843. * @param system Define the `lensFlareSystem` this flare is part of
  137844. */
  137845. constructor(
  137846. /**
  137847. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137848. */
  137849. size: number,
  137850. /**
  137851. * 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.
  137852. */
  137853. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  137854. /**
  137855. * Dispose and release the lens flare with its associated resources.
  137856. */
  137857. dispose(): void;
  137858. }
  137859. }
  137860. declare module BABYLON {
  137861. interface AbstractScene {
  137862. /**
  137863. * The list of lens flare system added to the scene
  137864. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137865. */
  137866. lensFlareSystems: Array<LensFlareSystem>;
  137867. /**
  137868. * Removes the given lens flare system from this scene.
  137869. * @param toRemove The lens flare system to remove
  137870. * @returns The index of the removed lens flare system
  137871. */
  137872. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  137873. /**
  137874. * Adds the given lens flare system to this scene
  137875. * @param newLensFlareSystem The lens flare system to add
  137876. */
  137877. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  137878. /**
  137879. * Gets a lens flare system using its name
  137880. * @param name defines the name to look for
  137881. * @returns the lens flare system or null if not found
  137882. */
  137883. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  137884. /**
  137885. * Gets a lens flare system using its id
  137886. * @param id defines the id to look for
  137887. * @returns the lens flare system or null if not found
  137888. */
  137889. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  137890. }
  137891. /**
  137892. * Defines the lens flare scene component responsible to manage any lens flares
  137893. * in a given scene.
  137894. */
  137895. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  137896. /**
  137897. * The component name helpfull to identify the component in the list of scene components.
  137898. */
  137899. readonly name: string;
  137900. /**
  137901. * The scene the component belongs to.
  137902. */
  137903. scene: Scene;
  137904. /**
  137905. * Creates a new instance of the component for the given scene
  137906. * @param scene Defines the scene to register the component in
  137907. */
  137908. constructor(scene: Scene);
  137909. /**
  137910. * Registers the component in a given scene
  137911. */
  137912. register(): void;
  137913. /**
  137914. * Rebuilds the elements related to this component in case of
  137915. * context lost for instance.
  137916. */
  137917. rebuild(): void;
  137918. /**
  137919. * Adds all the elements from the container to the scene
  137920. * @param container the container holding the elements
  137921. */
  137922. addFromContainer(container: AbstractScene): void;
  137923. /**
  137924. * Removes all the elements in the container from the scene
  137925. * @param container contains the elements to remove
  137926. * @param dispose if the removed element should be disposed (default: false)
  137927. */
  137928. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137929. /**
  137930. * Serializes the component data to the specified json object
  137931. * @param serializationObject The object to serialize to
  137932. */
  137933. serialize(serializationObject: any): void;
  137934. /**
  137935. * Disposes the component and the associated ressources.
  137936. */
  137937. dispose(): void;
  137938. private _draw;
  137939. }
  137940. }
  137941. declare module BABYLON {
  137942. /** @hidden */
  137943. export var depthPixelShader: {
  137944. name: string;
  137945. shader: string;
  137946. };
  137947. }
  137948. declare module BABYLON {
  137949. /** @hidden */
  137950. export var depthVertexShader: {
  137951. name: string;
  137952. shader: string;
  137953. };
  137954. }
  137955. declare module BABYLON {
  137956. /**
  137957. * This represents a depth renderer in Babylon.
  137958. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  137959. */
  137960. export class DepthRenderer {
  137961. private _scene;
  137962. private _depthMap;
  137963. private _effect;
  137964. private readonly _storeNonLinearDepth;
  137965. private readonly _clearColor;
  137966. /** Get if the depth renderer is using packed depth or not */
  137967. readonly isPacked: boolean;
  137968. private _cachedDefines;
  137969. private _camera;
  137970. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  137971. enabled: boolean;
  137972. /**
  137973. * Specifiess that the depth renderer will only be used within
  137974. * the camera it is created for.
  137975. * This can help forcing its rendering during the camera processing.
  137976. */
  137977. useOnlyInActiveCamera: boolean;
  137978. /** @hidden */
  137979. static _SceneComponentInitialization: (scene: Scene) => void;
  137980. /**
  137981. * Instantiates a depth renderer
  137982. * @param scene The scene the renderer belongs to
  137983. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  137984. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  137985. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  137986. */
  137987. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  137988. /**
  137989. * Creates the depth rendering effect and checks if the effect is ready.
  137990. * @param subMesh The submesh to be used to render the depth map of
  137991. * @param useInstances If multiple world instances should be used
  137992. * @returns if the depth renderer is ready to render the depth map
  137993. */
  137994. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137995. /**
  137996. * Gets the texture which the depth map will be written to.
  137997. * @returns The depth map texture
  137998. */
  137999. getDepthMap(): RenderTargetTexture;
  138000. /**
  138001. * Disposes of the depth renderer.
  138002. */
  138003. dispose(): void;
  138004. }
  138005. }
  138006. declare module BABYLON {
  138007. /** @hidden */
  138008. export var minmaxReduxPixelShader: {
  138009. name: string;
  138010. shader: string;
  138011. };
  138012. }
  138013. declare module BABYLON {
  138014. /**
  138015. * This class computes a min/max reduction from a texture: it means it computes the minimum
  138016. * and maximum values from all values of the texture.
  138017. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  138018. * The source values are read from the red channel of the texture.
  138019. */
  138020. export class MinMaxReducer {
  138021. /**
  138022. * Observable triggered when the computation has been performed
  138023. */
  138024. onAfterReductionPerformed: Observable<{
  138025. min: number;
  138026. max: number;
  138027. }>;
  138028. protected _camera: Camera;
  138029. protected _sourceTexture: Nullable<RenderTargetTexture>;
  138030. protected _reductionSteps: Nullable<Array<PostProcess>>;
  138031. protected _postProcessManager: PostProcessManager;
  138032. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  138033. protected _forceFullscreenViewport: boolean;
  138034. /**
  138035. * Creates a min/max reducer
  138036. * @param camera The camera to use for the post processes
  138037. */
  138038. constructor(camera: Camera);
  138039. /**
  138040. * Gets the texture used to read the values from.
  138041. */
  138042. get sourceTexture(): Nullable<RenderTargetTexture>;
  138043. /**
  138044. * Sets the source texture to read the values from.
  138045. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  138046. * because in such textures '1' value must not be taken into account to compute the maximum
  138047. * as this value is used to clear the texture.
  138048. * Note that the computation is not activated by calling this function, you must call activate() for that!
  138049. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  138050. * @param depthRedux Indicates if the texture is a depth texture or not
  138051. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  138052. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138053. */
  138054. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138055. /**
  138056. * Defines the refresh rate of the computation.
  138057. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138058. */
  138059. get refreshRate(): number;
  138060. set refreshRate(value: number);
  138061. protected _activated: boolean;
  138062. /**
  138063. * Gets the activation status of the reducer
  138064. */
  138065. get activated(): boolean;
  138066. /**
  138067. * Activates the reduction computation.
  138068. * When activated, the observers registered in onAfterReductionPerformed are
  138069. * called after the compuation is performed
  138070. */
  138071. activate(): void;
  138072. /**
  138073. * Deactivates the reduction computation.
  138074. */
  138075. deactivate(): void;
  138076. /**
  138077. * Disposes the min/max reducer
  138078. * @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.
  138079. */
  138080. dispose(disposeAll?: boolean): void;
  138081. }
  138082. }
  138083. declare module BABYLON {
  138084. /**
  138085. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  138086. */
  138087. export class DepthReducer extends MinMaxReducer {
  138088. private _depthRenderer;
  138089. private _depthRendererId;
  138090. /**
  138091. * Gets the depth renderer used for the computation.
  138092. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  138093. */
  138094. get depthRenderer(): Nullable<DepthRenderer>;
  138095. /**
  138096. * Creates a depth reducer
  138097. * @param camera The camera used to render the depth texture
  138098. */
  138099. constructor(camera: Camera);
  138100. /**
  138101. * Sets the depth renderer to use to generate the depth map
  138102. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  138103. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  138104. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138105. */
  138106. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  138107. /** @hidden */
  138108. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138109. /**
  138110. * Activates the reduction computation.
  138111. * When activated, the observers registered in onAfterReductionPerformed are
  138112. * called after the compuation is performed
  138113. */
  138114. activate(): void;
  138115. /**
  138116. * Deactivates the reduction computation.
  138117. */
  138118. deactivate(): void;
  138119. /**
  138120. * Disposes the depth reducer
  138121. * @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.
  138122. */
  138123. dispose(disposeAll?: boolean): void;
  138124. }
  138125. }
  138126. declare module BABYLON {
  138127. /**
  138128. * A CSM implementation allowing casting shadows on large scenes.
  138129. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138130. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  138131. */
  138132. export class CascadedShadowGenerator extends ShadowGenerator {
  138133. private static readonly frustumCornersNDCSpace;
  138134. /**
  138135. * Name of the CSM class
  138136. */
  138137. static CLASSNAME: string;
  138138. /**
  138139. * Defines the default number of cascades used by the CSM.
  138140. */
  138141. static readonly DEFAULT_CASCADES_COUNT: number;
  138142. /**
  138143. * Defines the minimum number of cascades used by the CSM.
  138144. */
  138145. static readonly MIN_CASCADES_COUNT: number;
  138146. /**
  138147. * Defines the maximum number of cascades used by the CSM.
  138148. */
  138149. static readonly MAX_CASCADES_COUNT: number;
  138150. protected _validateFilter(filter: number): number;
  138151. /**
  138152. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  138153. */
  138154. penumbraDarkness: number;
  138155. private _numCascades;
  138156. /**
  138157. * Gets or set the number of cascades used by the CSM.
  138158. */
  138159. get numCascades(): number;
  138160. set numCascades(value: number);
  138161. /**
  138162. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  138163. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  138164. */
  138165. stabilizeCascades: boolean;
  138166. private _freezeShadowCastersBoundingInfo;
  138167. private _freezeShadowCastersBoundingInfoObservable;
  138168. /**
  138169. * Enables or disables the shadow casters bounding info computation.
  138170. * If your shadow casters don't move, you can disable this feature.
  138171. * If it is enabled, the bounding box computation is done every frame.
  138172. */
  138173. get freezeShadowCastersBoundingInfo(): boolean;
  138174. set freezeShadowCastersBoundingInfo(freeze: boolean);
  138175. private _scbiMin;
  138176. private _scbiMax;
  138177. protected _computeShadowCastersBoundingInfo(): void;
  138178. protected _shadowCastersBoundingInfo: BoundingInfo;
  138179. /**
  138180. * Gets or sets the shadow casters bounding info.
  138181. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  138182. * so that the system won't overwrite the bounds you provide
  138183. */
  138184. get shadowCastersBoundingInfo(): BoundingInfo;
  138185. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  138186. protected _breaksAreDirty: boolean;
  138187. protected _minDistance: number;
  138188. protected _maxDistance: number;
  138189. /**
  138190. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  138191. *
  138192. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  138193. * If you don't know these values, simply leave them to their defaults and don't call this function.
  138194. * @param min minimal distance for the breaks (default to 0.)
  138195. * @param max maximal distance for the breaks (default to 1.)
  138196. */
  138197. setMinMaxDistance(min: number, max: number): void;
  138198. /** Gets the minimal distance used in the cascade break computation */
  138199. get minDistance(): number;
  138200. /** Gets the maximal distance used in the cascade break computation */
  138201. get maxDistance(): number;
  138202. /**
  138203. * Gets the class name of that object
  138204. * @returns "CascadedShadowGenerator"
  138205. */
  138206. getClassName(): string;
  138207. private _cascadeMinExtents;
  138208. private _cascadeMaxExtents;
  138209. /**
  138210. * Gets a cascade minimum extents
  138211. * @param cascadeIndex index of the cascade
  138212. * @returns the minimum cascade extents
  138213. */
  138214. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  138215. /**
  138216. * Gets a cascade maximum extents
  138217. * @param cascadeIndex index of the cascade
  138218. * @returns the maximum cascade extents
  138219. */
  138220. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  138221. private _cascades;
  138222. private _currentLayer;
  138223. private _viewSpaceFrustumsZ;
  138224. private _viewMatrices;
  138225. private _projectionMatrices;
  138226. private _transformMatrices;
  138227. private _transformMatricesAsArray;
  138228. private _frustumLengths;
  138229. private _lightSizeUVCorrection;
  138230. private _depthCorrection;
  138231. private _frustumCornersWorldSpace;
  138232. private _frustumCenter;
  138233. private _shadowCameraPos;
  138234. private _shadowMaxZ;
  138235. /**
  138236. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  138237. * It defaults to camera.maxZ
  138238. */
  138239. get shadowMaxZ(): number;
  138240. /**
  138241. * Sets the shadow max z distance.
  138242. */
  138243. set shadowMaxZ(value: number);
  138244. protected _debug: boolean;
  138245. /**
  138246. * Gets or sets the debug flag.
  138247. * When enabled, the cascades are materialized by different colors on the screen.
  138248. */
  138249. get debug(): boolean;
  138250. set debug(dbg: boolean);
  138251. private _depthClamp;
  138252. /**
  138253. * Gets or sets the depth clamping value.
  138254. *
  138255. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  138256. * to account for the shadow casters far away.
  138257. *
  138258. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  138259. */
  138260. get depthClamp(): boolean;
  138261. set depthClamp(value: boolean);
  138262. private _cascadeBlendPercentage;
  138263. /**
  138264. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  138265. * It defaults to 0.1 (10% blending).
  138266. */
  138267. get cascadeBlendPercentage(): number;
  138268. set cascadeBlendPercentage(value: number);
  138269. private _lambda;
  138270. /**
  138271. * Gets or set the lambda parameter.
  138272. * This parameter is used to split the camera frustum and create the cascades.
  138273. * 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.
  138274. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  138275. */
  138276. get lambda(): number;
  138277. set lambda(value: number);
  138278. /**
  138279. * Gets the view matrix corresponding to a given cascade
  138280. * @param cascadeNum cascade to retrieve the view matrix from
  138281. * @returns the cascade view matrix
  138282. */
  138283. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  138284. /**
  138285. * Gets the projection matrix corresponding to a given cascade
  138286. * @param cascadeNum cascade to retrieve the projection matrix from
  138287. * @returns the cascade projection matrix
  138288. */
  138289. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  138290. /**
  138291. * Gets the transformation matrix corresponding to a given cascade
  138292. * @param cascadeNum cascade to retrieve the transformation matrix from
  138293. * @returns the cascade transformation matrix
  138294. */
  138295. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  138296. private _depthRenderer;
  138297. /**
  138298. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  138299. *
  138300. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  138301. *
  138302. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  138303. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  138304. * @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
  138305. */
  138306. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  138307. private _depthReducer;
  138308. private _autoCalcDepthBounds;
  138309. /**
  138310. * Gets or sets the autoCalcDepthBounds property.
  138311. *
  138312. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  138313. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  138314. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  138315. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  138316. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  138317. */
  138318. get autoCalcDepthBounds(): boolean;
  138319. set autoCalcDepthBounds(value: boolean);
  138320. /**
  138321. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  138322. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138323. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  138324. * for setting the refresh rate on the renderer yourself!
  138325. */
  138326. get autoCalcDepthBoundsRefreshRate(): number;
  138327. set autoCalcDepthBoundsRefreshRate(value: number);
  138328. /**
  138329. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  138330. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  138331. * you change the camera near/far planes!
  138332. */
  138333. splitFrustum(): void;
  138334. private _splitFrustum;
  138335. private _computeMatrices;
  138336. private _computeFrustumInWorldSpace;
  138337. private _computeCascadeFrustum;
  138338. /**
  138339. * Support test.
  138340. */
  138341. static get IsSupported(): boolean;
  138342. /** @hidden */
  138343. static _SceneComponentInitialization: (scene: Scene) => void;
  138344. /**
  138345. * Creates a Cascaded Shadow Generator object.
  138346. * A ShadowGenerator is the required tool to use the shadows.
  138347. * Each directional light casting shadows needs to use its own ShadowGenerator.
  138348. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138349. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  138350. * @param light The directional light object generating the shadows.
  138351. * @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.
  138352. */
  138353. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  138354. protected _initializeGenerator(): void;
  138355. protected _createTargetRenderTexture(): void;
  138356. protected _initializeShadowMap(): void;
  138357. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  138358. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  138359. /**
  138360. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  138361. * @param defines Defines of the material we want to update
  138362. * @param lightIndex Index of the light in the enabled light list of the material
  138363. */
  138364. prepareDefines(defines: any, lightIndex: number): void;
  138365. /**
  138366. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  138367. * defined in the generator but impacting the effect).
  138368. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  138369. * @param effect The effect we are binfing the information for
  138370. */
  138371. bindShadowLight(lightIndex: string, effect: Effect): void;
  138372. /**
  138373. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  138374. * (eq to view projection * shadow projection matrices)
  138375. * @returns The transform matrix used to create the shadow map
  138376. */
  138377. getTransformMatrix(): Matrix;
  138378. /**
  138379. * Disposes the ShadowGenerator.
  138380. * Returns nothing.
  138381. */
  138382. dispose(): void;
  138383. /**
  138384. * Serializes the shadow generator setup to a json object.
  138385. * @returns The serialized JSON object
  138386. */
  138387. serialize(): any;
  138388. /**
  138389. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  138390. * @param parsedShadowGenerator The JSON object to parse
  138391. * @param scene The scene to create the shadow map for
  138392. * @returns The parsed shadow generator
  138393. */
  138394. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  138395. }
  138396. }
  138397. declare module BABYLON {
  138398. /**
  138399. * Defines the shadow generator component responsible to manage any shadow generators
  138400. * in a given scene.
  138401. */
  138402. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  138403. /**
  138404. * The component name helpfull to identify the component in the list of scene components.
  138405. */
  138406. readonly name: string;
  138407. /**
  138408. * The scene the component belongs to.
  138409. */
  138410. scene: Scene;
  138411. /**
  138412. * Creates a new instance of the component for the given scene
  138413. * @param scene Defines the scene to register the component in
  138414. */
  138415. constructor(scene: Scene);
  138416. /**
  138417. * Registers the component in a given scene
  138418. */
  138419. register(): void;
  138420. /**
  138421. * Rebuilds the elements related to this component in case of
  138422. * context lost for instance.
  138423. */
  138424. rebuild(): void;
  138425. /**
  138426. * Serializes the component data to the specified json object
  138427. * @param serializationObject The object to serialize to
  138428. */
  138429. serialize(serializationObject: any): void;
  138430. /**
  138431. * Adds all the elements from the container to the scene
  138432. * @param container the container holding the elements
  138433. */
  138434. addFromContainer(container: AbstractScene): void;
  138435. /**
  138436. * Removes all the elements in the container from the scene
  138437. * @param container contains the elements to remove
  138438. * @param dispose if the removed element should be disposed (default: false)
  138439. */
  138440. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138441. /**
  138442. * Rebuilds the elements related to this component in case of
  138443. * context lost for instance.
  138444. */
  138445. dispose(): void;
  138446. private _gatherRenderTargets;
  138447. }
  138448. }
  138449. declare module BABYLON {
  138450. /**
  138451. * A point light is a light defined by an unique point in world space.
  138452. * The light is emitted in every direction from this point.
  138453. * A good example of a point light is a standard light bulb.
  138454. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138455. */
  138456. export class PointLight extends ShadowLight {
  138457. private _shadowAngle;
  138458. /**
  138459. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138460. * This specifies what angle the shadow will use to be created.
  138461. *
  138462. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138463. */
  138464. get shadowAngle(): number;
  138465. /**
  138466. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138467. * This specifies what angle the shadow will use to be created.
  138468. *
  138469. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138470. */
  138471. set shadowAngle(value: number);
  138472. /**
  138473. * Gets the direction if it has been set.
  138474. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138475. */
  138476. get direction(): Vector3;
  138477. /**
  138478. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138479. */
  138480. set direction(value: Vector3);
  138481. /**
  138482. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  138483. * A PointLight emits the light in every direction.
  138484. * It can cast shadows.
  138485. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  138486. * ```javascript
  138487. * var pointLight = new PointLight("pl", camera.position, scene);
  138488. * ```
  138489. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138490. * @param name The light friendly name
  138491. * @param position The position of the point light in the scene
  138492. * @param scene The scene the lights belongs to
  138493. */
  138494. constructor(name: string, position: Vector3, scene: Scene);
  138495. /**
  138496. * Returns the string "PointLight"
  138497. * @returns the class name
  138498. */
  138499. getClassName(): string;
  138500. /**
  138501. * Returns the integer 0.
  138502. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138503. */
  138504. getTypeID(): number;
  138505. /**
  138506. * Specifies wether or not the shadowmap should be a cube texture.
  138507. * @returns true if the shadowmap needs to be a cube texture.
  138508. */
  138509. needCube(): boolean;
  138510. /**
  138511. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  138512. * @param faceIndex The index of the face we are computed the direction to generate shadow
  138513. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  138514. */
  138515. getShadowDirection(faceIndex?: number): Vector3;
  138516. /**
  138517. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  138518. * - fov = PI / 2
  138519. * - aspect ratio : 1.0
  138520. * - z-near and far equal to the active camera minZ and maxZ.
  138521. * Returns the PointLight.
  138522. */
  138523. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138524. protected _buildUniformLayout(): void;
  138525. /**
  138526. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  138527. * @param effect The effect to update
  138528. * @param lightIndex The index of the light in the effect to update
  138529. * @returns The point light
  138530. */
  138531. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  138532. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138533. /**
  138534. * Prepares the list of defines specific to the light type.
  138535. * @param defines the list of defines
  138536. * @param lightIndex defines the index of the light for the effect
  138537. */
  138538. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138539. }
  138540. }
  138541. declare module BABYLON {
  138542. /**
  138543. * Header information of HDR texture files.
  138544. */
  138545. export interface HDRInfo {
  138546. /**
  138547. * The height of the texture in pixels.
  138548. */
  138549. height: number;
  138550. /**
  138551. * The width of the texture in pixels.
  138552. */
  138553. width: number;
  138554. /**
  138555. * The index of the beginning of the data in the binary file.
  138556. */
  138557. dataPosition: number;
  138558. }
  138559. /**
  138560. * This groups tools to convert HDR texture to native colors array.
  138561. */
  138562. export class HDRTools {
  138563. private static Ldexp;
  138564. private static Rgbe2float;
  138565. private static readStringLine;
  138566. /**
  138567. * Reads header information from an RGBE texture stored in a native array.
  138568. * More information on this format are available here:
  138569. * https://en.wikipedia.org/wiki/RGBE_image_format
  138570. *
  138571. * @param uint8array The binary file stored in native array.
  138572. * @return The header information.
  138573. */
  138574. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  138575. /**
  138576. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  138577. * This RGBE texture needs to store the information as a panorama.
  138578. *
  138579. * More information on this format are available here:
  138580. * https://en.wikipedia.org/wiki/RGBE_image_format
  138581. *
  138582. * @param buffer The binary file stored in an array buffer.
  138583. * @param size The expected size of the extracted cubemap.
  138584. * @return The Cube Map information.
  138585. */
  138586. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  138587. /**
  138588. * Returns the pixels data extracted from an RGBE texture.
  138589. * This pixels will be stored left to right up to down in the R G B order in one array.
  138590. *
  138591. * More information on this format are available here:
  138592. * https://en.wikipedia.org/wiki/RGBE_image_format
  138593. *
  138594. * @param uint8array The binary file stored in an array buffer.
  138595. * @param hdrInfo The header information of the file.
  138596. * @return The pixels data in RGB right to left up to down order.
  138597. */
  138598. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  138599. private static RGBE_ReadPixels_RLE;
  138600. private static RGBE_ReadPixels_NOT_RLE;
  138601. }
  138602. }
  138603. declare module BABYLON {
  138604. /**
  138605. * Effect Render Options
  138606. */
  138607. export interface IEffectRendererOptions {
  138608. /**
  138609. * Defines the vertices positions.
  138610. */
  138611. positions?: number[];
  138612. /**
  138613. * Defines the indices.
  138614. */
  138615. indices?: number[];
  138616. }
  138617. /**
  138618. * Helper class to render one or more effects.
  138619. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138620. */
  138621. export class EffectRenderer {
  138622. private engine;
  138623. private static _DefaultOptions;
  138624. private _vertexBuffers;
  138625. private _indexBuffer;
  138626. private _fullscreenViewport;
  138627. /**
  138628. * Creates an effect renderer
  138629. * @param engine the engine to use for rendering
  138630. * @param options defines the options of the effect renderer
  138631. */
  138632. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138633. /**
  138634. * Sets the current viewport in normalized coordinates 0-1
  138635. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138636. */
  138637. setViewport(viewport?: Viewport): void;
  138638. /**
  138639. * Binds the embedded attributes buffer to the effect.
  138640. * @param effect Defines the effect to bind the attributes for
  138641. */
  138642. bindBuffers(effect: Effect): void;
  138643. /**
  138644. * Sets the current effect wrapper to use during draw.
  138645. * The effect needs to be ready before calling this api.
  138646. * This also sets the default full screen position attribute.
  138647. * @param effectWrapper Defines the effect to draw with
  138648. */
  138649. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138650. /**
  138651. * Restores engine states
  138652. */
  138653. restoreStates(): void;
  138654. /**
  138655. * Draws a full screen quad.
  138656. */
  138657. draw(): void;
  138658. private isRenderTargetTexture;
  138659. /**
  138660. * renders one or more effects to a specified texture
  138661. * @param effectWrapper the effect to renderer
  138662. * @param outputTexture texture to draw to, if null it will render to the screen.
  138663. */
  138664. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138665. /**
  138666. * Disposes of the effect renderer
  138667. */
  138668. dispose(): void;
  138669. }
  138670. /**
  138671. * Options to create an EffectWrapper
  138672. */
  138673. interface EffectWrapperCreationOptions {
  138674. /**
  138675. * Engine to use to create the effect
  138676. */
  138677. engine: ThinEngine;
  138678. /**
  138679. * Fragment shader for the effect
  138680. */
  138681. fragmentShader: string;
  138682. /**
  138683. * Use the shader store instead of direct source code
  138684. */
  138685. useShaderStore?: boolean;
  138686. /**
  138687. * Vertex shader for the effect
  138688. */
  138689. vertexShader?: string;
  138690. /**
  138691. * Attributes to use in the shader
  138692. */
  138693. attributeNames?: Array<string>;
  138694. /**
  138695. * Uniforms to use in the shader
  138696. */
  138697. uniformNames?: Array<string>;
  138698. /**
  138699. * Texture sampler names to use in the shader
  138700. */
  138701. samplerNames?: Array<string>;
  138702. /**
  138703. * Defines to use in the shader
  138704. */
  138705. defines?: Array<string>;
  138706. /**
  138707. * Callback when effect is compiled
  138708. */
  138709. onCompiled?: Nullable<(effect: Effect) => void>;
  138710. /**
  138711. * The friendly name of the effect displayed in Spector.
  138712. */
  138713. name?: string;
  138714. }
  138715. /**
  138716. * Wraps an effect to be used for rendering
  138717. */
  138718. export class EffectWrapper {
  138719. /**
  138720. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138721. */
  138722. onApplyObservable: Observable<{}>;
  138723. /**
  138724. * The underlying effect
  138725. */
  138726. effect: Effect;
  138727. /**
  138728. * Creates an effect to be renderer
  138729. * @param creationOptions options to create the effect
  138730. */
  138731. constructor(creationOptions: EffectWrapperCreationOptions);
  138732. /**
  138733. * Disposes of the effect wrapper
  138734. */
  138735. dispose(): void;
  138736. }
  138737. }
  138738. declare module BABYLON {
  138739. /** @hidden */
  138740. export var hdrFilteringVertexShader: {
  138741. name: string;
  138742. shader: string;
  138743. };
  138744. }
  138745. declare module BABYLON {
  138746. /** @hidden */
  138747. export var hdrFilteringPixelShader: {
  138748. name: string;
  138749. shader: string;
  138750. };
  138751. }
  138752. declare module BABYLON {
  138753. /**
  138754. * Options for texture filtering
  138755. */
  138756. interface IHDRFilteringOptions {
  138757. /**
  138758. * Scales pixel intensity for the input HDR map.
  138759. */
  138760. hdrScale?: number;
  138761. /**
  138762. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  138763. */
  138764. quality?: number;
  138765. }
  138766. /**
  138767. * Filters HDR maps to get correct renderings of PBR reflections
  138768. */
  138769. export class HDRFiltering {
  138770. private _engine;
  138771. private _effectRenderer;
  138772. private _effectWrapper;
  138773. private _lodGenerationOffset;
  138774. private _lodGenerationScale;
  138775. /**
  138776. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  138777. * you care about baking speed.
  138778. */
  138779. quality: number;
  138780. /**
  138781. * Scales pixel intensity for the input HDR map.
  138782. */
  138783. hdrScale: number;
  138784. /**
  138785. * Instantiates HDR filter for reflection maps
  138786. *
  138787. * @param engine Thin engine
  138788. * @param options Options
  138789. */
  138790. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  138791. private _createRenderTarget;
  138792. private _prefilterInternal;
  138793. private _createEffect;
  138794. /**
  138795. * Get a value indicating if the filter is ready to be used
  138796. * @param texture Texture to filter
  138797. * @returns true if the filter is ready
  138798. */
  138799. isReady(texture: BaseTexture): boolean;
  138800. /**
  138801. * Prefilters a cube texture to have mipmap levels representing roughness values.
  138802. * Prefiltering will be invoked at the end of next rendering pass.
  138803. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  138804. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  138805. * @param texture Texture to filter
  138806. * @param onFinished Callback when filtering is done
  138807. * @return Promise called when prefiltering is done
  138808. */
  138809. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  138810. }
  138811. }
  138812. declare module BABYLON {
  138813. /**
  138814. * This represents a texture coming from an HDR input.
  138815. *
  138816. * The only supported format is currently panorama picture stored in RGBE format.
  138817. * Example of such files can be found on HDRLib: http://hdrlib.com/
  138818. */
  138819. export class HDRCubeTexture extends BaseTexture {
  138820. private static _facesMapping;
  138821. private _generateHarmonics;
  138822. private _noMipmap;
  138823. private _prefilterOnLoad;
  138824. private _textureMatrix;
  138825. private _size;
  138826. private _onLoad;
  138827. private _onError;
  138828. /**
  138829. * The texture URL.
  138830. */
  138831. url: string;
  138832. /**
  138833. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  138834. */
  138835. coordinatesMode: number;
  138836. protected _isBlocking: boolean;
  138837. /**
  138838. * Sets wether or not the texture is blocking during loading.
  138839. */
  138840. set isBlocking(value: boolean);
  138841. /**
  138842. * Gets wether or not the texture is blocking during loading.
  138843. */
  138844. get isBlocking(): boolean;
  138845. protected _rotationY: number;
  138846. /**
  138847. * Sets texture matrix rotation angle around Y axis in radians.
  138848. */
  138849. set rotationY(value: number);
  138850. /**
  138851. * Gets texture matrix rotation angle around Y axis radians.
  138852. */
  138853. get rotationY(): number;
  138854. /**
  138855. * Gets or sets the center of the bounding box associated with the cube texture
  138856. * It must define where the camera used to render the texture was set
  138857. */
  138858. boundingBoxPosition: Vector3;
  138859. private _boundingBoxSize;
  138860. /**
  138861. * Gets or sets the size of the bounding box associated with the cube texture
  138862. * When defined, the cubemap will switch to local mode
  138863. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  138864. * @example https://www.babylonjs-playground.com/#RNASML
  138865. */
  138866. set boundingBoxSize(value: Vector3);
  138867. get boundingBoxSize(): Vector3;
  138868. /**
  138869. * Instantiates an HDRTexture from the following parameters.
  138870. *
  138871. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  138872. * @param sceneOrEngine The scene or engine the texture will be used in
  138873. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138874. * @param noMipmap Forces to not generate the mipmap if true
  138875. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  138876. * @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)
  138877. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  138878. */
  138879. 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>);
  138880. /**
  138881. * Get the current class name of the texture useful for serialization or dynamic coding.
  138882. * @returns "HDRCubeTexture"
  138883. */
  138884. getClassName(): string;
  138885. /**
  138886. * Occurs when the file is raw .hdr file.
  138887. */
  138888. private loadTexture;
  138889. clone(): HDRCubeTexture;
  138890. delayLoad(): void;
  138891. /**
  138892. * Get the texture reflection matrix used to rotate/transform the reflection.
  138893. * @returns the reflection matrix
  138894. */
  138895. getReflectionTextureMatrix(): Matrix;
  138896. /**
  138897. * Set the texture reflection matrix used to rotate/transform the reflection.
  138898. * @param value Define the reflection matrix to set
  138899. */
  138900. setReflectionTextureMatrix(value: Matrix): void;
  138901. /**
  138902. * Parses a JSON representation of an HDR Texture in order to create the texture
  138903. * @param parsedTexture Define the JSON representation
  138904. * @param scene Define the scene the texture should be created in
  138905. * @param rootUrl Define the root url in case we need to load relative dependencies
  138906. * @returns the newly created texture after parsing
  138907. */
  138908. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  138909. serialize(): any;
  138910. }
  138911. }
  138912. declare module BABYLON {
  138913. /**
  138914. * Class used to control physics engine
  138915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  138916. */
  138917. export class PhysicsEngine implements IPhysicsEngine {
  138918. private _physicsPlugin;
  138919. /**
  138920. * Global value used to control the smallest number supported by the simulation
  138921. */
  138922. static Epsilon: number;
  138923. private _impostors;
  138924. private _joints;
  138925. private _subTimeStep;
  138926. /**
  138927. * Gets the gravity vector used by the simulation
  138928. */
  138929. gravity: Vector3;
  138930. /**
  138931. * Factory used to create the default physics plugin.
  138932. * @returns The default physics plugin
  138933. */
  138934. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  138935. /**
  138936. * Creates a new Physics Engine
  138937. * @param gravity defines the gravity vector used by the simulation
  138938. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  138939. */
  138940. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  138941. /**
  138942. * Sets the gravity vector used by the simulation
  138943. * @param gravity defines the gravity vector to use
  138944. */
  138945. setGravity(gravity: Vector3): void;
  138946. /**
  138947. * Set the time step of the physics engine.
  138948. * Default is 1/60.
  138949. * To slow it down, enter 1/600 for example.
  138950. * To speed it up, 1/30
  138951. * @param newTimeStep defines the new timestep to apply to this world.
  138952. */
  138953. setTimeStep(newTimeStep?: number): void;
  138954. /**
  138955. * Get the time step of the physics engine.
  138956. * @returns the current time step
  138957. */
  138958. getTimeStep(): number;
  138959. /**
  138960. * Set the sub time step of the physics engine.
  138961. * Default is 0 meaning there is no sub steps
  138962. * To increase physics resolution precision, set a small value (like 1 ms)
  138963. * @param subTimeStep defines the new sub timestep used for physics resolution.
  138964. */
  138965. setSubTimeStep(subTimeStep?: number): void;
  138966. /**
  138967. * Get the sub time step of the physics engine.
  138968. * @returns the current sub time step
  138969. */
  138970. getSubTimeStep(): number;
  138971. /**
  138972. * Release all resources
  138973. */
  138974. dispose(): void;
  138975. /**
  138976. * Gets the name of the current physics plugin
  138977. * @returns the name of the plugin
  138978. */
  138979. getPhysicsPluginName(): string;
  138980. /**
  138981. * Adding a new impostor for the impostor tracking.
  138982. * This will be done by the impostor itself.
  138983. * @param impostor the impostor to add
  138984. */
  138985. addImpostor(impostor: PhysicsImpostor): void;
  138986. /**
  138987. * Remove an impostor from the engine.
  138988. * This impostor and its mesh will not longer be updated by the physics engine.
  138989. * @param impostor the impostor to remove
  138990. */
  138991. removeImpostor(impostor: PhysicsImpostor): void;
  138992. /**
  138993. * Add a joint to the physics engine
  138994. * @param mainImpostor defines the main impostor to which the joint is added.
  138995. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  138996. * @param joint defines the joint that will connect both impostors.
  138997. */
  138998. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  138999. /**
  139000. * Removes a joint from the simulation
  139001. * @param mainImpostor defines the impostor used with the joint
  139002. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  139003. * @param joint defines the joint to remove
  139004. */
  139005. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139006. /**
  139007. * Called by the scene. No need to call it.
  139008. * @param delta defines the timespam between frames
  139009. */
  139010. _step(delta: number): void;
  139011. /**
  139012. * Gets the current plugin used to run the simulation
  139013. * @returns current plugin
  139014. */
  139015. getPhysicsPlugin(): IPhysicsEnginePlugin;
  139016. /**
  139017. * Gets the list of physic impostors
  139018. * @returns an array of PhysicsImpostor
  139019. */
  139020. getImpostors(): Array<PhysicsImpostor>;
  139021. /**
  139022. * Gets the impostor for a physics enabled object
  139023. * @param object defines the object impersonated by the impostor
  139024. * @returns the PhysicsImpostor or null if not found
  139025. */
  139026. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  139027. /**
  139028. * Gets the impostor for a physics body object
  139029. * @param body defines physics body used by the impostor
  139030. * @returns the PhysicsImpostor or null if not found
  139031. */
  139032. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  139033. /**
  139034. * Does a raycast in the physics world
  139035. * @param from when should the ray start?
  139036. * @param to when should the ray end?
  139037. * @returns PhysicsRaycastResult
  139038. */
  139039. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139040. }
  139041. }
  139042. declare module BABYLON {
  139043. /** @hidden */
  139044. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  139045. private _useDeltaForWorldStep;
  139046. world: any;
  139047. name: string;
  139048. private _physicsMaterials;
  139049. private _fixedTimeStep;
  139050. private _cannonRaycastResult;
  139051. private _raycastResult;
  139052. private _physicsBodysToRemoveAfterStep;
  139053. private _firstFrame;
  139054. BJSCANNON: any;
  139055. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  139056. setGravity(gravity: Vector3): void;
  139057. setTimeStep(timeStep: number): void;
  139058. getTimeStep(): number;
  139059. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139060. private _removeMarkedPhysicsBodiesFromWorld;
  139061. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139062. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139063. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139064. private _processChildMeshes;
  139065. removePhysicsBody(impostor: PhysicsImpostor): void;
  139066. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139067. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139068. private _addMaterial;
  139069. private _checkWithEpsilon;
  139070. private _createShape;
  139071. private _createHeightmap;
  139072. private _minus90X;
  139073. private _plus90X;
  139074. private _tmpPosition;
  139075. private _tmpDeltaPosition;
  139076. private _tmpUnityRotation;
  139077. private _updatePhysicsBodyTransformation;
  139078. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139079. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139080. isSupported(): boolean;
  139081. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139082. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139083. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139084. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139085. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139086. getBodyMass(impostor: PhysicsImpostor): number;
  139087. getBodyFriction(impostor: PhysicsImpostor): number;
  139088. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139089. getBodyRestitution(impostor: PhysicsImpostor): number;
  139090. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139091. sleepBody(impostor: PhysicsImpostor): void;
  139092. wakeUpBody(impostor: PhysicsImpostor): void;
  139093. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  139094. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139095. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139096. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139097. getRadius(impostor: PhysicsImpostor): number;
  139098. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139099. dispose(): void;
  139100. private _extendNamespace;
  139101. /**
  139102. * Does a raycast in the physics world
  139103. * @param from when should the ray start?
  139104. * @param to when should the ray end?
  139105. * @returns PhysicsRaycastResult
  139106. */
  139107. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139108. }
  139109. }
  139110. declare module BABYLON {
  139111. /** @hidden */
  139112. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  139113. private _useDeltaForWorldStep;
  139114. world: any;
  139115. name: string;
  139116. BJSOIMO: any;
  139117. private _raycastResult;
  139118. private _fixedTimeStep;
  139119. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  139120. setGravity(gravity: Vector3): void;
  139121. setTimeStep(timeStep: number): void;
  139122. getTimeStep(): number;
  139123. private _tmpImpostorsArray;
  139124. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139125. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139126. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139127. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139128. private _tmpPositionVector;
  139129. removePhysicsBody(impostor: PhysicsImpostor): void;
  139130. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139131. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139132. isSupported(): boolean;
  139133. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139134. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139135. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139136. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139137. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139138. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139139. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139140. getBodyMass(impostor: PhysicsImpostor): number;
  139141. getBodyFriction(impostor: PhysicsImpostor): number;
  139142. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139143. getBodyRestitution(impostor: PhysicsImpostor): number;
  139144. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139145. sleepBody(impostor: PhysicsImpostor): void;
  139146. wakeUpBody(impostor: PhysicsImpostor): void;
  139147. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139148. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  139149. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  139150. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139151. getRadius(impostor: PhysicsImpostor): number;
  139152. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139153. dispose(): void;
  139154. /**
  139155. * Does a raycast in the physics world
  139156. * @param from when should the ray start?
  139157. * @param to when should the ray end?
  139158. * @returns PhysicsRaycastResult
  139159. */
  139160. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139161. }
  139162. }
  139163. declare module BABYLON {
  139164. /**
  139165. * AmmoJS Physics plugin
  139166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139167. * @see https://github.com/kripken/ammo.js/
  139168. */
  139169. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  139170. private _useDeltaForWorldStep;
  139171. /**
  139172. * Reference to the Ammo library
  139173. */
  139174. bjsAMMO: any;
  139175. /**
  139176. * Created ammoJS world which physics bodies are added to
  139177. */
  139178. world: any;
  139179. /**
  139180. * Name of the plugin
  139181. */
  139182. name: string;
  139183. private _timeStep;
  139184. private _fixedTimeStep;
  139185. private _maxSteps;
  139186. private _tmpQuaternion;
  139187. private _tmpAmmoTransform;
  139188. private _tmpAmmoQuaternion;
  139189. private _tmpAmmoConcreteContactResultCallback;
  139190. private _collisionConfiguration;
  139191. private _dispatcher;
  139192. private _overlappingPairCache;
  139193. private _solver;
  139194. private _softBodySolver;
  139195. private _tmpAmmoVectorA;
  139196. private _tmpAmmoVectorB;
  139197. private _tmpAmmoVectorC;
  139198. private _tmpAmmoVectorD;
  139199. private _tmpContactCallbackResult;
  139200. private _tmpAmmoVectorRCA;
  139201. private _tmpAmmoVectorRCB;
  139202. private _raycastResult;
  139203. private static readonly DISABLE_COLLISION_FLAG;
  139204. private static readonly KINEMATIC_FLAG;
  139205. private static readonly DISABLE_DEACTIVATION_FLAG;
  139206. /**
  139207. * Initializes the ammoJS plugin
  139208. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  139209. * @param ammoInjection can be used to inject your own ammo reference
  139210. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  139211. */
  139212. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  139213. /**
  139214. * Sets the gravity of the physics world (m/(s^2))
  139215. * @param gravity Gravity to set
  139216. */
  139217. setGravity(gravity: Vector3): void;
  139218. /**
  139219. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  139220. * @param timeStep timestep to use in seconds
  139221. */
  139222. setTimeStep(timeStep: number): void;
  139223. /**
  139224. * 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)
  139225. * @param fixedTimeStep fixedTimeStep to use in seconds
  139226. */
  139227. setFixedTimeStep(fixedTimeStep: number): void;
  139228. /**
  139229. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  139230. * @param maxSteps the maximum number of steps by the physics engine per frame
  139231. */
  139232. setMaxSteps(maxSteps: number): void;
  139233. /**
  139234. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  139235. * @returns the current timestep in seconds
  139236. */
  139237. getTimeStep(): number;
  139238. /**
  139239. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  139240. */
  139241. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  139242. private _isImpostorInContact;
  139243. private _isImpostorPairInContact;
  139244. private _stepSimulation;
  139245. /**
  139246. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  139247. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  139248. * After the step the babylon meshes are set to the position of the physics imposters
  139249. * @param delta amount of time to step forward
  139250. * @param impostors array of imposters to update before/after the step
  139251. */
  139252. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139253. /**
  139254. * Update babylon mesh to match physics world object
  139255. * @param impostor imposter to match
  139256. */
  139257. private _afterSoftStep;
  139258. /**
  139259. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139260. * @param impostor imposter to match
  139261. */
  139262. private _ropeStep;
  139263. /**
  139264. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139265. * @param impostor imposter to match
  139266. */
  139267. private _softbodyOrClothStep;
  139268. private _tmpMatrix;
  139269. /**
  139270. * Applies an impulse on the imposter
  139271. * @param impostor imposter to apply impulse to
  139272. * @param force amount of force to be applied to the imposter
  139273. * @param contactPoint the location to apply the impulse on the imposter
  139274. */
  139275. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139276. /**
  139277. * Applies a force on the imposter
  139278. * @param impostor imposter to apply force
  139279. * @param force amount of force to be applied to the imposter
  139280. * @param contactPoint the location to apply the force on the imposter
  139281. */
  139282. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139283. /**
  139284. * Creates a physics body using the plugin
  139285. * @param impostor the imposter to create the physics body on
  139286. */
  139287. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139288. /**
  139289. * Removes the physics body from the imposter and disposes of the body's memory
  139290. * @param impostor imposter to remove the physics body from
  139291. */
  139292. removePhysicsBody(impostor: PhysicsImpostor): void;
  139293. /**
  139294. * Generates a joint
  139295. * @param impostorJoint the imposter joint to create the joint with
  139296. */
  139297. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139298. /**
  139299. * Removes a joint
  139300. * @param impostorJoint the imposter joint to remove the joint from
  139301. */
  139302. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139303. private _addMeshVerts;
  139304. /**
  139305. * Initialise the soft body vertices to match its object's (mesh) vertices
  139306. * Softbody vertices (nodes) are in world space and to match this
  139307. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  139308. * @param impostor to create the softbody for
  139309. */
  139310. private _softVertexData;
  139311. /**
  139312. * Create an impostor's soft body
  139313. * @param impostor to create the softbody for
  139314. */
  139315. private _createSoftbody;
  139316. /**
  139317. * Create cloth for an impostor
  139318. * @param impostor to create the softbody for
  139319. */
  139320. private _createCloth;
  139321. /**
  139322. * Create rope for an impostor
  139323. * @param impostor to create the softbody for
  139324. */
  139325. private _createRope;
  139326. /**
  139327. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  139328. * @param impostor to create the custom physics shape for
  139329. */
  139330. private _createCustom;
  139331. private _addHullVerts;
  139332. private _createShape;
  139333. /**
  139334. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  139335. * @param impostor imposter containing the physics body and babylon object
  139336. */
  139337. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139338. /**
  139339. * Sets the babylon object's position/rotation from the physics body's position/rotation
  139340. * @param impostor imposter containing the physics body and babylon object
  139341. * @param newPosition new position
  139342. * @param newRotation new rotation
  139343. */
  139344. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139345. /**
  139346. * If this plugin is supported
  139347. * @returns true if its supported
  139348. */
  139349. isSupported(): boolean;
  139350. /**
  139351. * Sets the linear velocity of the physics body
  139352. * @param impostor imposter to set the velocity on
  139353. * @param velocity velocity to set
  139354. */
  139355. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139356. /**
  139357. * Sets the angular velocity of the physics body
  139358. * @param impostor imposter to set the velocity on
  139359. * @param velocity velocity to set
  139360. */
  139361. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139362. /**
  139363. * gets the linear velocity
  139364. * @param impostor imposter to get linear velocity from
  139365. * @returns linear velocity
  139366. */
  139367. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139368. /**
  139369. * gets the angular velocity
  139370. * @param impostor imposter to get angular velocity from
  139371. * @returns angular velocity
  139372. */
  139373. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139374. /**
  139375. * Sets the mass of physics body
  139376. * @param impostor imposter to set the mass on
  139377. * @param mass mass to set
  139378. */
  139379. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139380. /**
  139381. * Gets the mass of the physics body
  139382. * @param impostor imposter to get the mass from
  139383. * @returns mass
  139384. */
  139385. getBodyMass(impostor: PhysicsImpostor): number;
  139386. /**
  139387. * Gets friction of the impostor
  139388. * @param impostor impostor to get friction from
  139389. * @returns friction value
  139390. */
  139391. getBodyFriction(impostor: PhysicsImpostor): number;
  139392. /**
  139393. * Sets friction of the impostor
  139394. * @param impostor impostor to set friction on
  139395. * @param friction friction value
  139396. */
  139397. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139398. /**
  139399. * Gets restitution of the impostor
  139400. * @param impostor impostor to get restitution from
  139401. * @returns restitution value
  139402. */
  139403. getBodyRestitution(impostor: PhysicsImpostor): number;
  139404. /**
  139405. * Sets resitution of the impostor
  139406. * @param impostor impostor to set resitution on
  139407. * @param restitution resitution value
  139408. */
  139409. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139410. /**
  139411. * Gets pressure inside the impostor
  139412. * @param impostor impostor to get pressure from
  139413. * @returns pressure value
  139414. */
  139415. getBodyPressure(impostor: PhysicsImpostor): number;
  139416. /**
  139417. * Sets pressure inside a soft body impostor
  139418. * Cloth and rope must remain 0 pressure
  139419. * @param impostor impostor to set pressure on
  139420. * @param pressure pressure value
  139421. */
  139422. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  139423. /**
  139424. * Gets stiffness of the impostor
  139425. * @param impostor impostor to get stiffness from
  139426. * @returns pressure value
  139427. */
  139428. getBodyStiffness(impostor: PhysicsImpostor): number;
  139429. /**
  139430. * Sets stiffness of the impostor
  139431. * @param impostor impostor to set stiffness on
  139432. * @param stiffness stiffness value from 0 to 1
  139433. */
  139434. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  139435. /**
  139436. * Gets velocityIterations of the impostor
  139437. * @param impostor impostor to get velocity iterations from
  139438. * @returns velocityIterations value
  139439. */
  139440. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  139441. /**
  139442. * Sets velocityIterations of the impostor
  139443. * @param impostor impostor to set velocity iterations on
  139444. * @param velocityIterations velocityIterations value
  139445. */
  139446. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  139447. /**
  139448. * Gets positionIterations of the impostor
  139449. * @param impostor impostor to get position iterations from
  139450. * @returns positionIterations value
  139451. */
  139452. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  139453. /**
  139454. * Sets positionIterations of the impostor
  139455. * @param impostor impostor to set position on
  139456. * @param positionIterations positionIterations value
  139457. */
  139458. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  139459. /**
  139460. * Append an anchor to a cloth object
  139461. * @param impostor is the cloth impostor to add anchor to
  139462. * @param otherImpostor is the rigid impostor to anchor to
  139463. * @param width ratio across width from 0 to 1
  139464. * @param height ratio up height from 0 to 1
  139465. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  139466. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139467. */
  139468. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139469. /**
  139470. * Append an hook to a rope object
  139471. * @param impostor is the rope impostor to add hook to
  139472. * @param otherImpostor is the rigid impostor to hook to
  139473. * @param length ratio along the rope from 0 to 1
  139474. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  139475. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139476. */
  139477. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139478. /**
  139479. * Sleeps the physics body and stops it from being active
  139480. * @param impostor impostor to sleep
  139481. */
  139482. sleepBody(impostor: PhysicsImpostor): void;
  139483. /**
  139484. * Activates the physics body
  139485. * @param impostor impostor to activate
  139486. */
  139487. wakeUpBody(impostor: PhysicsImpostor): void;
  139488. /**
  139489. * Updates the distance parameters of the joint
  139490. * @param joint joint to update
  139491. * @param maxDistance maximum distance of the joint
  139492. * @param minDistance minimum distance of the joint
  139493. */
  139494. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139495. /**
  139496. * Sets a motor on the joint
  139497. * @param joint joint to set motor on
  139498. * @param speed speed of the motor
  139499. * @param maxForce maximum force of the motor
  139500. * @param motorIndex index of the motor
  139501. */
  139502. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139503. /**
  139504. * Sets the motors limit
  139505. * @param joint joint to set limit on
  139506. * @param upperLimit upper limit
  139507. * @param lowerLimit lower limit
  139508. */
  139509. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139510. /**
  139511. * Syncs the position and rotation of a mesh with the impostor
  139512. * @param mesh mesh to sync
  139513. * @param impostor impostor to update the mesh with
  139514. */
  139515. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139516. /**
  139517. * Gets the radius of the impostor
  139518. * @param impostor impostor to get radius from
  139519. * @returns the radius
  139520. */
  139521. getRadius(impostor: PhysicsImpostor): number;
  139522. /**
  139523. * Gets the box size of the impostor
  139524. * @param impostor impostor to get box size from
  139525. * @param result the resulting box size
  139526. */
  139527. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139528. /**
  139529. * Disposes of the impostor
  139530. */
  139531. dispose(): void;
  139532. /**
  139533. * Does a raycast in the physics world
  139534. * @param from when should the ray start?
  139535. * @param to when should the ray end?
  139536. * @returns PhysicsRaycastResult
  139537. */
  139538. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139539. }
  139540. }
  139541. declare module BABYLON {
  139542. interface AbstractScene {
  139543. /**
  139544. * The list of reflection probes added to the scene
  139545. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139546. */
  139547. reflectionProbes: Array<ReflectionProbe>;
  139548. /**
  139549. * Removes the given reflection probe from this scene.
  139550. * @param toRemove The reflection probe to remove
  139551. * @returns The index of the removed reflection probe
  139552. */
  139553. removeReflectionProbe(toRemove: ReflectionProbe): number;
  139554. /**
  139555. * Adds the given reflection probe to this scene.
  139556. * @param newReflectionProbe The reflection probe to add
  139557. */
  139558. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  139559. }
  139560. /**
  139561. * Class used to generate realtime reflection / refraction cube textures
  139562. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139563. */
  139564. export class ReflectionProbe {
  139565. /** defines the name of the probe */
  139566. name: string;
  139567. private _scene;
  139568. private _renderTargetTexture;
  139569. private _projectionMatrix;
  139570. private _viewMatrix;
  139571. private _target;
  139572. private _add;
  139573. private _attachedMesh;
  139574. private _invertYAxis;
  139575. /** Gets or sets probe position (center of the cube map) */
  139576. position: Vector3;
  139577. /**
  139578. * Creates a new reflection probe
  139579. * @param name defines the name of the probe
  139580. * @param size defines the texture resolution (for each face)
  139581. * @param scene defines the hosting scene
  139582. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  139583. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  139584. */
  139585. constructor(
  139586. /** defines the name of the probe */
  139587. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  139588. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  139589. get samples(): number;
  139590. set samples(value: number);
  139591. /** Gets or sets the refresh rate to use (on every frame by default) */
  139592. get refreshRate(): number;
  139593. set refreshRate(value: number);
  139594. /**
  139595. * Gets the hosting scene
  139596. * @returns a Scene
  139597. */
  139598. getScene(): Scene;
  139599. /** Gets the internal CubeTexture used to render to */
  139600. get cubeTexture(): RenderTargetTexture;
  139601. /** Gets the list of meshes to render */
  139602. get renderList(): Nullable<AbstractMesh[]>;
  139603. /**
  139604. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  139605. * @param mesh defines the mesh to attach to
  139606. */
  139607. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  139608. /**
  139609. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  139610. * @param renderingGroupId The rendering group id corresponding to its index
  139611. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  139612. */
  139613. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  139614. /**
  139615. * Clean all associated resources
  139616. */
  139617. dispose(): void;
  139618. /**
  139619. * Converts the reflection probe information to a readable string for debug purpose.
  139620. * @param fullDetails Supports for multiple levels of logging within scene loading
  139621. * @returns the human readable reflection probe info
  139622. */
  139623. toString(fullDetails?: boolean): string;
  139624. /**
  139625. * Get the class name of the relfection probe.
  139626. * @returns "ReflectionProbe"
  139627. */
  139628. getClassName(): string;
  139629. /**
  139630. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  139631. * @returns The JSON representation of the texture
  139632. */
  139633. serialize(): any;
  139634. /**
  139635. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  139636. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  139637. * @param scene Define the scene the parsed reflection probe should be instantiated in
  139638. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  139639. * @returns The parsed reflection probe if successful
  139640. */
  139641. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  139642. }
  139643. }
  139644. declare module BABYLON {
  139645. /** @hidden */
  139646. export var _BabylonLoaderRegistered: boolean;
  139647. /**
  139648. * Helps setting up some configuration for the babylon file loader.
  139649. */
  139650. export class BabylonFileLoaderConfiguration {
  139651. /**
  139652. * The loader does not allow injecting custom physix engine into the plugins.
  139653. * Unfortunately in ES6, we need to manually inject them into the plugin.
  139654. * So you could set this variable to your engine import to make it work.
  139655. */
  139656. static LoaderInjectedPhysicsEngine: any;
  139657. }
  139658. }
  139659. declare module BABYLON {
  139660. /**
  139661. * The Physically based simple base material of BJS.
  139662. *
  139663. * This enables better naming and convention enforcements on top of the pbrMaterial.
  139664. * It is used as the base class for both the specGloss and metalRough conventions.
  139665. */
  139666. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  139667. /**
  139668. * Number of Simultaneous lights allowed on the material.
  139669. */
  139670. maxSimultaneousLights: number;
  139671. /**
  139672. * If sets to true, disables all the lights affecting the material.
  139673. */
  139674. disableLighting: boolean;
  139675. /**
  139676. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  139677. */
  139678. environmentTexture: BaseTexture;
  139679. /**
  139680. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  139681. */
  139682. invertNormalMapX: boolean;
  139683. /**
  139684. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  139685. */
  139686. invertNormalMapY: boolean;
  139687. /**
  139688. * Normal map used in the model.
  139689. */
  139690. normalTexture: BaseTexture;
  139691. /**
  139692. * Emissivie color used to self-illuminate the model.
  139693. */
  139694. emissiveColor: Color3;
  139695. /**
  139696. * Emissivie texture used to self-illuminate the model.
  139697. */
  139698. emissiveTexture: BaseTexture;
  139699. /**
  139700. * Occlusion Channel Strenght.
  139701. */
  139702. occlusionStrength: number;
  139703. /**
  139704. * Occlusion Texture of the material (adding extra occlusion effects).
  139705. */
  139706. occlusionTexture: BaseTexture;
  139707. /**
  139708. * Defines the alpha limits in alpha test mode.
  139709. */
  139710. alphaCutOff: number;
  139711. /**
  139712. * Gets the current double sided mode.
  139713. */
  139714. get doubleSided(): boolean;
  139715. /**
  139716. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  139717. */
  139718. set doubleSided(value: boolean);
  139719. /**
  139720. * Stores the pre-calculated light information of a mesh in a texture.
  139721. */
  139722. lightmapTexture: BaseTexture;
  139723. /**
  139724. * If true, the light map contains occlusion information instead of lighting info.
  139725. */
  139726. useLightmapAsShadowmap: boolean;
  139727. /**
  139728. * Instantiates a new PBRMaterial instance.
  139729. *
  139730. * @param name The material name
  139731. * @param scene The scene the material will be use in.
  139732. */
  139733. constructor(name: string, scene: Scene);
  139734. getClassName(): string;
  139735. }
  139736. }
  139737. declare module BABYLON {
  139738. /**
  139739. * The PBR material of BJS following the metal roughness convention.
  139740. *
  139741. * This fits to the PBR convention in the GLTF definition:
  139742. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  139743. */
  139744. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  139745. /**
  139746. * The base color has two different interpretations depending on the value of metalness.
  139747. * When the material is a metal, the base color is the specific measured reflectance value
  139748. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  139749. * of the material.
  139750. */
  139751. baseColor: Color3;
  139752. /**
  139753. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  139754. * well as opacity information in the alpha channel.
  139755. */
  139756. baseTexture: BaseTexture;
  139757. /**
  139758. * Specifies the metallic scalar value of the material.
  139759. * Can also be used to scale the metalness values of the metallic texture.
  139760. */
  139761. metallic: number;
  139762. /**
  139763. * Specifies the roughness scalar value of the material.
  139764. * Can also be used to scale the roughness values of the metallic texture.
  139765. */
  139766. roughness: number;
  139767. /**
  139768. * Texture containing both the metallic value in the B channel and the
  139769. * roughness value in the G channel to keep better precision.
  139770. */
  139771. metallicRoughnessTexture: BaseTexture;
  139772. /**
  139773. * Instantiates a new PBRMetalRoughnessMaterial instance.
  139774. *
  139775. * @param name The material name
  139776. * @param scene The scene the material will be use in.
  139777. */
  139778. constructor(name: string, scene: Scene);
  139779. /**
  139780. * Return the currrent class name of the material.
  139781. */
  139782. getClassName(): string;
  139783. /**
  139784. * Makes a duplicate of the current material.
  139785. * @param name - name to use for the new material.
  139786. */
  139787. clone(name: string): PBRMetallicRoughnessMaterial;
  139788. /**
  139789. * Serialize the material to a parsable JSON object.
  139790. */
  139791. serialize(): any;
  139792. /**
  139793. * Parses a JSON object correponding to the serialize function.
  139794. */
  139795. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  139796. }
  139797. }
  139798. declare module BABYLON {
  139799. /**
  139800. * The PBR material of BJS following the specular glossiness convention.
  139801. *
  139802. * This fits to the PBR convention in the GLTF definition:
  139803. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  139804. */
  139805. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  139806. /**
  139807. * Specifies the diffuse color of the material.
  139808. */
  139809. diffuseColor: Color3;
  139810. /**
  139811. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  139812. * channel.
  139813. */
  139814. diffuseTexture: BaseTexture;
  139815. /**
  139816. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  139817. */
  139818. specularColor: Color3;
  139819. /**
  139820. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  139821. */
  139822. glossiness: number;
  139823. /**
  139824. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  139825. */
  139826. specularGlossinessTexture: BaseTexture;
  139827. /**
  139828. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  139829. *
  139830. * @param name The material name
  139831. * @param scene The scene the material will be use in.
  139832. */
  139833. constructor(name: string, scene: Scene);
  139834. /**
  139835. * Return the currrent class name of the material.
  139836. */
  139837. getClassName(): string;
  139838. /**
  139839. * Makes a duplicate of the current material.
  139840. * @param name - name to use for the new material.
  139841. */
  139842. clone(name: string): PBRSpecularGlossinessMaterial;
  139843. /**
  139844. * Serialize the material to a parsable JSON object.
  139845. */
  139846. serialize(): any;
  139847. /**
  139848. * Parses a JSON object correponding to the serialize function.
  139849. */
  139850. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  139851. }
  139852. }
  139853. declare module BABYLON {
  139854. /**
  139855. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  139856. * It can help converting any input color in a desired output one. This can then be used to create effects
  139857. * from sepia, black and white to sixties or futuristic rendering...
  139858. *
  139859. * The only supported format is currently 3dl.
  139860. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  139861. */
  139862. export class ColorGradingTexture extends BaseTexture {
  139863. /**
  139864. * The texture URL.
  139865. */
  139866. url: string;
  139867. /**
  139868. * Empty line regex stored for GC.
  139869. */
  139870. private static _noneEmptyLineRegex;
  139871. private _textureMatrix;
  139872. private _onLoad;
  139873. /**
  139874. * Instantiates a ColorGradingTexture from the following parameters.
  139875. *
  139876. * @param url The location of the color gradind data (currently only supporting 3dl)
  139877. * @param sceneOrEngine The scene or engine the texture will be used in
  139878. * @param onLoad defines a callback triggered when the texture has been loaded
  139879. */
  139880. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  139881. /**
  139882. * Fires the onload event from the constructor if requested.
  139883. */
  139884. private _triggerOnLoad;
  139885. /**
  139886. * Returns the texture matrix used in most of the material.
  139887. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  139888. */
  139889. getTextureMatrix(): Matrix;
  139890. /**
  139891. * Occurs when the file being loaded is a .3dl LUT file.
  139892. */
  139893. private load3dlTexture;
  139894. /**
  139895. * Starts the loading process of the texture.
  139896. */
  139897. private loadTexture;
  139898. /**
  139899. * Clones the color gradind texture.
  139900. */
  139901. clone(): ColorGradingTexture;
  139902. /**
  139903. * Called during delayed load for textures.
  139904. */
  139905. delayLoad(): void;
  139906. /**
  139907. * Parses a color grading texture serialized by Babylon.
  139908. * @param parsedTexture The texture information being parsedTexture
  139909. * @param scene The scene to load the texture in
  139910. * @param rootUrl The root url of the data assets to load
  139911. * @return A color gradind texture
  139912. */
  139913. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  139914. /**
  139915. * Serializes the LUT texture to json format.
  139916. */
  139917. serialize(): any;
  139918. }
  139919. }
  139920. declare module BABYLON {
  139921. /**
  139922. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  139923. */
  139924. export class EquiRectangularCubeTexture extends BaseTexture {
  139925. /** The six faces of the cube. */
  139926. private static _FacesMapping;
  139927. private _noMipmap;
  139928. private _onLoad;
  139929. private _onError;
  139930. /** The size of the cubemap. */
  139931. private _size;
  139932. /** The buffer of the image. */
  139933. private _buffer;
  139934. /** The width of the input image. */
  139935. private _width;
  139936. /** The height of the input image. */
  139937. private _height;
  139938. /** The URL to the image. */
  139939. url: string;
  139940. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  139941. coordinatesMode: number;
  139942. /**
  139943. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  139944. * @param url The location of the image
  139945. * @param scene The scene the texture will be used in
  139946. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139947. * @param noMipmap Forces to not generate the mipmap if true
  139948. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  139949. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  139950. * @param onLoad — defines a callback called when texture is loaded
  139951. * @param onError — defines a callback called if there is an error
  139952. */
  139953. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  139954. /**
  139955. * Load the image data, by putting the image on a canvas and extracting its buffer.
  139956. */
  139957. private loadImage;
  139958. /**
  139959. * Convert the image buffer into a cubemap and create a CubeTexture.
  139960. */
  139961. private loadTexture;
  139962. /**
  139963. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  139964. * @param buffer The ArrayBuffer that should be converted.
  139965. * @returns The buffer as Float32Array.
  139966. */
  139967. private getFloat32ArrayFromArrayBuffer;
  139968. /**
  139969. * Get the current class name of the texture useful for serialization or dynamic coding.
  139970. * @returns "EquiRectangularCubeTexture"
  139971. */
  139972. getClassName(): string;
  139973. /**
  139974. * Create a clone of the current EquiRectangularCubeTexture and return it.
  139975. * @returns A clone of the current EquiRectangularCubeTexture.
  139976. */
  139977. clone(): EquiRectangularCubeTexture;
  139978. }
  139979. }
  139980. declare module BABYLON {
  139981. /**
  139982. * Defines the options related to the creation of an HtmlElementTexture
  139983. */
  139984. export interface IHtmlElementTextureOptions {
  139985. /**
  139986. * Defines wether mip maps should be created or not.
  139987. */
  139988. generateMipMaps?: boolean;
  139989. /**
  139990. * Defines the sampling mode of the texture.
  139991. */
  139992. samplingMode?: number;
  139993. /**
  139994. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  139995. */
  139996. engine: Nullable<ThinEngine>;
  139997. /**
  139998. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  139999. */
  140000. scene: Nullable<Scene>;
  140001. }
  140002. /**
  140003. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  140004. * To be as efficient as possible depending on your constraints nothing aside the first upload
  140005. * is automatically managed.
  140006. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  140007. * in your application.
  140008. *
  140009. * As the update is not automatic, you need to call them manually.
  140010. */
  140011. export class HtmlElementTexture extends BaseTexture {
  140012. /**
  140013. * The texture URL.
  140014. */
  140015. element: HTMLVideoElement | HTMLCanvasElement;
  140016. private static readonly DefaultOptions;
  140017. private _textureMatrix;
  140018. private _isVideo;
  140019. private _generateMipMaps;
  140020. private _samplingMode;
  140021. /**
  140022. * Instantiates a HtmlElementTexture from the following parameters.
  140023. *
  140024. * @param name Defines the name of the texture
  140025. * @param element Defines the video or canvas the texture is filled with
  140026. * @param options Defines the other none mandatory texture creation options
  140027. */
  140028. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  140029. private _createInternalTexture;
  140030. /**
  140031. * Returns the texture matrix used in most of the material.
  140032. */
  140033. getTextureMatrix(): Matrix;
  140034. /**
  140035. * Updates the content of the texture.
  140036. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  140037. */
  140038. update(invertY?: Nullable<boolean>): void;
  140039. }
  140040. }
  140041. declare module BABYLON {
  140042. /**
  140043. * Based on jsTGALoader - Javascript loader for TGA file
  140044. * By Vincent Thibault
  140045. * @see http://blog.robrowser.com/javascript-tga-loader.html
  140046. */
  140047. export class TGATools {
  140048. private static _TYPE_INDEXED;
  140049. private static _TYPE_RGB;
  140050. private static _TYPE_GREY;
  140051. private static _TYPE_RLE_INDEXED;
  140052. private static _TYPE_RLE_RGB;
  140053. private static _TYPE_RLE_GREY;
  140054. private static _ORIGIN_MASK;
  140055. private static _ORIGIN_SHIFT;
  140056. private static _ORIGIN_BL;
  140057. private static _ORIGIN_BR;
  140058. private static _ORIGIN_UL;
  140059. private static _ORIGIN_UR;
  140060. /**
  140061. * Gets the header of a TGA file
  140062. * @param data defines the TGA data
  140063. * @returns the header
  140064. */
  140065. static GetTGAHeader(data: Uint8Array): any;
  140066. /**
  140067. * Uploads TGA content to a Babylon Texture
  140068. * @hidden
  140069. */
  140070. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  140071. /** @hidden */
  140072. 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;
  140073. /** @hidden */
  140074. 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;
  140075. /** @hidden */
  140076. 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;
  140077. /** @hidden */
  140078. 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;
  140079. /** @hidden */
  140080. 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;
  140081. /** @hidden */
  140082. 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;
  140083. }
  140084. }
  140085. declare module BABYLON {
  140086. /**
  140087. * Implementation of the TGA Texture Loader.
  140088. * @hidden
  140089. */
  140090. export class _TGATextureLoader implements IInternalTextureLoader {
  140091. /**
  140092. * Defines wether the loader supports cascade loading the different faces.
  140093. */
  140094. readonly supportCascades: boolean;
  140095. /**
  140096. * This returns if the loader support the current file information.
  140097. * @param extension defines the file extension of the file being loaded
  140098. * @returns true if the loader can load the specified file
  140099. */
  140100. canLoad(extension: string): boolean;
  140101. /**
  140102. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140103. * @param data contains the texture data
  140104. * @param texture defines the BabylonJS internal texture
  140105. * @param createPolynomials will be true if polynomials have been requested
  140106. * @param onLoad defines the callback to trigger once the texture is ready
  140107. * @param onError defines the callback to trigger in case of error
  140108. */
  140109. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140110. /**
  140111. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140112. * @param data contains the texture data
  140113. * @param texture defines the BabylonJS internal texture
  140114. * @param callback defines the method to call once ready to upload
  140115. */
  140116. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140117. }
  140118. }
  140119. declare module BABYLON {
  140120. /**
  140121. * Info about the .basis files
  140122. */
  140123. class BasisFileInfo {
  140124. /**
  140125. * If the file has alpha
  140126. */
  140127. hasAlpha: boolean;
  140128. /**
  140129. * Info about each image of the basis file
  140130. */
  140131. images: Array<{
  140132. levels: Array<{
  140133. width: number;
  140134. height: number;
  140135. transcodedPixels: ArrayBufferView;
  140136. }>;
  140137. }>;
  140138. }
  140139. /**
  140140. * Result of transcoding a basis file
  140141. */
  140142. class TranscodeResult {
  140143. /**
  140144. * Info about the .basis file
  140145. */
  140146. fileInfo: BasisFileInfo;
  140147. /**
  140148. * Format to use when loading the file
  140149. */
  140150. format: number;
  140151. }
  140152. /**
  140153. * Configuration options for the Basis transcoder
  140154. */
  140155. export class BasisTranscodeConfiguration {
  140156. /**
  140157. * Supported compression formats used to determine the supported output format of the transcoder
  140158. */
  140159. supportedCompressionFormats?: {
  140160. /**
  140161. * etc1 compression format
  140162. */
  140163. etc1?: boolean;
  140164. /**
  140165. * s3tc compression format
  140166. */
  140167. s3tc?: boolean;
  140168. /**
  140169. * pvrtc compression format
  140170. */
  140171. pvrtc?: boolean;
  140172. /**
  140173. * etc2 compression format
  140174. */
  140175. etc2?: boolean;
  140176. };
  140177. /**
  140178. * If mipmap levels should be loaded for transcoded images (Default: true)
  140179. */
  140180. loadMipmapLevels?: boolean;
  140181. /**
  140182. * Index of a single image to load (Default: all images)
  140183. */
  140184. loadSingleImage?: number;
  140185. }
  140186. /**
  140187. * Used to load .Basis files
  140188. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  140189. */
  140190. export class BasisTools {
  140191. private static _IgnoreSupportedFormats;
  140192. /**
  140193. * URL to use when loading the basis transcoder
  140194. */
  140195. static JSModuleURL: string;
  140196. /**
  140197. * URL to use when loading the wasm module for the transcoder
  140198. */
  140199. static WasmModuleURL: string;
  140200. /**
  140201. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  140202. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  140203. * @returns internal format corresponding to the Basis format
  140204. */
  140205. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  140206. private static _WorkerPromise;
  140207. private static _Worker;
  140208. private static _actionId;
  140209. private static _CreateWorkerAsync;
  140210. /**
  140211. * Transcodes a loaded image file to compressed pixel data
  140212. * @param data image data to transcode
  140213. * @param config configuration options for the transcoding
  140214. * @returns a promise resulting in the transcoded image
  140215. */
  140216. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  140217. /**
  140218. * Loads a texture from the transcode result
  140219. * @param texture texture load to
  140220. * @param transcodeResult the result of transcoding the basis file to load from
  140221. */
  140222. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  140223. }
  140224. }
  140225. declare module BABYLON {
  140226. /**
  140227. * Loader for .basis file format
  140228. */
  140229. export class _BasisTextureLoader implements IInternalTextureLoader {
  140230. /**
  140231. * Defines whether the loader supports cascade loading the different faces.
  140232. */
  140233. readonly supportCascades: boolean;
  140234. /**
  140235. * This returns if the loader support the current file information.
  140236. * @param extension defines the file extension of the file being loaded
  140237. * @returns true if the loader can load the specified file
  140238. */
  140239. canLoad(extension: string): boolean;
  140240. /**
  140241. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140242. * @param data contains the texture data
  140243. * @param texture defines the BabylonJS internal texture
  140244. * @param createPolynomials will be true if polynomials have been requested
  140245. * @param onLoad defines the callback to trigger once the texture is ready
  140246. * @param onError defines the callback to trigger in case of error
  140247. */
  140248. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140249. /**
  140250. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140251. * @param data contains the texture data
  140252. * @param texture defines the BabylonJS internal texture
  140253. * @param callback defines the method to call once ready to upload
  140254. */
  140255. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140256. }
  140257. }
  140258. declare module BABYLON {
  140259. /**
  140260. * Defines the basic options interface of a TexturePacker Frame
  140261. */
  140262. export interface ITexturePackerFrame {
  140263. /**
  140264. * The frame ID
  140265. */
  140266. id: number;
  140267. /**
  140268. * The frames Scale
  140269. */
  140270. scale: Vector2;
  140271. /**
  140272. * The Frames offset
  140273. */
  140274. offset: Vector2;
  140275. }
  140276. /**
  140277. * This is a support class for frame Data on texture packer sets.
  140278. */
  140279. export class TexturePackerFrame implements ITexturePackerFrame {
  140280. /**
  140281. * The frame ID
  140282. */
  140283. id: number;
  140284. /**
  140285. * The frames Scale
  140286. */
  140287. scale: Vector2;
  140288. /**
  140289. * The Frames offset
  140290. */
  140291. offset: Vector2;
  140292. /**
  140293. * Initializes a texture package frame.
  140294. * @param id The numerical frame identifier
  140295. * @param scale Scalar Vector2 for UV frame
  140296. * @param offset Vector2 for the frame position in UV units.
  140297. * @returns TexturePackerFrame
  140298. */
  140299. constructor(id: number, scale: Vector2, offset: Vector2);
  140300. }
  140301. }
  140302. declare module BABYLON {
  140303. /**
  140304. * Defines the basic options interface of a TexturePacker
  140305. */
  140306. export interface ITexturePackerOptions {
  140307. /**
  140308. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  140309. */
  140310. map?: string[];
  140311. /**
  140312. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140313. */
  140314. uvsIn?: string;
  140315. /**
  140316. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140317. */
  140318. uvsOut?: string;
  140319. /**
  140320. * number representing the layout style. Defaults to LAYOUT_STRIP
  140321. */
  140322. layout?: number;
  140323. /**
  140324. * number of columns if using custom column count layout(2). This defaults to 4.
  140325. */
  140326. colnum?: number;
  140327. /**
  140328. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  140329. */
  140330. updateInputMeshes?: boolean;
  140331. /**
  140332. * boolean flag to dispose all the source textures. Defaults to true.
  140333. */
  140334. disposeSources?: boolean;
  140335. /**
  140336. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  140337. */
  140338. fillBlanks?: boolean;
  140339. /**
  140340. * string value representing the context fill style color. Defaults to 'black'.
  140341. */
  140342. customFillColor?: string;
  140343. /**
  140344. * Width and Height Value of each Frame in the TexturePacker Sets
  140345. */
  140346. frameSize?: number;
  140347. /**
  140348. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  140349. */
  140350. paddingRatio?: number;
  140351. /**
  140352. * Number that declares the fill method for the padding gutter.
  140353. */
  140354. paddingMode?: number;
  140355. /**
  140356. * If in SUBUV_COLOR padding mode what color to use.
  140357. */
  140358. paddingColor?: Color3 | Color4;
  140359. }
  140360. /**
  140361. * Defines the basic interface of a TexturePacker JSON File
  140362. */
  140363. export interface ITexturePackerJSON {
  140364. /**
  140365. * The frame ID
  140366. */
  140367. name: string;
  140368. /**
  140369. * The base64 channel data
  140370. */
  140371. sets: any;
  140372. /**
  140373. * The options of the Packer
  140374. */
  140375. options: ITexturePackerOptions;
  140376. /**
  140377. * The frame data of the Packer
  140378. */
  140379. frames: Array<number>;
  140380. }
  140381. /**
  140382. * This is a support class that generates a series of packed texture sets.
  140383. * @see https://doc.babylonjs.com/babylon101/materials
  140384. */
  140385. export class TexturePacker {
  140386. /** Packer Layout Constant 0 */
  140387. static readonly LAYOUT_STRIP: number;
  140388. /** Packer Layout Constant 1 */
  140389. static readonly LAYOUT_POWER2: number;
  140390. /** Packer Layout Constant 2 */
  140391. static readonly LAYOUT_COLNUM: number;
  140392. /** Packer Layout Constant 0 */
  140393. static readonly SUBUV_WRAP: number;
  140394. /** Packer Layout Constant 1 */
  140395. static readonly SUBUV_EXTEND: number;
  140396. /** Packer Layout Constant 2 */
  140397. static readonly SUBUV_COLOR: number;
  140398. /** The Name of the Texture Package */
  140399. name: string;
  140400. /** The scene scope of the TexturePacker */
  140401. scene: Scene;
  140402. /** The Meshes to target */
  140403. meshes: AbstractMesh[];
  140404. /** Arguments passed with the Constructor */
  140405. options: ITexturePackerOptions;
  140406. /** The promise that is started upon initialization */
  140407. promise: Nullable<Promise<TexturePacker | string>>;
  140408. /** The Container object for the channel sets that are generated */
  140409. sets: object;
  140410. /** The Container array for the frames that are generated */
  140411. frames: TexturePackerFrame[];
  140412. /** The expected number of textures the system is parsing. */
  140413. private _expecting;
  140414. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  140415. private _paddingValue;
  140416. /**
  140417. * Initializes a texture package series from an array of meshes or a single mesh.
  140418. * @param name The name of the package
  140419. * @param meshes The target meshes to compose the package from
  140420. * @param options The arguments that texture packer should follow while building.
  140421. * @param scene The scene which the textures are scoped to.
  140422. * @returns TexturePacker
  140423. */
  140424. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  140425. /**
  140426. * Starts the package process
  140427. * @param resolve The promises resolution function
  140428. * @returns TexturePacker
  140429. */
  140430. private _createFrames;
  140431. /**
  140432. * Calculates the Size of the Channel Sets
  140433. * @returns Vector2
  140434. */
  140435. private _calculateSize;
  140436. /**
  140437. * Calculates the UV data for the frames.
  140438. * @param baseSize the base frameSize
  140439. * @param padding the base frame padding
  140440. * @param dtSize size of the Dynamic Texture for that channel
  140441. * @param dtUnits is 1/dtSize
  140442. * @param update flag to update the input meshes
  140443. */
  140444. private _calculateMeshUVFrames;
  140445. /**
  140446. * Calculates the frames Offset.
  140447. * @param index of the frame
  140448. * @returns Vector2
  140449. */
  140450. private _getFrameOffset;
  140451. /**
  140452. * Updates a Mesh to the frame data
  140453. * @param mesh that is the target
  140454. * @param frameID or the frame index
  140455. */
  140456. private _updateMeshUV;
  140457. /**
  140458. * Updates a Meshes materials to use the texture packer channels
  140459. * @param m is the mesh to target
  140460. * @param force all channels on the packer to be set.
  140461. */
  140462. private _updateTextureReferences;
  140463. /**
  140464. * Public method to set a Mesh to a frame
  140465. * @param m that is the target
  140466. * @param frameID or the frame index
  140467. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  140468. */
  140469. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  140470. /**
  140471. * Starts the async promise to compile the texture packer.
  140472. * @returns Promise<void>
  140473. */
  140474. processAsync(): Promise<void>;
  140475. /**
  140476. * Disposes all textures associated with this packer
  140477. */
  140478. dispose(): void;
  140479. /**
  140480. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  140481. * @param imageType is the image type to use.
  140482. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  140483. */
  140484. download(imageType?: string, quality?: number): void;
  140485. /**
  140486. * Public method to load a texturePacker JSON file.
  140487. * @param data of the JSON file in string format.
  140488. */
  140489. updateFromJSON(data: string): void;
  140490. }
  140491. }
  140492. declare module BABYLON {
  140493. /**
  140494. * 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.
  140495. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140496. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140497. */
  140498. export class CustomProceduralTexture extends ProceduralTexture {
  140499. private _animate;
  140500. private _time;
  140501. private _config;
  140502. private _texturePath;
  140503. /**
  140504. * Instantiates a new Custom Procedural Texture.
  140505. * 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.
  140506. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140507. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140508. * @param name Define the name of the texture
  140509. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  140510. * @param size Define the size of the texture to create
  140511. * @param scene Define the scene the texture belongs to
  140512. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  140513. * @param generateMipMaps Define if the texture should creates mip maps or not
  140514. */
  140515. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140516. private _loadJson;
  140517. /**
  140518. * Is the texture ready to be used ? (rendered at least once)
  140519. * @returns true if ready, otherwise, false.
  140520. */
  140521. isReady(): boolean;
  140522. /**
  140523. * Render the texture to its associated render target.
  140524. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  140525. */
  140526. render(useCameraPostProcess?: boolean): void;
  140527. /**
  140528. * Update the list of dependant textures samplers in the shader.
  140529. */
  140530. updateTextures(): void;
  140531. /**
  140532. * Update the uniform values of the procedural texture in the shader.
  140533. */
  140534. updateShaderUniforms(): void;
  140535. /**
  140536. * Define if the texture animates or not.
  140537. */
  140538. get animate(): boolean;
  140539. set animate(value: boolean);
  140540. }
  140541. }
  140542. declare module BABYLON {
  140543. /** @hidden */
  140544. export var noisePixelShader: {
  140545. name: string;
  140546. shader: string;
  140547. };
  140548. }
  140549. declare module BABYLON {
  140550. /**
  140551. * Class used to generate noise procedural textures
  140552. */
  140553. export class NoiseProceduralTexture extends ProceduralTexture {
  140554. private _time;
  140555. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  140556. brightness: number;
  140557. /** Defines the number of octaves to process */
  140558. octaves: number;
  140559. /** Defines the level of persistence (0.8 by default) */
  140560. persistence: number;
  140561. /** Gets or sets animation speed factor (default is 1) */
  140562. animationSpeedFactor: number;
  140563. /**
  140564. * Creates a new NoiseProceduralTexture
  140565. * @param name defines the name fo the texture
  140566. * @param size defines the size of the texture (default is 256)
  140567. * @param scene defines the hosting scene
  140568. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  140569. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  140570. */
  140571. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140572. private _updateShaderUniforms;
  140573. protected _getDefines(): string;
  140574. /** Generate the current state of the procedural texture */
  140575. render(useCameraPostProcess?: boolean): void;
  140576. /**
  140577. * Serializes this noise procedural texture
  140578. * @returns a serialized noise procedural texture object
  140579. */
  140580. serialize(): any;
  140581. /**
  140582. * Clone the texture.
  140583. * @returns the cloned texture
  140584. */
  140585. clone(): NoiseProceduralTexture;
  140586. /**
  140587. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  140588. * @param parsedTexture defines parsed texture data
  140589. * @param scene defines the current scene
  140590. * @param rootUrl defines the root URL containing noise procedural texture information
  140591. * @returns a parsed NoiseProceduralTexture
  140592. */
  140593. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  140594. }
  140595. }
  140596. declare module BABYLON {
  140597. /**
  140598. * Raw cube texture where the raw buffers are passed in
  140599. */
  140600. export class RawCubeTexture extends CubeTexture {
  140601. /**
  140602. * Creates a cube texture where the raw buffers are passed in.
  140603. * @param scene defines the scene the texture is attached to
  140604. * @param data defines the array of data to use to create each face
  140605. * @param size defines the size of the textures
  140606. * @param format defines the format of the data
  140607. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  140608. * @param generateMipMaps defines if the engine should generate the mip levels
  140609. * @param invertY defines if data must be stored with Y axis inverted
  140610. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  140611. * @param compression defines the compression used (null by default)
  140612. */
  140613. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  140614. /**
  140615. * Updates the raw cube texture.
  140616. * @param data defines the data to store
  140617. * @param format defines the data format
  140618. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140619. * @param invertY defines if data must be stored with Y axis inverted
  140620. * @param compression defines the compression used (null by default)
  140621. * @param level defines which level of the texture to update
  140622. */
  140623. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  140624. /**
  140625. * Updates a raw cube texture with RGBD encoded data.
  140626. * @param data defines the array of data [mipmap][face] to use to create each face
  140627. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  140628. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  140629. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  140630. * @returns a promsie that resolves when the operation is complete
  140631. */
  140632. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  140633. /**
  140634. * Clones the raw cube texture.
  140635. * @return a new cube texture
  140636. */
  140637. clone(): CubeTexture;
  140638. /** @hidden */
  140639. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  140640. }
  140641. }
  140642. declare module BABYLON {
  140643. /**
  140644. * Class used to store 2D array textures containing user data
  140645. */
  140646. export class RawTexture2DArray extends Texture {
  140647. /** Gets or sets the texture format to use */
  140648. format: number;
  140649. /**
  140650. * Create a new RawTexture2DArray
  140651. * @param data defines the data of the texture
  140652. * @param width defines the width of the texture
  140653. * @param height defines the height of the texture
  140654. * @param depth defines the number of layers of the texture
  140655. * @param format defines the texture format to use
  140656. * @param scene defines the hosting scene
  140657. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140658. * @param invertY defines if texture must be stored with Y axis inverted
  140659. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140660. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140661. */
  140662. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140663. /** Gets or sets the texture format to use */
  140664. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140665. /**
  140666. * Update the texture with new data
  140667. * @param data defines the data to store in the texture
  140668. */
  140669. update(data: ArrayBufferView): void;
  140670. }
  140671. }
  140672. declare module BABYLON {
  140673. /**
  140674. * Class used to store 3D textures containing user data
  140675. */
  140676. export class RawTexture3D extends Texture {
  140677. /** Gets or sets the texture format to use */
  140678. format: number;
  140679. /**
  140680. * Create a new RawTexture3D
  140681. * @param data defines the data of the texture
  140682. * @param width defines the width of the texture
  140683. * @param height defines the height of the texture
  140684. * @param depth defines the depth of the texture
  140685. * @param format defines the texture format to use
  140686. * @param scene defines the hosting scene
  140687. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140688. * @param invertY defines if texture must be stored with Y axis inverted
  140689. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140690. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140691. */
  140692. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140693. /** Gets or sets the texture format to use */
  140694. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140695. /**
  140696. * Update the texture with new data
  140697. * @param data defines the data to store in the texture
  140698. */
  140699. update(data: ArrayBufferView): void;
  140700. }
  140701. }
  140702. declare module BABYLON {
  140703. /**
  140704. * Creates a refraction texture used by refraction channel of the standard material.
  140705. * It is like a mirror but to see through a material.
  140706. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140707. */
  140708. export class RefractionTexture extends RenderTargetTexture {
  140709. /**
  140710. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  140711. * 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.
  140712. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140713. */
  140714. refractionPlane: Plane;
  140715. /**
  140716. * Define how deep under the surface we should see.
  140717. */
  140718. depth: number;
  140719. /**
  140720. * Creates a refraction texture used by refraction channel of the standard material.
  140721. * It is like a mirror but to see through a material.
  140722. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140723. * @param name Define the texture name
  140724. * @param size Define the size of the underlying texture
  140725. * @param scene Define the scene the refraction belongs to
  140726. * @param generateMipMaps Define if we need to generate mips level for the refraction
  140727. */
  140728. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  140729. /**
  140730. * Clone the refraction texture.
  140731. * @returns the cloned texture
  140732. */
  140733. clone(): RefractionTexture;
  140734. /**
  140735. * Serialize the texture to a JSON representation you could use in Parse later on
  140736. * @returns the serialized JSON representation
  140737. */
  140738. serialize(): any;
  140739. }
  140740. }
  140741. declare module BABYLON {
  140742. /**
  140743. * Block used to add support for vertex skinning (bones)
  140744. */
  140745. export class BonesBlock extends NodeMaterialBlock {
  140746. /**
  140747. * Creates a new BonesBlock
  140748. * @param name defines the block name
  140749. */
  140750. constructor(name: string);
  140751. /**
  140752. * Initialize the block and prepare the context for build
  140753. * @param state defines the state that will be used for the build
  140754. */
  140755. initialize(state: NodeMaterialBuildState): void;
  140756. /**
  140757. * Gets the current class name
  140758. * @returns the class name
  140759. */
  140760. getClassName(): string;
  140761. /**
  140762. * Gets the matrix indices input component
  140763. */
  140764. get matricesIndices(): NodeMaterialConnectionPoint;
  140765. /**
  140766. * Gets the matrix weights input component
  140767. */
  140768. get matricesWeights(): NodeMaterialConnectionPoint;
  140769. /**
  140770. * Gets the extra matrix indices input component
  140771. */
  140772. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  140773. /**
  140774. * Gets the extra matrix weights input component
  140775. */
  140776. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  140777. /**
  140778. * Gets the world input component
  140779. */
  140780. get world(): NodeMaterialConnectionPoint;
  140781. /**
  140782. * Gets the output component
  140783. */
  140784. get output(): NodeMaterialConnectionPoint;
  140785. autoConfigure(material: NodeMaterial): void;
  140786. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  140787. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140789. protected _buildBlock(state: NodeMaterialBuildState): this;
  140790. }
  140791. }
  140792. declare module BABYLON {
  140793. /**
  140794. * Block used to add support for instances
  140795. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  140796. */
  140797. export class InstancesBlock extends NodeMaterialBlock {
  140798. /**
  140799. * Creates a new InstancesBlock
  140800. * @param name defines the block name
  140801. */
  140802. constructor(name: string);
  140803. /**
  140804. * Gets the current class name
  140805. * @returns the class name
  140806. */
  140807. getClassName(): string;
  140808. /**
  140809. * Gets the first world row input component
  140810. */
  140811. get world0(): NodeMaterialConnectionPoint;
  140812. /**
  140813. * Gets the second world row input component
  140814. */
  140815. get world1(): NodeMaterialConnectionPoint;
  140816. /**
  140817. * Gets the third world row input component
  140818. */
  140819. get world2(): NodeMaterialConnectionPoint;
  140820. /**
  140821. * Gets the forth world row input component
  140822. */
  140823. get world3(): NodeMaterialConnectionPoint;
  140824. /**
  140825. * Gets the world input component
  140826. */
  140827. get world(): NodeMaterialConnectionPoint;
  140828. /**
  140829. * Gets the output component
  140830. */
  140831. get output(): NodeMaterialConnectionPoint;
  140832. /**
  140833. * Gets the isntanceID component
  140834. */
  140835. get instanceID(): NodeMaterialConnectionPoint;
  140836. autoConfigure(material: NodeMaterial): void;
  140837. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  140838. protected _buildBlock(state: NodeMaterialBuildState): this;
  140839. }
  140840. }
  140841. declare module BABYLON {
  140842. /**
  140843. * Block used to add morph targets support to vertex shader
  140844. */
  140845. export class MorphTargetsBlock extends NodeMaterialBlock {
  140846. private _repeatableContentAnchor;
  140847. /**
  140848. * Create a new MorphTargetsBlock
  140849. * @param name defines the block name
  140850. */
  140851. constructor(name: string);
  140852. /**
  140853. * Gets the current class name
  140854. * @returns the class name
  140855. */
  140856. getClassName(): string;
  140857. /**
  140858. * Gets the position input component
  140859. */
  140860. get position(): NodeMaterialConnectionPoint;
  140861. /**
  140862. * Gets the normal input component
  140863. */
  140864. get normal(): NodeMaterialConnectionPoint;
  140865. /**
  140866. * Gets the tangent input component
  140867. */
  140868. get tangent(): NodeMaterialConnectionPoint;
  140869. /**
  140870. * Gets the tangent input component
  140871. */
  140872. get uv(): NodeMaterialConnectionPoint;
  140873. /**
  140874. * Gets the position output component
  140875. */
  140876. get positionOutput(): NodeMaterialConnectionPoint;
  140877. /**
  140878. * Gets the normal output component
  140879. */
  140880. get normalOutput(): NodeMaterialConnectionPoint;
  140881. /**
  140882. * Gets the tangent output component
  140883. */
  140884. get tangentOutput(): NodeMaterialConnectionPoint;
  140885. /**
  140886. * Gets the tangent output component
  140887. */
  140888. get uvOutput(): NodeMaterialConnectionPoint;
  140889. initialize(state: NodeMaterialBuildState): void;
  140890. autoConfigure(material: NodeMaterial): void;
  140891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140892. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140893. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  140894. protected _buildBlock(state: NodeMaterialBuildState): this;
  140895. }
  140896. }
  140897. declare module BABYLON {
  140898. /**
  140899. * Block used to get data information from a light
  140900. */
  140901. export class LightInformationBlock extends NodeMaterialBlock {
  140902. private _lightDataUniformName;
  140903. private _lightColorUniformName;
  140904. private _lightTypeDefineName;
  140905. /**
  140906. * Gets or sets the light associated with this block
  140907. */
  140908. light: Nullable<Light>;
  140909. /**
  140910. * Creates a new LightInformationBlock
  140911. * @param name defines the block name
  140912. */
  140913. constructor(name: string);
  140914. /**
  140915. * Gets the current class name
  140916. * @returns the class name
  140917. */
  140918. getClassName(): string;
  140919. /**
  140920. * Gets the world position input component
  140921. */
  140922. get worldPosition(): NodeMaterialConnectionPoint;
  140923. /**
  140924. * Gets the direction output component
  140925. */
  140926. get direction(): NodeMaterialConnectionPoint;
  140927. /**
  140928. * Gets the direction output component
  140929. */
  140930. get color(): NodeMaterialConnectionPoint;
  140931. /**
  140932. * Gets the direction output component
  140933. */
  140934. get intensity(): NodeMaterialConnectionPoint;
  140935. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140937. protected _buildBlock(state: NodeMaterialBuildState): this;
  140938. serialize(): any;
  140939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140940. }
  140941. }
  140942. declare module BABYLON {
  140943. /**
  140944. * Block used to add image processing support to fragment shader
  140945. */
  140946. export class ImageProcessingBlock extends NodeMaterialBlock {
  140947. /**
  140948. * Create a new ImageProcessingBlock
  140949. * @param name defines the block name
  140950. */
  140951. constructor(name: string);
  140952. /**
  140953. * Gets the current class name
  140954. * @returns the class name
  140955. */
  140956. getClassName(): string;
  140957. /**
  140958. * Gets the color input component
  140959. */
  140960. get color(): NodeMaterialConnectionPoint;
  140961. /**
  140962. * Gets the output component
  140963. */
  140964. get output(): NodeMaterialConnectionPoint;
  140965. /**
  140966. * Initialize the block and prepare the context for build
  140967. * @param state defines the state that will be used for the build
  140968. */
  140969. initialize(state: NodeMaterialBuildState): void;
  140970. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  140971. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140972. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140973. protected _buildBlock(state: NodeMaterialBuildState): this;
  140974. }
  140975. }
  140976. declare module BABYLON {
  140977. /**
  140978. * Block used to pertub normals based on a normal map
  140979. */
  140980. export class PerturbNormalBlock extends NodeMaterialBlock {
  140981. private _tangentSpaceParameterName;
  140982. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140983. invertX: boolean;
  140984. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  140985. invertY: boolean;
  140986. /**
  140987. * Create a new PerturbNormalBlock
  140988. * @param name defines the block name
  140989. */
  140990. constructor(name: string);
  140991. /**
  140992. * Gets the current class name
  140993. * @returns the class name
  140994. */
  140995. getClassName(): string;
  140996. /**
  140997. * Gets the world position input component
  140998. */
  140999. get worldPosition(): NodeMaterialConnectionPoint;
  141000. /**
  141001. * Gets the world normal input component
  141002. */
  141003. get worldNormal(): NodeMaterialConnectionPoint;
  141004. /**
  141005. * Gets the world tangent input component
  141006. */
  141007. get worldTangent(): NodeMaterialConnectionPoint;
  141008. /**
  141009. * Gets the uv input component
  141010. */
  141011. get uv(): NodeMaterialConnectionPoint;
  141012. /**
  141013. * Gets the normal map color input component
  141014. */
  141015. get normalMapColor(): NodeMaterialConnectionPoint;
  141016. /**
  141017. * Gets the strength input component
  141018. */
  141019. get strength(): NodeMaterialConnectionPoint;
  141020. /**
  141021. * Gets the output component
  141022. */
  141023. get output(): NodeMaterialConnectionPoint;
  141024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141025. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141026. autoConfigure(material: NodeMaterial): void;
  141027. protected _buildBlock(state: NodeMaterialBuildState): this;
  141028. protected _dumpPropertiesCode(): string;
  141029. serialize(): any;
  141030. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141031. }
  141032. }
  141033. declare module BABYLON {
  141034. /**
  141035. * Block used to discard a pixel if a value is smaller than a cutoff
  141036. */
  141037. export class DiscardBlock extends NodeMaterialBlock {
  141038. /**
  141039. * Create a new DiscardBlock
  141040. * @param name defines the block name
  141041. */
  141042. constructor(name: string);
  141043. /**
  141044. * Gets the current class name
  141045. * @returns the class name
  141046. */
  141047. getClassName(): string;
  141048. /**
  141049. * Gets the color input component
  141050. */
  141051. get value(): NodeMaterialConnectionPoint;
  141052. /**
  141053. * Gets the cutoff input component
  141054. */
  141055. get cutoff(): NodeMaterialConnectionPoint;
  141056. protected _buildBlock(state: NodeMaterialBuildState): this;
  141057. }
  141058. }
  141059. declare module BABYLON {
  141060. /**
  141061. * Block used to test if the fragment shader is front facing
  141062. */
  141063. export class FrontFacingBlock extends NodeMaterialBlock {
  141064. /**
  141065. * Creates a new FrontFacingBlock
  141066. * @param name defines the block name
  141067. */
  141068. constructor(name: string);
  141069. /**
  141070. * Gets the current class name
  141071. * @returns the class name
  141072. */
  141073. getClassName(): string;
  141074. /**
  141075. * Gets the output component
  141076. */
  141077. get output(): NodeMaterialConnectionPoint;
  141078. protected _buildBlock(state: NodeMaterialBuildState): this;
  141079. }
  141080. }
  141081. declare module BABYLON {
  141082. /**
  141083. * Block used to get the derivative value on x and y of a given input
  141084. */
  141085. export class DerivativeBlock extends NodeMaterialBlock {
  141086. /**
  141087. * Create a new DerivativeBlock
  141088. * @param name defines the block name
  141089. */
  141090. constructor(name: string);
  141091. /**
  141092. * Gets the current class name
  141093. * @returns the class name
  141094. */
  141095. getClassName(): string;
  141096. /**
  141097. * Gets the input component
  141098. */
  141099. get input(): NodeMaterialConnectionPoint;
  141100. /**
  141101. * Gets the derivative output on x
  141102. */
  141103. get dx(): NodeMaterialConnectionPoint;
  141104. /**
  141105. * Gets the derivative output on y
  141106. */
  141107. get dy(): NodeMaterialConnectionPoint;
  141108. protected _buildBlock(state: NodeMaterialBuildState): this;
  141109. }
  141110. }
  141111. declare module BABYLON {
  141112. /**
  141113. * Block used to make gl_FragCoord available
  141114. */
  141115. export class FragCoordBlock extends NodeMaterialBlock {
  141116. /**
  141117. * Creates a new FragCoordBlock
  141118. * @param name defines the block name
  141119. */
  141120. constructor(name: string);
  141121. /**
  141122. * Gets the current class name
  141123. * @returns the class name
  141124. */
  141125. getClassName(): string;
  141126. /**
  141127. * Gets the xy component
  141128. */
  141129. get xy(): NodeMaterialConnectionPoint;
  141130. /**
  141131. * Gets the xyz component
  141132. */
  141133. get xyz(): NodeMaterialConnectionPoint;
  141134. /**
  141135. * Gets the xyzw component
  141136. */
  141137. get xyzw(): NodeMaterialConnectionPoint;
  141138. /**
  141139. * Gets the x component
  141140. */
  141141. get x(): NodeMaterialConnectionPoint;
  141142. /**
  141143. * Gets the y component
  141144. */
  141145. get y(): NodeMaterialConnectionPoint;
  141146. /**
  141147. * Gets the z component
  141148. */
  141149. get z(): NodeMaterialConnectionPoint;
  141150. /**
  141151. * Gets the w component
  141152. */
  141153. get output(): NodeMaterialConnectionPoint;
  141154. protected writeOutputs(state: NodeMaterialBuildState): string;
  141155. protected _buildBlock(state: NodeMaterialBuildState): this;
  141156. }
  141157. }
  141158. declare module BABYLON {
  141159. /**
  141160. * Block used to get the screen sizes
  141161. */
  141162. export class ScreenSizeBlock extends NodeMaterialBlock {
  141163. private _varName;
  141164. private _scene;
  141165. /**
  141166. * Creates a new ScreenSizeBlock
  141167. * @param name defines the block name
  141168. */
  141169. constructor(name: string);
  141170. /**
  141171. * Gets the current class name
  141172. * @returns the class name
  141173. */
  141174. getClassName(): string;
  141175. /**
  141176. * Gets the xy component
  141177. */
  141178. get xy(): NodeMaterialConnectionPoint;
  141179. /**
  141180. * Gets the x component
  141181. */
  141182. get x(): NodeMaterialConnectionPoint;
  141183. /**
  141184. * Gets the y component
  141185. */
  141186. get y(): NodeMaterialConnectionPoint;
  141187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141188. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  141189. protected _buildBlock(state: NodeMaterialBuildState): this;
  141190. }
  141191. }
  141192. declare module BABYLON {
  141193. /**
  141194. * Block used to add support for scene fog
  141195. */
  141196. export class FogBlock extends NodeMaterialBlock {
  141197. private _fogDistanceName;
  141198. private _fogParameters;
  141199. /**
  141200. * Create a new FogBlock
  141201. * @param name defines the block name
  141202. */
  141203. constructor(name: string);
  141204. /**
  141205. * Gets the current class name
  141206. * @returns the class name
  141207. */
  141208. getClassName(): string;
  141209. /**
  141210. * Gets the world position input component
  141211. */
  141212. get worldPosition(): NodeMaterialConnectionPoint;
  141213. /**
  141214. * Gets the view input component
  141215. */
  141216. get view(): NodeMaterialConnectionPoint;
  141217. /**
  141218. * Gets the color input component
  141219. */
  141220. get input(): NodeMaterialConnectionPoint;
  141221. /**
  141222. * Gets the fog color input component
  141223. */
  141224. get fogColor(): NodeMaterialConnectionPoint;
  141225. /**
  141226. * Gets the output component
  141227. */
  141228. get output(): NodeMaterialConnectionPoint;
  141229. autoConfigure(material: NodeMaterial): void;
  141230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141231. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141232. protected _buildBlock(state: NodeMaterialBuildState): this;
  141233. }
  141234. }
  141235. declare module BABYLON {
  141236. /**
  141237. * Block used to add light in the fragment shader
  141238. */
  141239. export class LightBlock extends NodeMaterialBlock {
  141240. private _lightId;
  141241. /**
  141242. * Gets or sets the light associated with this block
  141243. */
  141244. light: Nullable<Light>;
  141245. /**
  141246. * Create a new LightBlock
  141247. * @param name defines the block name
  141248. */
  141249. constructor(name: string);
  141250. /**
  141251. * Gets the current class name
  141252. * @returns the class name
  141253. */
  141254. getClassName(): string;
  141255. /**
  141256. * Gets the world position input component
  141257. */
  141258. get worldPosition(): NodeMaterialConnectionPoint;
  141259. /**
  141260. * Gets the world normal input component
  141261. */
  141262. get worldNormal(): NodeMaterialConnectionPoint;
  141263. /**
  141264. * Gets the camera (or eye) position component
  141265. */
  141266. get cameraPosition(): NodeMaterialConnectionPoint;
  141267. /**
  141268. * Gets the glossiness component
  141269. */
  141270. get glossiness(): NodeMaterialConnectionPoint;
  141271. /**
  141272. * Gets the glossinness power component
  141273. */
  141274. get glossPower(): NodeMaterialConnectionPoint;
  141275. /**
  141276. * Gets the diffuse color component
  141277. */
  141278. get diffuseColor(): NodeMaterialConnectionPoint;
  141279. /**
  141280. * Gets the specular color component
  141281. */
  141282. get specularColor(): NodeMaterialConnectionPoint;
  141283. /**
  141284. * Gets the diffuse output component
  141285. */
  141286. get diffuseOutput(): NodeMaterialConnectionPoint;
  141287. /**
  141288. * Gets the specular output component
  141289. */
  141290. get specularOutput(): NodeMaterialConnectionPoint;
  141291. /**
  141292. * Gets the shadow output component
  141293. */
  141294. get shadow(): NodeMaterialConnectionPoint;
  141295. autoConfigure(material: NodeMaterial): void;
  141296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141297. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141299. private _injectVertexCode;
  141300. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141301. serialize(): any;
  141302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141303. }
  141304. }
  141305. declare module BABYLON {
  141306. /**
  141307. * Block used to read a reflection texture from a sampler
  141308. */
  141309. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  141310. /**
  141311. * Create a new ReflectionTextureBlock
  141312. * @param name defines the block name
  141313. */
  141314. constructor(name: string);
  141315. /**
  141316. * Gets the current class name
  141317. * @returns the class name
  141318. */
  141319. getClassName(): string;
  141320. /**
  141321. * Gets the world position input component
  141322. */
  141323. get position(): NodeMaterialConnectionPoint;
  141324. /**
  141325. * Gets the world position input component
  141326. */
  141327. get worldPosition(): NodeMaterialConnectionPoint;
  141328. /**
  141329. * Gets the world normal input component
  141330. */
  141331. get worldNormal(): NodeMaterialConnectionPoint;
  141332. /**
  141333. * Gets the world input component
  141334. */
  141335. get world(): NodeMaterialConnectionPoint;
  141336. /**
  141337. * Gets the camera (or eye) position component
  141338. */
  141339. get cameraPosition(): NodeMaterialConnectionPoint;
  141340. /**
  141341. * Gets the view input component
  141342. */
  141343. get view(): NodeMaterialConnectionPoint;
  141344. /**
  141345. * Gets the rgb output component
  141346. */
  141347. get rgb(): NodeMaterialConnectionPoint;
  141348. /**
  141349. * Gets the rgba output component
  141350. */
  141351. get rgba(): NodeMaterialConnectionPoint;
  141352. /**
  141353. * Gets the r output component
  141354. */
  141355. get r(): NodeMaterialConnectionPoint;
  141356. /**
  141357. * Gets the g output component
  141358. */
  141359. get g(): NodeMaterialConnectionPoint;
  141360. /**
  141361. * Gets the b output component
  141362. */
  141363. get b(): NodeMaterialConnectionPoint;
  141364. /**
  141365. * Gets the a output component
  141366. */
  141367. get a(): NodeMaterialConnectionPoint;
  141368. autoConfigure(material: NodeMaterial): void;
  141369. protected _buildBlock(state: NodeMaterialBuildState): this;
  141370. }
  141371. }
  141372. declare module BABYLON {
  141373. /**
  141374. * Block used to add 2 vectors
  141375. */
  141376. export class AddBlock extends NodeMaterialBlock {
  141377. /**
  141378. * Creates a new AddBlock
  141379. * @param name defines the block name
  141380. */
  141381. constructor(name: string);
  141382. /**
  141383. * Gets the current class name
  141384. * @returns the class name
  141385. */
  141386. getClassName(): string;
  141387. /**
  141388. * Gets the left operand input component
  141389. */
  141390. get left(): NodeMaterialConnectionPoint;
  141391. /**
  141392. * Gets the right operand input component
  141393. */
  141394. get right(): NodeMaterialConnectionPoint;
  141395. /**
  141396. * Gets the output component
  141397. */
  141398. get output(): NodeMaterialConnectionPoint;
  141399. protected _buildBlock(state: NodeMaterialBuildState): this;
  141400. }
  141401. }
  141402. declare module BABYLON {
  141403. /**
  141404. * Block used to scale a vector by a float
  141405. */
  141406. export class ScaleBlock extends NodeMaterialBlock {
  141407. /**
  141408. * Creates a new ScaleBlock
  141409. * @param name defines the block name
  141410. */
  141411. constructor(name: string);
  141412. /**
  141413. * Gets the current class name
  141414. * @returns the class name
  141415. */
  141416. getClassName(): string;
  141417. /**
  141418. * Gets the input component
  141419. */
  141420. get input(): NodeMaterialConnectionPoint;
  141421. /**
  141422. * Gets the factor input component
  141423. */
  141424. get factor(): NodeMaterialConnectionPoint;
  141425. /**
  141426. * Gets the output component
  141427. */
  141428. get output(): NodeMaterialConnectionPoint;
  141429. protected _buildBlock(state: NodeMaterialBuildState): this;
  141430. }
  141431. }
  141432. declare module BABYLON {
  141433. /**
  141434. * Block used to clamp a float
  141435. */
  141436. export class ClampBlock extends NodeMaterialBlock {
  141437. /** Gets or sets the minimum range */
  141438. minimum: number;
  141439. /** Gets or sets the maximum range */
  141440. maximum: number;
  141441. /**
  141442. * Creates a new ClampBlock
  141443. * @param name defines the block name
  141444. */
  141445. constructor(name: string);
  141446. /**
  141447. * Gets the current class name
  141448. * @returns the class name
  141449. */
  141450. getClassName(): string;
  141451. /**
  141452. * Gets the value input component
  141453. */
  141454. get value(): NodeMaterialConnectionPoint;
  141455. /**
  141456. * Gets the output component
  141457. */
  141458. get output(): NodeMaterialConnectionPoint;
  141459. protected _buildBlock(state: NodeMaterialBuildState): this;
  141460. protected _dumpPropertiesCode(): string;
  141461. serialize(): any;
  141462. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141463. }
  141464. }
  141465. declare module BABYLON {
  141466. /**
  141467. * Block used to apply a cross product between 2 vectors
  141468. */
  141469. export class CrossBlock extends NodeMaterialBlock {
  141470. /**
  141471. * Creates a new CrossBlock
  141472. * @param name defines the block name
  141473. */
  141474. constructor(name: string);
  141475. /**
  141476. * Gets the current class name
  141477. * @returns the class name
  141478. */
  141479. getClassName(): string;
  141480. /**
  141481. * Gets the left operand input component
  141482. */
  141483. get left(): NodeMaterialConnectionPoint;
  141484. /**
  141485. * Gets the right operand input component
  141486. */
  141487. get right(): NodeMaterialConnectionPoint;
  141488. /**
  141489. * Gets the output component
  141490. */
  141491. get output(): NodeMaterialConnectionPoint;
  141492. protected _buildBlock(state: NodeMaterialBuildState): this;
  141493. }
  141494. }
  141495. declare module BABYLON {
  141496. /**
  141497. * Block used to apply a dot product between 2 vectors
  141498. */
  141499. export class DotBlock extends NodeMaterialBlock {
  141500. /**
  141501. * Creates a new DotBlock
  141502. * @param name defines the block name
  141503. */
  141504. constructor(name: string);
  141505. /**
  141506. * Gets the current class name
  141507. * @returns the class name
  141508. */
  141509. getClassName(): string;
  141510. /**
  141511. * Gets the left operand input component
  141512. */
  141513. get left(): NodeMaterialConnectionPoint;
  141514. /**
  141515. * Gets the right operand input component
  141516. */
  141517. get right(): NodeMaterialConnectionPoint;
  141518. /**
  141519. * Gets the output component
  141520. */
  141521. get output(): NodeMaterialConnectionPoint;
  141522. protected _buildBlock(state: NodeMaterialBuildState): this;
  141523. }
  141524. }
  141525. declare module BABYLON {
  141526. /**
  141527. * Block used to normalize a vector
  141528. */
  141529. export class NormalizeBlock extends NodeMaterialBlock {
  141530. /**
  141531. * Creates a new NormalizeBlock
  141532. * @param name defines the block name
  141533. */
  141534. constructor(name: string);
  141535. /**
  141536. * Gets the current class name
  141537. * @returns the class name
  141538. */
  141539. getClassName(): string;
  141540. /**
  141541. * Gets the input component
  141542. */
  141543. get input(): NodeMaterialConnectionPoint;
  141544. /**
  141545. * Gets the output component
  141546. */
  141547. get output(): NodeMaterialConnectionPoint;
  141548. protected _buildBlock(state: NodeMaterialBuildState): this;
  141549. }
  141550. }
  141551. declare module BABYLON {
  141552. /**
  141553. * Operations supported by the Trigonometry block
  141554. */
  141555. export enum TrigonometryBlockOperations {
  141556. /** Cos */
  141557. Cos = 0,
  141558. /** Sin */
  141559. Sin = 1,
  141560. /** Abs */
  141561. Abs = 2,
  141562. /** Exp */
  141563. Exp = 3,
  141564. /** Exp2 */
  141565. Exp2 = 4,
  141566. /** Round */
  141567. Round = 5,
  141568. /** Floor */
  141569. Floor = 6,
  141570. /** Ceiling */
  141571. Ceiling = 7,
  141572. /** Square root */
  141573. Sqrt = 8,
  141574. /** Log */
  141575. Log = 9,
  141576. /** Tangent */
  141577. Tan = 10,
  141578. /** Arc tangent */
  141579. ArcTan = 11,
  141580. /** Arc cosinus */
  141581. ArcCos = 12,
  141582. /** Arc sinus */
  141583. ArcSin = 13,
  141584. /** Fraction */
  141585. Fract = 14,
  141586. /** Sign */
  141587. Sign = 15,
  141588. /** To radians (from degrees) */
  141589. Radians = 16,
  141590. /** To degrees (from radians) */
  141591. Degrees = 17
  141592. }
  141593. /**
  141594. * Block used to apply trigonometry operation to floats
  141595. */
  141596. export class TrigonometryBlock extends NodeMaterialBlock {
  141597. /**
  141598. * Gets or sets the operation applied by the block
  141599. */
  141600. operation: TrigonometryBlockOperations;
  141601. /**
  141602. * Creates a new TrigonometryBlock
  141603. * @param name defines the block name
  141604. */
  141605. constructor(name: string);
  141606. /**
  141607. * Gets the current class name
  141608. * @returns the class name
  141609. */
  141610. getClassName(): string;
  141611. /**
  141612. * Gets the input component
  141613. */
  141614. get input(): NodeMaterialConnectionPoint;
  141615. /**
  141616. * Gets the output component
  141617. */
  141618. get output(): NodeMaterialConnectionPoint;
  141619. protected _buildBlock(state: NodeMaterialBuildState): this;
  141620. serialize(): any;
  141621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141622. protected _dumpPropertiesCode(): string;
  141623. }
  141624. }
  141625. declare module BABYLON {
  141626. /**
  141627. * Block used to create a Color3/4 out of individual inputs (one for each component)
  141628. */
  141629. export class ColorMergerBlock extends NodeMaterialBlock {
  141630. /**
  141631. * Create a new ColorMergerBlock
  141632. * @param name defines the block name
  141633. */
  141634. constructor(name: string);
  141635. /**
  141636. * Gets the current class name
  141637. * @returns the class name
  141638. */
  141639. getClassName(): string;
  141640. /**
  141641. * Gets the rgb component (input)
  141642. */
  141643. get rgbIn(): NodeMaterialConnectionPoint;
  141644. /**
  141645. * Gets the r component (input)
  141646. */
  141647. get r(): NodeMaterialConnectionPoint;
  141648. /**
  141649. * Gets the g component (input)
  141650. */
  141651. get g(): NodeMaterialConnectionPoint;
  141652. /**
  141653. * Gets the b component (input)
  141654. */
  141655. get b(): NodeMaterialConnectionPoint;
  141656. /**
  141657. * Gets the a component (input)
  141658. */
  141659. get a(): NodeMaterialConnectionPoint;
  141660. /**
  141661. * Gets the rgba component (output)
  141662. */
  141663. get rgba(): NodeMaterialConnectionPoint;
  141664. /**
  141665. * Gets the rgb component (output)
  141666. */
  141667. get rgbOut(): NodeMaterialConnectionPoint;
  141668. /**
  141669. * Gets the rgb component (output)
  141670. * @deprecated Please use rgbOut instead.
  141671. */
  141672. get rgb(): NodeMaterialConnectionPoint;
  141673. protected _buildBlock(state: NodeMaterialBuildState): this;
  141674. }
  141675. }
  141676. declare module BABYLON {
  141677. /**
  141678. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  141679. */
  141680. export class VectorSplitterBlock extends NodeMaterialBlock {
  141681. /**
  141682. * Create a new VectorSplitterBlock
  141683. * @param name defines the block name
  141684. */
  141685. constructor(name: string);
  141686. /**
  141687. * Gets the current class name
  141688. * @returns the class name
  141689. */
  141690. getClassName(): string;
  141691. /**
  141692. * Gets the xyzw component (input)
  141693. */
  141694. get xyzw(): NodeMaterialConnectionPoint;
  141695. /**
  141696. * Gets the xyz component (input)
  141697. */
  141698. get xyzIn(): NodeMaterialConnectionPoint;
  141699. /**
  141700. * Gets the xy component (input)
  141701. */
  141702. get xyIn(): NodeMaterialConnectionPoint;
  141703. /**
  141704. * Gets the xyz component (output)
  141705. */
  141706. get xyzOut(): NodeMaterialConnectionPoint;
  141707. /**
  141708. * Gets the xy component (output)
  141709. */
  141710. get xyOut(): NodeMaterialConnectionPoint;
  141711. /**
  141712. * Gets the x component (output)
  141713. */
  141714. get x(): NodeMaterialConnectionPoint;
  141715. /**
  141716. * Gets the y component (output)
  141717. */
  141718. get y(): NodeMaterialConnectionPoint;
  141719. /**
  141720. * Gets the z component (output)
  141721. */
  141722. get z(): NodeMaterialConnectionPoint;
  141723. /**
  141724. * Gets the w component (output)
  141725. */
  141726. get w(): NodeMaterialConnectionPoint;
  141727. protected _inputRename(name: string): string;
  141728. protected _outputRename(name: string): string;
  141729. protected _buildBlock(state: NodeMaterialBuildState): this;
  141730. }
  141731. }
  141732. declare module BABYLON {
  141733. /**
  141734. * Block used to lerp between 2 values
  141735. */
  141736. export class LerpBlock extends NodeMaterialBlock {
  141737. /**
  141738. * Creates a new LerpBlock
  141739. * @param name defines the block name
  141740. */
  141741. constructor(name: string);
  141742. /**
  141743. * Gets the current class name
  141744. * @returns the class name
  141745. */
  141746. getClassName(): string;
  141747. /**
  141748. * Gets the left operand input component
  141749. */
  141750. get left(): NodeMaterialConnectionPoint;
  141751. /**
  141752. * Gets the right operand input component
  141753. */
  141754. get right(): NodeMaterialConnectionPoint;
  141755. /**
  141756. * Gets the gradient operand input component
  141757. */
  141758. get gradient(): NodeMaterialConnectionPoint;
  141759. /**
  141760. * Gets the output component
  141761. */
  141762. get output(): NodeMaterialConnectionPoint;
  141763. protected _buildBlock(state: NodeMaterialBuildState): this;
  141764. }
  141765. }
  141766. declare module BABYLON {
  141767. /**
  141768. * Block used to divide 2 vectors
  141769. */
  141770. export class DivideBlock extends NodeMaterialBlock {
  141771. /**
  141772. * Creates a new DivideBlock
  141773. * @param name defines the block name
  141774. */
  141775. constructor(name: string);
  141776. /**
  141777. * Gets the current class name
  141778. * @returns the class name
  141779. */
  141780. getClassName(): string;
  141781. /**
  141782. * Gets the left operand input component
  141783. */
  141784. get left(): NodeMaterialConnectionPoint;
  141785. /**
  141786. * Gets the right operand input component
  141787. */
  141788. get right(): NodeMaterialConnectionPoint;
  141789. /**
  141790. * Gets the output component
  141791. */
  141792. get output(): NodeMaterialConnectionPoint;
  141793. protected _buildBlock(state: NodeMaterialBuildState): this;
  141794. }
  141795. }
  141796. declare module BABYLON {
  141797. /**
  141798. * Block used to subtract 2 vectors
  141799. */
  141800. export class SubtractBlock extends NodeMaterialBlock {
  141801. /**
  141802. * Creates a new SubtractBlock
  141803. * @param name defines the block name
  141804. */
  141805. constructor(name: string);
  141806. /**
  141807. * Gets the current class name
  141808. * @returns the class name
  141809. */
  141810. getClassName(): string;
  141811. /**
  141812. * Gets the left operand input component
  141813. */
  141814. get left(): NodeMaterialConnectionPoint;
  141815. /**
  141816. * Gets the right operand input component
  141817. */
  141818. get right(): NodeMaterialConnectionPoint;
  141819. /**
  141820. * Gets the output component
  141821. */
  141822. get output(): NodeMaterialConnectionPoint;
  141823. protected _buildBlock(state: NodeMaterialBuildState): this;
  141824. }
  141825. }
  141826. declare module BABYLON {
  141827. /**
  141828. * Block used to step a value
  141829. */
  141830. export class StepBlock extends NodeMaterialBlock {
  141831. /**
  141832. * Creates a new StepBlock
  141833. * @param name defines the block name
  141834. */
  141835. constructor(name: string);
  141836. /**
  141837. * Gets the current class name
  141838. * @returns the class name
  141839. */
  141840. getClassName(): string;
  141841. /**
  141842. * Gets the value operand input component
  141843. */
  141844. get value(): NodeMaterialConnectionPoint;
  141845. /**
  141846. * Gets the edge operand input component
  141847. */
  141848. get edge(): NodeMaterialConnectionPoint;
  141849. /**
  141850. * Gets the output component
  141851. */
  141852. get output(): NodeMaterialConnectionPoint;
  141853. protected _buildBlock(state: NodeMaterialBuildState): this;
  141854. }
  141855. }
  141856. declare module BABYLON {
  141857. /**
  141858. * Block used to get the opposite (1 - x) of a value
  141859. */
  141860. export class OneMinusBlock extends NodeMaterialBlock {
  141861. /**
  141862. * Creates a new OneMinusBlock
  141863. * @param name defines the block name
  141864. */
  141865. constructor(name: string);
  141866. /**
  141867. * Gets the current class name
  141868. * @returns the class name
  141869. */
  141870. getClassName(): string;
  141871. /**
  141872. * Gets the input component
  141873. */
  141874. get input(): NodeMaterialConnectionPoint;
  141875. /**
  141876. * Gets the output component
  141877. */
  141878. get output(): NodeMaterialConnectionPoint;
  141879. protected _buildBlock(state: NodeMaterialBuildState): this;
  141880. }
  141881. }
  141882. declare module BABYLON {
  141883. /**
  141884. * Block used to get the view direction
  141885. */
  141886. export class ViewDirectionBlock extends NodeMaterialBlock {
  141887. /**
  141888. * Creates a new ViewDirectionBlock
  141889. * @param name defines the block name
  141890. */
  141891. constructor(name: string);
  141892. /**
  141893. * Gets the current class name
  141894. * @returns the class name
  141895. */
  141896. getClassName(): string;
  141897. /**
  141898. * Gets the world position component
  141899. */
  141900. get worldPosition(): NodeMaterialConnectionPoint;
  141901. /**
  141902. * Gets the camera position component
  141903. */
  141904. get cameraPosition(): NodeMaterialConnectionPoint;
  141905. /**
  141906. * Gets the output component
  141907. */
  141908. get output(): NodeMaterialConnectionPoint;
  141909. autoConfigure(material: NodeMaterial): void;
  141910. protected _buildBlock(state: NodeMaterialBuildState): this;
  141911. }
  141912. }
  141913. declare module BABYLON {
  141914. /**
  141915. * Block used to compute fresnel value
  141916. */
  141917. export class FresnelBlock extends NodeMaterialBlock {
  141918. /**
  141919. * Create a new FresnelBlock
  141920. * @param name defines the block name
  141921. */
  141922. constructor(name: string);
  141923. /**
  141924. * Gets the current class name
  141925. * @returns the class name
  141926. */
  141927. getClassName(): string;
  141928. /**
  141929. * Gets the world normal input component
  141930. */
  141931. get worldNormal(): NodeMaterialConnectionPoint;
  141932. /**
  141933. * Gets the view direction input component
  141934. */
  141935. get viewDirection(): NodeMaterialConnectionPoint;
  141936. /**
  141937. * Gets the bias input component
  141938. */
  141939. get bias(): NodeMaterialConnectionPoint;
  141940. /**
  141941. * Gets the camera (or eye) position component
  141942. */
  141943. get power(): NodeMaterialConnectionPoint;
  141944. /**
  141945. * Gets the fresnel output component
  141946. */
  141947. get fresnel(): NodeMaterialConnectionPoint;
  141948. autoConfigure(material: NodeMaterial): void;
  141949. protected _buildBlock(state: NodeMaterialBuildState): this;
  141950. }
  141951. }
  141952. declare module BABYLON {
  141953. /**
  141954. * Block used to get the max of 2 values
  141955. */
  141956. export class MaxBlock extends NodeMaterialBlock {
  141957. /**
  141958. * Creates a new MaxBlock
  141959. * @param name defines the block name
  141960. */
  141961. constructor(name: string);
  141962. /**
  141963. * Gets the current class name
  141964. * @returns the class name
  141965. */
  141966. getClassName(): string;
  141967. /**
  141968. * Gets the left operand input component
  141969. */
  141970. get left(): NodeMaterialConnectionPoint;
  141971. /**
  141972. * Gets the right operand input component
  141973. */
  141974. get right(): NodeMaterialConnectionPoint;
  141975. /**
  141976. * Gets the output component
  141977. */
  141978. get output(): NodeMaterialConnectionPoint;
  141979. protected _buildBlock(state: NodeMaterialBuildState): this;
  141980. }
  141981. }
  141982. declare module BABYLON {
  141983. /**
  141984. * Block used to get the min of 2 values
  141985. */
  141986. export class MinBlock extends NodeMaterialBlock {
  141987. /**
  141988. * Creates a new MinBlock
  141989. * @param name defines the block name
  141990. */
  141991. constructor(name: string);
  141992. /**
  141993. * Gets the current class name
  141994. * @returns the class name
  141995. */
  141996. getClassName(): string;
  141997. /**
  141998. * Gets the left operand input component
  141999. */
  142000. get left(): NodeMaterialConnectionPoint;
  142001. /**
  142002. * Gets the right operand input component
  142003. */
  142004. get right(): NodeMaterialConnectionPoint;
  142005. /**
  142006. * Gets the output component
  142007. */
  142008. get output(): NodeMaterialConnectionPoint;
  142009. protected _buildBlock(state: NodeMaterialBuildState): this;
  142010. }
  142011. }
  142012. declare module BABYLON {
  142013. /**
  142014. * Block used to get the distance between 2 values
  142015. */
  142016. export class DistanceBlock extends NodeMaterialBlock {
  142017. /**
  142018. * Creates a new DistanceBlock
  142019. * @param name defines the block name
  142020. */
  142021. constructor(name: string);
  142022. /**
  142023. * Gets the current class name
  142024. * @returns the class name
  142025. */
  142026. getClassName(): string;
  142027. /**
  142028. * Gets the left operand input component
  142029. */
  142030. get left(): NodeMaterialConnectionPoint;
  142031. /**
  142032. * Gets the right operand input component
  142033. */
  142034. get right(): NodeMaterialConnectionPoint;
  142035. /**
  142036. * Gets the output component
  142037. */
  142038. get output(): NodeMaterialConnectionPoint;
  142039. protected _buildBlock(state: NodeMaterialBuildState): this;
  142040. }
  142041. }
  142042. declare module BABYLON {
  142043. /**
  142044. * Block used to get the length of a vector
  142045. */
  142046. export class LengthBlock extends NodeMaterialBlock {
  142047. /**
  142048. * Creates a new LengthBlock
  142049. * @param name defines the block name
  142050. */
  142051. constructor(name: string);
  142052. /**
  142053. * Gets the current class name
  142054. * @returns the class name
  142055. */
  142056. getClassName(): string;
  142057. /**
  142058. * Gets the value input component
  142059. */
  142060. get value(): NodeMaterialConnectionPoint;
  142061. /**
  142062. * Gets the output component
  142063. */
  142064. get output(): NodeMaterialConnectionPoint;
  142065. protected _buildBlock(state: NodeMaterialBuildState): this;
  142066. }
  142067. }
  142068. declare module BABYLON {
  142069. /**
  142070. * Block used to get negative version of a value (i.e. x * -1)
  142071. */
  142072. export class NegateBlock extends NodeMaterialBlock {
  142073. /**
  142074. * Creates a new NegateBlock
  142075. * @param name defines the block name
  142076. */
  142077. constructor(name: string);
  142078. /**
  142079. * Gets the current class name
  142080. * @returns the class name
  142081. */
  142082. getClassName(): string;
  142083. /**
  142084. * Gets the value input component
  142085. */
  142086. get value(): NodeMaterialConnectionPoint;
  142087. /**
  142088. * Gets the output component
  142089. */
  142090. get output(): NodeMaterialConnectionPoint;
  142091. protected _buildBlock(state: NodeMaterialBuildState): this;
  142092. }
  142093. }
  142094. declare module BABYLON {
  142095. /**
  142096. * Block used to get the value of the first parameter raised to the power of the second
  142097. */
  142098. export class PowBlock extends NodeMaterialBlock {
  142099. /**
  142100. * Creates a new PowBlock
  142101. * @param name defines the block name
  142102. */
  142103. constructor(name: string);
  142104. /**
  142105. * Gets the current class name
  142106. * @returns the class name
  142107. */
  142108. getClassName(): string;
  142109. /**
  142110. * Gets the value operand input component
  142111. */
  142112. get value(): NodeMaterialConnectionPoint;
  142113. /**
  142114. * Gets the power operand input component
  142115. */
  142116. get power(): NodeMaterialConnectionPoint;
  142117. /**
  142118. * Gets the output component
  142119. */
  142120. get output(): NodeMaterialConnectionPoint;
  142121. protected _buildBlock(state: NodeMaterialBuildState): this;
  142122. }
  142123. }
  142124. declare module BABYLON {
  142125. /**
  142126. * Block used to get a random number
  142127. */
  142128. export class RandomNumberBlock extends NodeMaterialBlock {
  142129. /**
  142130. * Creates a new RandomNumberBlock
  142131. * @param name defines the block name
  142132. */
  142133. constructor(name: string);
  142134. /**
  142135. * Gets the current class name
  142136. * @returns the class name
  142137. */
  142138. getClassName(): string;
  142139. /**
  142140. * Gets the seed input component
  142141. */
  142142. get seed(): NodeMaterialConnectionPoint;
  142143. /**
  142144. * Gets the output component
  142145. */
  142146. get output(): NodeMaterialConnectionPoint;
  142147. protected _buildBlock(state: NodeMaterialBuildState): this;
  142148. }
  142149. }
  142150. declare module BABYLON {
  142151. /**
  142152. * Block used to compute arc tangent of 2 values
  142153. */
  142154. export class ArcTan2Block extends NodeMaterialBlock {
  142155. /**
  142156. * Creates a new ArcTan2Block
  142157. * @param name defines the block name
  142158. */
  142159. constructor(name: string);
  142160. /**
  142161. * Gets the current class name
  142162. * @returns the class name
  142163. */
  142164. getClassName(): string;
  142165. /**
  142166. * Gets the x operand input component
  142167. */
  142168. get x(): NodeMaterialConnectionPoint;
  142169. /**
  142170. * Gets the y operand input component
  142171. */
  142172. get y(): NodeMaterialConnectionPoint;
  142173. /**
  142174. * Gets the output component
  142175. */
  142176. get output(): NodeMaterialConnectionPoint;
  142177. protected _buildBlock(state: NodeMaterialBuildState): this;
  142178. }
  142179. }
  142180. declare module BABYLON {
  142181. /**
  142182. * Block used to smooth step a value
  142183. */
  142184. export class SmoothStepBlock extends NodeMaterialBlock {
  142185. /**
  142186. * Creates a new SmoothStepBlock
  142187. * @param name defines the block name
  142188. */
  142189. constructor(name: string);
  142190. /**
  142191. * Gets the current class name
  142192. * @returns the class name
  142193. */
  142194. getClassName(): string;
  142195. /**
  142196. * Gets the value operand input component
  142197. */
  142198. get value(): NodeMaterialConnectionPoint;
  142199. /**
  142200. * Gets the first edge operand input component
  142201. */
  142202. get edge0(): NodeMaterialConnectionPoint;
  142203. /**
  142204. * Gets the second edge operand input component
  142205. */
  142206. get edge1(): NodeMaterialConnectionPoint;
  142207. /**
  142208. * Gets the output component
  142209. */
  142210. get output(): NodeMaterialConnectionPoint;
  142211. protected _buildBlock(state: NodeMaterialBuildState): this;
  142212. }
  142213. }
  142214. declare module BABYLON {
  142215. /**
  142216. * Block used to get the reciprocal (1 / x) of a value
  142217. */
  142218. export class ReciprocalBlock extends NodeMaterialBlock {
  142219. /**
  142220. * Creates a new ReciprocalBlock
  142221. * @param name defines the block name
  142222. */
  142223. constructor(name: string);
  142224. /**
  142225. * Gets the current class name
  142226. * @returns the class name
  142227. */
  142228. getClassName(): string;
  142229. /**
  142230. * Gets the input component
  142231. */
  142232. get input(): NodeMaterialConnectionPoint;
  142233. /**
  142234. * Gets the output component
  142235. */
  142236. get output(): NodeMaterialConnectionPoint;
  142237. protected _buildBlock(state: NodeMaterialBuildState): this;
  142238. }
  142239. }
  142240. declare module BABYLON {
  142241. /**
  142242. * Block used to replace a color by another one
  142243. */
  142244. export class ReplaceColorBlock extends NodeMaterialBlock {
  142245. /**
  142246. * Creates a new ReplaceColorBlock
  142247. * @param name defines the block name
  142248. */
  142249. constructor(name: string);
  142250. /**
  142251. * Gets the current class name
  142252. * @returns the class name
  142253. */
  142254. getClassName(): string;
  142255. /**
  142256. * Gets the value input component
  142257. */
  142258. get value(): NodeMaterialConnectionPoint;
  142259. /**
  142260. * Gets the reference input component
  142261. */
  142262. get reference(): NodeMaterialConnectionPoint;
  142263. /**
  142264. * Gets the distance input component
  142265. */
  142266. get distance(): NodeMaterialConnectionPoint;
  142267. /**
  142268. * Gets the replacement input component
  142269. */
  142270. get replacement(): NodeMaterialConnectionPoint;
  142271. /**
  142272. * Gets the output component
  142273. */
  142274. get output(): NodeMaterialConnectionPoint;
  142275. protected _buildBlock(state: NodeMaterialBuildState): this;
  142276. }
  142277. }
  142278. declare module BABYLON {
  142279. /**
  142280. * Block used to posterize a value
  142281. * @see https://en.wikipedia.org/wiki/Posterization
  142282. */
  142283. export class PosterizeBlock extends NodeMaterialBlock {
  142284. /**
  142285. * Creates a new PosterizeBlock
  142286. * @param name defines the block name
  142287. */
  142288. constructor(name: string);
  142289. /**
  142290. * Gets the current class name
  142291. * @returns the class name
  142292. */
  142293. getClassName(): string;
  142294. /**
  142295. * Gets the value input component
  142296. */
  142297. get value(): NodeMaterialConnectionPoint;
  142298. /**
  142299. * Gets the steps input component
  142300. */
  142301. get steps(): NodeMaterialConnectionPoint;
  142302. /**
  142303. * Gets the output component
  142304. */
  142305. get output(): NodeMaterialConnectionPoint;
  142306. protected _buildBlock(state: NodeMaterialBuildState): this;
  142307. }
  142308. }
  142309. declare module BABYLON {
  142310. /**
  142311. * Operations supported by the Wave block
  142312. */
  142313. export enum WaveBlockKind {
  142314. /** SawTooth */
  142315. SawTooth = 0,
  142316. /** Square */
  142317. Square = 1,
  142318. /** Triangle */
  142319. Triangle = 2
  142320. }
  142321. /**
  142322. * Block used to apply wave operation to floats
  142323. */
  142324. export class WaveBlock extends NodeMaterialBlock {
  142325. /**
  142326. * Gets or sets the kibnd of wave to be applied by the block
  142327. */
  142328. kind: WaveBlockKind;
  142329. /**
  142330. * Creates a new WaveBlock
  142331. * @param name defines the block name
  142332. */
  142333. constructor(name: string);
  142334. /**
  142335. * Gets the current class name
  142336. * @returns the class name
  142337. */
  142338. getClassName(): string;
  142339. /**
  142340. * Gets the input component
  142341. */
  142342. get input(): NodeMaterialConnectionPoint;
  142343. /**
  142344. * Gets the output component
  142345. */
  142346. get output(): NodeMaterialConnectionPoint;
  142347. protected _buildBlock(state: NodeMaterialBuildState): this;
  142348. serialize(): any;
  142349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142350. }
  142351. }
  142352. declare module BABYLON {
  142353. /**
  142354. * Class used to store a color step for the GradientBlock
  142355. */
  142356. export class GradientBlockColorStep {
  142357. /**
  142358. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142359. */
  142360. step: number;
  142361. /**
  142362. * Gets or sets the color associated with this step
  142363. */
  142364. color: Color3;
  142365. /**
  142366. * Creates a new GradientBlockColorStep
  142367. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  142368. * @param color defines the color associated with this step
  142369. */
  142370. constructor(
  142371. /**
  142372. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142373. */
  142374. step: number,
  142375. /**
  142376. * Gets or sets the color associated with this step
  142377. */
  142378. color: Color3);
  142379. }
  142380. /**
  142381. * Block used to return a color from a gradient based on an input value between 0 and 1
  142382. */
  142383. export class GradientBlock extends NodeMaterialBlock {
  142384. /**
  142385. * Gets or sets the list of color steps
  142386. */
  142387. colorSteps: GradientBlockColorStep[];
  142388. /**
  142389. * Creates a new GradientBlock
  142390. * @param name defines the block name
  142391. */
  142392. constructor(name: string);
  142393. /**
  142394. * Gets the current class name
  142395. * @returns the class name
  142396. */
  142397. getClassName(): string;
  142398. /**
  142399. * Gets the gradient input component
  142400. */
  142401. get gradient(): NodeMaterialConnectionPoint;
  142402. /**
  142403. * Gets the output component
  142404. */
  142405. get output(): NodeMaterialConnectionPoint;
  142406. private _writeColorConstant;
  142407. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142408. serialize(): any;
  142409. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142410. protected _dumpPropertiesCode(): string;
  142411. }
  142412. }
  142413. declare module BABYLON {
  142414. /**
  142415. * Block used to normalize lerp between 2 values
  142416. */
  142417. export class NLerpBlock extends NodeMaterialBlock {
  142418. /**
  142419. * Creates a new NLerpBlock
  142420. * @param name defines the block name
  142421. */
  142422. constructor(name: string);
  142423. /**
  142424. * Gets the current class name
  142425. * @returns the class name
  142426. */
  142427. getClassName(): string;
  142428. /**
  142429. * Gets the left operand input component
  142430. */
  142431. get left(): NodeMaterialConnectionPoint;
  142432. /**
  142433. * Gets the right operand input component
  142434. */
  142435. get right(): NodeMaterialConnectionPoint;
  142436. /**
  142437. * Gets the gradient operand input component
  142438. */
  142439. get gradient(): NodeMaterialConnectionPoint;
  142440. /**
  142441. * Gets the output component
  142442. */
  142443. get output(): NodeMaterialConnectionPoint;
  142444. protected _buildBlock(state: NodeMaterialBuildState): this;
  142445. }
  142446. }
  142447. declare module BABYLON {
  142448. /**
  142449. * block used to Generate a Worley Noise 3D Noise Pattern
  142450. */
  142451. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  142452. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142453. manhattanDistance: boolean;
  142454. /**
  142455. * Creates a new WorleyNoise3DBlock
  142456. * @param name defines the block name
  142457. */
  142458. constructor(name: string);
  142459. /**
  142460. * Gets the current class name
  142461. * @returns the class name
  142462. */
  142463. getClassName(): string;
  142464. /**
  142465. * Gets the seed input component
  142466. */
  142467. get seed(): NodeMaterialConnectionPoint;
  142468. /**
  142469. * Gets the jitter input component
  142470. */
  142471. get jitter(): NodeMaterialConnectionPoint;
  142472. /**
  142473. * Gets the output component
  142474. */
  142475. get output(): NodeMaterialConnectionPoint;
  142476. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142477. /**
  142478. * Exposes the properties to the UI?
  142479. */
  142480. protected _dumpPropertiesCode(): string;
  142481. /**
  142482. * Exposes the properties to the Seralize?
  142483. */
  142484. serialize(): any;
  142485. /**
  142486. * Exposes the properties to the deseralize?
  142487. */
  142488. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142489. }
  142490. }
  142491. declare module BABYLON {
  142492. /**
  142493. * block used to Generate a Simplex Perlin 3d Noise Pattern
  142494. */
  142495. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  142496. /**
  142497. * Creates a new SimplexPerlin3DBlock
  142498. * @param name defines the block name
  142499. */
  142500. constructor(name: string);
  142501. /**
  142502. * Gets the current class name
  142503. * @returns the class name
  142504. */
  142505. getClassName(): string;
  142506. /**
  142507. * Gets the seed operand input component
  142508. */
  142509. get seed(): NodeMaterialConnectionPoint;
  142510. /**
  142511. * Gets the output component
  142512. */
  142513. get output(): NodeMaterialConnectionPoint;
  142514. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142515. }
  142516. }
  142517. declare module BABYLON {
  142518. /**
  142519. * Block used to blend normals
  142520. */
  142521. export class NormalBlendBlock extends NodeMaterialBlock {
  142522. /**
  142523. * Creates a new NormalBlendBlock
  142524. * @param name defines the block name
  142525. */
  142526. constructor(name: string);
  142527. /**
  142528. * Gets the current class name
  142529. * @returns the class name
  142530. */
  142531. getClassName(): string;
  142532. /**
  142533. * Gets the first input component
  142534. */
  142535. get normalMap0(): NodeMaterialConnectionPoint;
  142536. /**
  142537. * Gets the second input component
  142538. */
  142539. get normalMap1(): NodeMaterialConnectionPoint;
  142540. /**
  142541. * Gets the output component
  142542. */
  142543. get output(): NodeMaterialConnectionPoint;
  142544. protected _buildBlock(state: NodeMaterialBuildState): this;
  142545. }
  142546. }
  142547. declare module BABYLON {
  142548. /**
  142549. * Block used to rotate a 2d vector by a given angle
  142550. */
  142551. export class Rotate2dBlock extends NodeMaterialBlock {
  142552. /**
  142553. * Creates a new Rotate2dBlock
  142554. * @param name defines the block name
  142555. */
  142556. constructor(name: string);
  142557. /**
  142558. * Gets the current class name
  142559. * @returns the class name
  142560. */
  142561. getClassName(): string;
  142562. /**
  142563. * Gets the input vector
  142564. */
  142565. get input(): NodeMaterialConnectionPoint;
  142566. /**
  142567. * Gets the input angle
  142568. */
  142569. get angle(): NodeMaterialConnectionPoint;
  142570. /**
  142571. * Gets the output component
  142572. */
  142573. get output(): NodeMaterialConnectionPoint;
  142574. autoConfigure(material: NodeMaterial): void;
  142575. protected _buildBlock(state: NodeMaterialBuildState): this;
  142576. }
  142577. }
  142578. declare module BABYLON {
  142579. /**
  142580. * Block used to get the reflected vector from a direction and a normal
  142581. */
  142582. export class ReflectBlock extends NodeMaterialBlock {
  142583. /**
  142584. * Creates a new ReflectBlock
  142585. * @param name defines the block name
  142586. */
  142587. constructor(name: string);
  142588. /**
  142589. * Gets the current class name
  142590. * @returns the class name
  142591. */
  142592. getClassName(): string;
  142593. /**
  142594. * Gets the incident component
  142595. */
  142596. get incident(): NodeMaterialConnectionPoint;
  142597. /**
  142598. * Gets the normal component
  142599. */
  142600. get normal(): NodeMaterialConnectionPoint;
  142601. /**
  142602. * Gets the output component
  142603. */
  142604. get output(): NodeMaterialConnectionPoint;
  142605. protected _buildBlock(state: NodeMaterialBuildState): this;
  142606. }
  142607. }
  142608. declare module BABYLON {
  142609. /**
  142610. * Block used to get the refracted vector from a direction and a normal
  142611. */
  142612. export class RefractBlock extends NodeMaterialBlock {
  142613. /**
  142614. * Creates a new RefractBlock
  142615. * @param name defines the block name
  142616. */
  142617. constructor(name: string);
  142618. /**
  142619. * Gets the current class name
  142620. * @returns the class name
  142621. */
  142622. getClassName(): string;
  142623. /**
  142624. * Gets the incident component
  142625. */
  142626. get incident(): NodeMaterialConnectionPoint;
  142627. /**
  142628. * Gets the normal component
  142629. */
  142630. get normal(): NodeMaterialConnectionPoint;
  142631. /**
  142632. * Gets the index of refraction component
  142633. */
  142634. get ior(): NodeMaterialConnectionPoint;
  142635. /**
  142636. * Gets the output component
  142637. */
  142638. get output(): NodeMaterialConnectionPoint;
  142639. protected _buildBlock(state: NodeMaterialBuildState): this;
  142640. }
  142641. }
  142642. declare module BABYLON {
  142643. /**
  142644. * Block used to desaturate a color
  142645. */
  142646. export class DesaturateBlock extends NodeMaterialBlock {
  142647. /**
  142648. * Creates a new DesaturateBlock
  142649. * @param name defines the block name
  142650. */
  142651. constructor(name: string);
  142652. /**
  142653. * Gets the current class name
  142654. * @returns the class name
  142655. */
  142656. getClassName(): string;
  142657. /**
  142658. * Gets the color operand input component
  142659. */
  142660. get color(): NodeMaterialConnectionPoint;
  142661. /**
  142662. * Gets the level operand input component
  142663. */
  142664. get level(): NodeMaterialConnectionPoint;
  142665. /**
  142666. * Gets the output component
  142667. */
  142668. get output(): NodeMaterialConnectionPoint;
  142669. protected _buildBlock(state: NodeMaterialBuildState): this;
  142670. }
  142671. }
  142672. declare module BABYLON {
  142673. /**
  142674. * Block used to implement the ambient occlusion module of the PBR material
  142675. */
  142676. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  142677. /**
  142678. * Create a new AmbientOcclusionBlock
  142679. * @param name defines the block name
  142680. */
  142681. constructor(name: string);
  142682. /**
  142683. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  142684. */
  142685. useAmbientInGrayScale: boolean;
  142686. /**
  142687. * Initialize the block and prepare the context for build
  142688. * @param state defines the state that will be used for the build
  142689. */
  142690. initialize(state: NodeMaterialBuildState): void;
  142691. /**
  142692. * Gets the current class name
  142693. * @returns the class name
  142694. */
  142695. getClassName(): string;
  142696. /**
  142697. * Gets the texture input component
  142698. */
  142699. get texture(): NodeMaterialConnectionPoint;
  142700. /**
  142701. * Gets the texture intensity component
  142702. */
  142703. get intensity(): NodeMaterialConnectionPoint;
  142704. /**
  142705. * Gets the direct light intensity input component
  142706. */
  142707. get directLightIntensity(): NodeMaterialConnectionPoint;
  142708. /**
  142709. * Gets the ambient occlusion object output component
  142710. */
  142711. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142712. /**
  142713. * Gets the main code of the block (fragment side)
  142714. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  142715. * @returns the shader code
  142716. */
  142717. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  142718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142719. protected _buildBlock(state: NodeMaterialBuildState): this;
  142720. protected _dumpPropertiesCode(): string;
  142721. serialize(): any;
  142722. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142723. }
  142724. }
  142725. declare module BABYLON {
  142726. /**
  142727. * Block used to implement the reflection module of the PBR material
  142728. */
  142729. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  142730. /** @hidden */
  142731. _defineLODReflectionAlpha: string;
  142732. /** @hidden */
  142733. _defineLinearSpecularReflection: string;
  142734. private _vEnvironmentIrradianceName;
  142735. /** @hidden */
  142736. _vReflectionMicrosurfaceInfosName: string;
  142737. /** @hidden */
  142738. _vReflectionInfosName: string;
  142739. /** @hidden */
  142740. _vReflectionFilteringInfoName: string;
  142741. private _scene;
  142742. /**
  142743. * The three properties below are set by the main PBR block prior to calling methods of this class.
  142744. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142745. * It's less burden on the user side in the editor part.
  142746. */
  142747. /** @hidden */
  142748. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142749. /** @hidden */
  142750. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142751. /** @hidden */
  142752. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  142753. /**
  142754. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  142755. * diffuse part of the IBL.
  142756. */
  142757. useSphericalHarmonics: boolean;
  142758. /**
  142759. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  142760. */
  142761. forceIrradianceInFragment: boolean;
  142762. /**
  142763. * Create a new ReflectionBlock
  142764. * @param name defines the block name
  142765. */
  142766. constructor(name: string);
  142767. /**
  142768. * Gets the current class name
  142769. * @returns the class name
  142770. */
  142771. getClassName(): string;
  142772. /**
  142773. * Gets the position input component
  142774. */
  142775. get position(): NodeMaterialConnectionPoint;
  142776. /**
  142777. * Gets the world position input component
  142778. */
  142779. get worldPosition(): NodeMaterialConnectionPoint;
  142780. /**
  142781. * Gets the world normal input component
  142782. */
  142783. get worldNormal(): NodeMaterialConnectionPoint;
  142784. /**
  142785. * Gets the world input component
  142786. */
  142787. get world(): NodeMaterialConnectionPoint;
  142788. /**
  142789. * Gets the camera (or eye) position component
  142790. */
  142791. get cameraPosition(): NodeMaterialConnectionPoint;
  142792. /**
  142793. * Gets the view input component
  142794. */
  142795. get view(): NodeMaterialConnectionPoint;
  142796. /**
  142797. * Gets the color input component
  142798. */
  142799. get color(): NodeMaterialConnectionPoint;
  142800. /**
  142801. * Gets the reflection object output component
  142802. */
  142803. get reflection(): NodeMaterialConnectionPoint;
  142804. /**
  142805. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  142806. */
  142807. get hasTexture(): boolean;
  142808. /**
  142809. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  142810. */
  142811. get reflectionColor(): string;
  142812. protected _getTexture(): Nullable<BaseTexture>;
  142813. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142814. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142815. /**
  142816. * Gets the code to inject in the vertex shader
  142817. * @param state current state of the node material building
  142818. * @returns the shader code
  142819. */
  142820. handleVertexSide(state: NodeMaterialBuildState): string;
  142821. /**
  142822. * Gets the main code of the block (fragment side)
  142823. * @param state current state of the node material building
  142824. * @param normalVarName name of the existing variable corresponding to the normal
  142825. * @returns the shader code
  142826. */
  142827. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  142828. protected _buildBlock(state: NodeMaterialBuildState): this;
  142829. protected _dumpPropertiesCode(): string;
  142830. serialize(): any;
  142831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142832. }
  142833. }
  142834. declare module BABYLON {
  142835. /**
  142836. * Block used to implement the sheen module of the PBR material
  142837. */
  142838. export class SheenBlock extends NodeMaterialBlock {
  142839. /**
  142840. * Create a new SheenBlock
  142841. * @param name defines the block name
  142842. */
  142843. constructor(name: string);
  142844. /**
  142845. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  142846. * It allows the strength of the sheen effect to not depend on the base color of the material,
  142847. * making it easier to setup and tweak the effect
  142848. */
  142849. albedoScaling: boolean;
  142850. /**
  142851. * Defines if the sheen is linked to the sheen color.
  142852. */
  142853. linkSheenWithAlbedo: boolean;
  142854. /**
  142855. * Initialize the block and prepare the context for build
  142856. * @param state defines the state that will be used for the build
  142857. */
  142858. initialize(state: NodeMaterialBuildState): void;
  142859. /**
  142860. * Gets the current class name
  142861. * @returns the class name
  142862. */
  142863. getClassName(): string;
  142864. /**
  142865. * Gets the intensity input component
  142866. */
  142867. get intensity(): NodeMaterialConnectionPoint;
  142868. /**
  142869. * Gets the color input component
  142870. */
  142871. get color(): NodeMaterialConnectionPoint;
  142872. /**
  142873. * Gets the roughness input component
  142874. */
  142875. get roughness(): NodeMaterialConnectionPoint;
  142876. /**
  142877. * Gets the sheen object output component
  142878. */
  142879. get sheen(): NodeMaterialConnectionPoint;
  142880. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142881. /**
  142882. * Gets the main code of the block (fragment side)
  142883. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142884. * @returns the shader code
  142885. */
  142886. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  142887. protected _buildBlock(state: NodeMaterialBuildState): this;
  142888. protected _dumpPropertiesCode(): string;
  142889. serialize(): any;
  142890. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142891. }
  142892. }
  142893. declare module BABYLON {
  142894. /**
  142895. * Block used to implement the reflectivity module of the PBR material
  142896. */
  142897. export class ReflectivityBlock extends NodeMaterialBlock {
  142898. private _metallicReflectanceColor;
  142899. private _metallicF0Factor;
  142900. /** @hidden */
  142901. _vMetallicReflectanceFactorsName: string;
  142902. /**
  142903. * The property below is set by the main PBR block prior to calling methods of this class.
  142904. */
  142905. /** @hidden */
  142906. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  142907. /**
  142908. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  142909. */
  142910. useAmbientOcclusionFromMetallicTextureRed: boolean;
  142911. /**
  142912. * Specifies if the metallic texture contains the metallness information in its blue channel.
  142913. */
  142914. useMetallnessFromMetallicTextureBlue: boolean;
  142915. /**
  142916. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  142917. */
  142918. useRoughnessFromMetallicTextureAlpha: boolean;
  142919. /**
  142920. * Specifies if the metallic texture contains the roughness information in its green channel.
  142921. */
  142922. useRoughnessFromMetallicTextureGreen: boolean;
  142923. /**
  142924. * Create a new ReflectivityBlock
  142925. * @param name defines the block name
  142926. */
  142927. constructor(name: string);
  142928. /**
  142929. * Initialize the block and prepare the context for build
  142930. * @param state defines the state that will be used for the build
  142931. */
  142932. initialize(state: NodeMaterialBuildState): void;
  142933. /**
  142934. * Gets the current class name
  142935. * @returns the class name
  142936. */
  142937. getClassName(): string;
  142938. /**
  142939. * Gets the metallic input component
  142940. */
  142941. get metallic(): NodeMaterialConnectionPoint;
  142942. /**
  142943. * Gets the roughness input component
  142944. */
  142945. get roughness(): NodeMaterialConnectionPoint;
  142946. /**
  142947. * Gets the texture input component
  142948. */
  142949. get texture(): NodeMaterialConnectionPoint;
  142950. /**
  142951. * Gets the reflectivity object output component
  142952. */
  142953. get reflectivity(): NodeMaterialConnectionPoint;
  142954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142955. /**
  142956. * Gets the main code of the block (fragment side)
  142957. * @param state current state of the node material building
  142958. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  142959. * @returns the shader code
  142960. */
  142961. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  142962. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142963. protected _buildBlock(state: NodeMaterialBuildState): this;
  142964. protected _dumpPropertiesCode(): string;
  142965. serialize(): any;
  142966. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142967. }
  142968. }
  142969. declare module BABYLON {
  142970. /**
  142971. * Block used to implement the anisotropy module of the PBR material
  142972. */
  142973. export class AnisotropyBlock extends NodeMaterialBlock {
  142974. /**
  142975. * The two properties below are set by the main PBR block prior to calling methods of this class.
  142976. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142977. * It's less burden on the user side in the editor part.
  142978. */
  142979. /** @hidden */
  142980. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142981. /** @hidden */
  142982. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142983. /**
  142984. * Create a new AnisotropyBlock
  142985. * @param name defines the block name
  142986. */
  142987. constructor(name: string);
  142988. /**
  142989. * Initialize the block and prepare the context for build
  142990. * @param state defines the state that will be used for the build
  142991. */
  142992. initialize(state: NodeMaterialBuildState): void;
  142993. /**
  142994. * Gets the current class name
  142995. * @returns the class name
  142996. */
  142997. getClassName(): string;
  142998. /**
  142999. * Gets the intensity input component
  143000. */
  143001. get intensity(): NodeMaterialConnectionPoint;
  143002. /**
  143003. * Gets the direction input component
  143004. */
  143005. get direction(): NodeMaterialConnectionPoint;
  143006. /**
  143007. * Gets the texture input component
  143008. */
  143009. get texture(): NodeMaterialConnectionPoint;
  143010. /**
  143011. * Gets the uv input component
  143012. */
  143013. get uv(): NodeMaterialConnectionPoint;
  143014. /**
  143015. * Gets the worldTangent input component
  143016. */
  143017. get worldTangent(): NodeMaterialConnectionPoint;
  143018. /**
  143019. * Gets the anisotropy object output component
  143020. */
  143021. get anisotropy(): NodeMaterialConnectionPoint;
  143022. private _generateTBNSpace;
  143023. /**
  143024. * Gets the main code of the block (fragment side)
  143025. * @param state current state of the node material building
  143026. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143027. * @returns the shader code
  143028. */
  143029. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  143030. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143031. protected _buildBlock(state: NodeMaterialBuildState): this;
  143032. }
  143033. }
  143034. declare module BABYLON {
  143035. /**
  143036. * Block used to implement the clear coat module of the PBR material
  143037. */
  143038. export class ClearCoatBlock extends NodeMaterialBlock {
  143039. private _scene;
  143040. /**
  143041. * Create a new ClearCoatBlock
  143042. * @param name defines the block name
  143043. */
  143044. constructor(name: string);
  143045. /**
  143046. * Initialize the block and prepare the context for build
  143047. * @param state defines the state that will be used for the build
  143048. */
  143049. initialize(state: NodeMaterialBuildState): void;
  143050. /**
  143051. * Gets the current class name
  143052. * @returns the class name
  143053. */
  143054. getClassName(): string;
  143055. /**
  143056. * Gets the intensity input component
  143057. */
  143058. get intensity(): NodeMaterialConnectionPoint;
  143059. /**
  143060. * Gets the roughness input component
  143061. */
  143062. get roughness(): NodeMaterialConnectionPoint;
  143063. /**
  143064. * Gets the ior input component
  143065. */
  143066. get ior(): NodeMaterialConnectionPoint;
  143067. /**
  143068. * Gets the texture input component
  143069. */
  143070. get texture(): NodeMaterialConnectionPoint;
  143071. /**
  143072. * Gets the bump texture input component
  143073. */
  143074. get bumpTexture(): NodeMaterialConnectionPoint;
  143075. /**
  143076. * Gets the uv input component
  143077. */
  143078. get uv(): NodeMaterialConnectionPoint;
  143079. /**
  143080. * Gets the tint color input component
  143081. */
  143082. get tintColor(): NodeMaterialConnectionPoint;
  143083. /**
  143084. * Gets the tint "at distance" input component
  143085. */
  143086. get tintAtDistance(): NodeMaterialConnectionPoint;
  143087. /**
  143088. * Gets the tint thickness input component
  143089. */
  143090. get tintThickness(): NodeMaterialConnectionPoint;
  143091. /**
  143092. * Gets the world tangent input component
  143093. */
  143094. get worldTangent(): NodeMaterialConnectionPoint;
  143095. /**
  143096. * Gets the clear coat object output component
  143097. */
  143098. get clearcoat(): NodeMaterialConnectionPoint;
  143099. autoConfigure(material: NodeMaterial): void;
  143100. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143102. private _generateTBNSpace;
  143103. /**
  143104. * Gets the main code of the block (fragment side)
  143105. * @param state current state of the node material building
  143106. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  143107. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143108. * @param worldPosVarName name of the variable holding the world position
  143109. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143110. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  143111. * @param worldNormalVarName name of the variable holding the world normal
  143112. * @returns the shader code
  143113. */
  143114. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  143115. protected _buildBlock(state: NodeMaterialBuildState): this;
  143116. }
  143117. }
  143118. declare module BABYLON {
  143119. /**
  143120. * Block used to implement the sub surface module of the PBR material
  143121. */
  143122. export class SubSurfaceBlock extends NodeMaterialBlock {
  143123. /**
  143124. * Create a new SubSurfaceBlock
  143125. * @param name defines the block name
  143126. */
  143127. constructor(name: string);
  143128. /**
  143129. * Stores the intensity of the different subsurface effects in the thickness texture.
  143130. * * the green channel is the translucency intensity.
  143131. * * the blue channel is the scattering intensity.
  143132. * * the alpha channel is the refraction intensity.
  143133. */
  143134. useMaskFromThicknessTexture: boolean;
  143135. /**
  143136. * Initialize the block and prepare the context for build
  143137. * @param state defines the state that will be used for the build
  143138. */
  143139. initialize(state: NodeMaterialBuildState): void;
  143140. /**
  143141. * Gets the current class name
  143142. * @returns the class name
  143143. */
  143144. getClassName(): string;
  143145. /**
  143146. * Gets the min thickness input component
  143147. */
  143148. get minThickness(): NodeMaterialConnectionPoint;
  143149. /**
  143150. * Gets the max thickness input component
  143151. */
  143152. get maxThickness(): NodeMaterialConnectionPoint;
  143153. /**
  143154. * Gets the thickness texture component
  143155. */
  143156. get thicknessTexture(): NodeMaterialConnectionPoint;
  143157. /**
  143158. * Gets the tint color input component
  143159. */
  143160. get tintColor(): NodeMaterialConnectionPoint;
  143161. /**
  143162. * Gets the translucency intensity input component
  143163. */
  143164. get translucencyIntensity(): NodeMaterialConnectionPoint;
  143165. /**
  143166. * Gets the translucency diffusion distance input component
  143167. */
  143168. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  143169. /**
  143170. * Gets the refraction object parameters
  143171. */
  143172. get refraction(): NodeMaterialConnectionPoint;
  143173. /**
  143174. * Gets the sub surface object output component
  143175. */
  143176. get subsurface(): NodeMaterialConnectionPoint;
  143177. autoConfigure(material: NodeMaterial): void;
  143178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143179. /**
  143180. * Gets the main code of the block (fragment side)
  143181. * @param state current state of the node material building
  143182. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  143183. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143184. * @param worldPosVarName name of the variable holding the world position
  143185. * @returns the shader code
  143186. */
  143187. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  143188. protected _buildBlock(state: NodeMaterialBuildState): this;
  143189. }
  143190. }
  143191. declare module BABYLON {
  143192. /**
  143193. * Block used to implement the PBR metallic/roughness model
  143194. */
  143195. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  143196. /**
  143197. * Gets or sets the light associated with this block
  143198. */
  143199. light: Nullable<Light>;
  143200. private _lightId;
  143201. private _scene;
  143202. private _environmentBRDFTexture;
  143203. private _environmentBrdfSamplerName;
  143204. private _vNormalWName;
  143205. private _invertNormalName;
  143206. /**
  143207. * Create a new ReflectionBlock
  143208. * @param name defines the block name
  143209. */
  143210. constructor(name: string);
  143211. /**
  143212. * Intensity of the direct lights e.g. the four lights available in your scene.
  143213. * This impacts both the direct diffuse and specular highlights.
  143214. */
  143215. directIntensity: number;
  143216. /**
  143217. * Intensity of the environment e.g. how much the environment will light the object
  143218. * either through harmonics for rough material or through the refelction for shiny ones.
  143219. */
  143220. environmentIntensity: number;
  143221. /**
  143222. * This is a special control allowing the reduction of the specular highlights coming from the
  143223. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  143224. */
  143225. specularIntensity: number;
  143226. /**
  143227. * Defines the falloff type used in this material.
  143228. * It by default is Physical.
  143229. */
  143230. lightFalloff: number;
  143231. /**
  143232. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  143233. */
  143234. useAlphaFromAlbedoTexture: boolean;
  143235. /**
  143236. * Specifies that alpha test should be used
  143237. */
  143238. useAlphaTest: boolean;
  143239. /**
  143240. * Defines the alpha limits in alpha test mode.
  143241. */
  143242. alphaTestCutoff: number;
  143243. /**
  143244. * Specifies that alpha blending should be used
  143245. */
  143246. useAlphaBlending: boolean;
  143247. /**
  143248. * Defines if the alpha value should be determined via the rgb values.
  143249. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  143250. */
  143251. opacityRGB: boolean;
  143252. /**
  143253. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  143254. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  143255. */
  143256. useRadianceOverAlpha: boolean;
  143257. /**
  143258. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  143259. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  143260. */
  143261. useSpecularOverAlpha: boolean;
  143262. /**
  143263. * Enables specular anti aliasing in the PBR shader.
  143264. * It will both interacts on the Geometry for analytical and IBL lighting.
  143265. * It also prefilter the roughness map based on the bump values.
  143266. */
  143267. enableSpecularAntiAliasing: boolean;
  143268. /**
  143269. * Enables realtime filtering on the texture.
  143270. */
  143271. realTimeFiltering: boolean;
  143272. /**
  143273. * Quality switch for realtime filtering
  143274. */
  143275. realTimeFilteringQuality: number;
  143276. /**
  143277. * Defines if the material uses energy conservation.
  143278. */
  143279. useEnergyConservation: boolean;
  143280. /**
  143281. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  143282. * too much the area relying on ambient texture to define their ambient occlusion.
  143283. */
  143284. useRadianceOcclusion: boolean;
  143285. /**
  143286. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  143287. * makes the reflect vector face the model (under horizon).
  143288. */
  143289. useHorizonOcclusion: boolean;
  143290. /**
  143291. * If set to true, no lighting calculations will be applied.
  143292. */
  143293. unlit: boolean;
  143294. /**
  143295. * Force normal to face away from face.
  143296. */
  143297. forceNormalForward: boolean;
  143298. /**
  143299. * Defines the material debug mode.
  143300. * It helps seeing only some components of the material while troubleshooting.
  143301. */
  143302. debugMode: number;
  143303. /**
  143304. * Specify from where on screen the debug mode should start.
  143305. * The value goes from -1 (full screen) to 1 (not visible)
  143306. * It helps with side by side comparison against the final render
  143307. * This defaults to 0
  143308. */
  143309. debugLimit: number;
  143310. /**
  143311. * As the default viewing range might not be enough (if the ambient is really small for instance)
  143312. * You can use the factor to better multiply the final value.
  143313. */
  143314. debugFactor: number;
  143315. /**
  143316. * Initialize the block and prepare the context for build
  143317. * @param state defines the state that will be used for the build
  143318. */
  143319. initialize(state: NodeMaterialBuildState): void;
  143320. /**
  143321. * Gets the current class name
  143322. * @returns the class name
  143323. */
  143324. getClassName(): string;
  143325. /**
  143326. * Gets the world position input component
  143327. */
  143328. get worldPosition(): NodeMaterialConnectionPoint;
  143329. /**
  143330. * Gets the world normal input component
  143331. */
  143332. get worldNormal(): NodeMaterialConnectionPoint;
  143333. /**
  143334. * Gets the perturbed normal input component
  143335. */
  143336. get perturbedNormal(): NodeMaterialConnectionPoint;
  143337. /**
  143338. * Gets the camera position input component
  143339. */
  143340. get cameraPosition(): NodeMaterialConnectionPoint;
  143341. /**
  143342. * Gets the base color input component
  143343. */
  143344. get baseColor(): NodeMaterialConnectionPoint;
  143345. /**
  143346. * Gets the opacity texture input component
  143347. */
  143348. get opacityTexture(): NodeMaterialConnectionPoint;
  143349. /**
  143350. * Gets the ambient color input component
  143351. */
  143352. get ambientColor(): NodeMaterialConnectionPoint;
  143353. /**
  143354. * Gets the reflectivity object parameters
  143355. */
  143356. get reflectivity(): NodeMaterialConnectionPoint;
  143357. /**
  143358. * Gets the ambient occlusion object parameters
  143359. */
  143360. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143361. /**
  143362. * Gets the reflection object parameters
  143363. */
  143364. get reflection(): NodeMaterialConnectionPoint;
  143365. /**
  143366. * Gets the sheen object parameters
  143367. */
  143368. get sheen(): NodeMaterialConnectionPoint;
  143369. /**
  143370. * Gets the clear coat object parameters
  143371. */
  143372. get clearcoat(): NodeMaterialConnectionPoint;
  143373. /**
  143374. * Gets the sub surface object parameters
  143375. */
  143376. get subsurface(): NodeMaterialConnectionPoint;
  143377. /**
  143378. * Gets the anisotropy object parameters
  143379. */
  143380. get anisotropy(): NodeMaterialConnectionPoint;
  143381. /**
  143382. * Gets the ambient output component
  143383. */
  143384. get ambient(): NodeMaterialConnectionPoint;
  143385. /**
  143386. * Gets the diffuse output component
  143387. */
  143388. get diffuse(): NodeMaterialConnectionPoint;
  143389. /**
  143390. * Gets the specular output component
  143391. */
  143392. get specular(): NodeMaterialConnectionPoint;
  143393. /**
  143394. * Gets the sheen output component
  143395. */
  143396. get sheenDir(): NodeMaterialConnectionPoint;
  143397. /**
  143398. * Gets the clear coat output component
  143399. */
  143400. get clearcoatDir(): NodeMaterialConnectionPoint;
  143401. /**
  143402. * Gets the indirect diffuse output component
  143403. */
  143404. get diffuseIndirect(): NodeMaterialConnectionPoint;
  143405. /**
  143406. * Gets the indirect specular output component
  143407. */
  143408. get specularIndirect(): NodeMaterialConnectionPoint;
  143409. /**
  143410. * Gets the indirect sheen output component
  143411. */
  143412. get sheenIndirect(): NodeMaterialConnectionPoint;
  143413. /**
  143414. * Gets the indirect clear coat output component
  143415. */
  143416. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  143417. /**
  143418. * Gets the refraction output component
  143419. */
  143420. get refraction(): NodeMaterialConnectionPoint;
  143421. /**
  143422. * Gets the global lighting output component
  143423. */
  143424. get lighting(): NodeMaterialConnectionPoint;
  143425. /**
  143426. * Gets the shadow output component
  143427. */
  143428. get shadow(): NodeMaterialConnectionPoint;
  143429. /**
  143430. * Gets the alpha output component
  143431. */
  143432. get alpha(): NodeMaterialConnectionPoint;
  143433. autoConfigure(material: NodeMaterial): void;
  143434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143435. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143436. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143437. private _injectVertexCode;
  143438. /**
  143439. * Gets the code corresponding to the albedo/opacity module
  143440. * @returns the shader code
  143441. */
  143442. getAlbedoOpacityCode(): string;
  143443. protected _buildBlock(state: NodeMaterialBuildState): this;
  143444. protected _dumpPropertiesCode(): string;
  143445. serialize(): any;
  143446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143447. }
  143448. }
  143449. declare module BABYLON {
  143450. /**
  143451. * Block used to compute value of one parameter modulo another
  143452. */
  143453. export class ModBlock extends NodeMaterialBlock {
  143454. /**
  143455. * Creates a new ModBlock
  143456. * @param name defines the block name
  143457. */
  143458. constructor(name: string);
  143459. /**
  143460. * Gets the current class name
  143461. * @returns the class name
  143462. */
  143463. getClassName(): string;
  143464. /**
  143465. * Gets the left operand input component
  143466. */
  143467. get left(): NodeMaterialConnectionPoint;
  143468. /**
  143469. * Gets the right operand input component
  143470. */
  143471. get right(): NodeMaterialConnectionPoint;
  143472. /**
  143473. * Gets the output component
  143474. */
  143475. get output(): NodeMaterialConnectionPoint;
  143476. protected _buildBlock(state: NodeMaterialBuildState): this;
  143477. }
  143478. }
  143479. declare module BABYLON {
  143480. /**
  143481. * Helper class to push actions to a pool of workers.
  143482. */
  143483. export class WorkerPool implements IDisposable {
  143484. private _workerInfos;
  143485. private _pendingActions;
  143486. /**
  143487. * Constructor
  143488. * @param workers Array of workers to use for actions
  143489. */
  143490. constructor(workers: Array<Worker>);
  143491. /**
  143492. * Terminates all workers and clears any pending actions.
  143493. */
  143494. dispose(): void;
  143495. /**
  143496. * Pushes an action to the worker pool. If all the workers are active, the action will be
  143497. * pended until a worker has completed its action.
  143498. * @param action The action to perform. Call onComplete when the action is complete.
  143499. */
  143500. push(action: (worker: Worker, onComplete: () => void) => void): void;
  143501. private _execute;
  143502. }
  143503. }
  143504. declare module BABYLON {
  143505. /**
  143506. * Configuration for Draco compression
  143507. */
  143508. export interface IDracoCompressionConfiguration {
  143509. /**
  143510. * Configuration for the decoder.
  143511. */
  143512. decoder: {
  143513. /**
  143514. * The url to the WebAssembly module.
  143515. */
  143516. wasmUrl?: string;
  143517. /**
  143518. * The url to the WebAssembly binary.
  143519. */
  143520. wasmBinaryUrl?: string;
  143521. /**
  143522. * The url to the fallback JavaScript module.
  143523. */
  143524. fallbackUrl?: string;
  143525. };
  143526. }
  143527. /**
  143528. * Draco compression (https://google.github.io/draco/)
  143529. *
  143530. * This class wraps the Draco module.
  143531. *
  143532. * **Encoder**
  143533. *
  143534. * The encoder is not currently implemented.
  143535. *
  143536. * **Decoder**
  143537. *
  143538. * 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.
  143539. *
  143540. * To update the configuration, use the following code:
  143541. * ```javascript
  143542. * DracoCompression.Configuration = {
  143543. * decoder: {
  143544. * wasmUrl: "<url to the WebAssembly library>",
  143545. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  143546. * fallbackUrl: "<url to the fallback JavaScript library>",
  143547. * }
  143548. * };
  143549. * ```
  143550. *
  143551. * 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.
  143552. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  143553. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  143554. *
  143555. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  143556. * ```javascript
  143557. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  143558. * ```
  143559. *
  143560. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  143561. */
  143562. export class DracoCompression implements IDisposable {
  143563. private _workerPoolPromise?;
  143564. private _decoderModulePromise?;
  143565. /**
  143566. * The configuration. Defaults to the following urls:
  143567. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  143568. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  143569. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  143570. */
  143571. static Configuration: IDracoCompressionConfiguration;
  143572. /**
  143573. * Returns true if the decoder configuration is available.
  143574. */
  143575. static get DecoderAvailable(): boolean;
  143576. /**
  143577. * Default number of workers to create when creating the draco compression object.
  143578. */
  143579. static DefaultNumWorkers: number;
  143580. private static GetDefaultNumWorkers;
  143581. private static _Default;
  143582. /**
  143583. * Default instance for the draco compression object.
  143584. */
  143585. static get Default(): DracoCompression;
  143586. /**
  143587. * Constructor
  143588. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  143589. */
  143590. constructor(numWorkers?: number);
  143591. /**
  143592. * Stop all async operations and release resources.
  143593. */
  143594. dispose(): void;
  143595. /**
  143596. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  143597. * @returns a promise that resolves when ready
  143598. */
  143599. whenReadyAsync(): Promise<void>;
  143600. /**
  143601. * Decode Draco compressed mesh data to vertex data.
  143602. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  143603. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  143604. * @returns A promise that resolves with the decoded vertex data
  143605. */
  143606. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  143607. [kind: string]: number;
  143608. }): Promise<VertexData>;
  143609. }
  143610. }
  143611. declare module BABYLON {
  143612. /**
  143613. * Class for building Constructive Solid Geometry
  143614. */
  143615. export class CSG {
  143616. private polygons;
  143617. /**
  143618. * The world matrix
  143619. */
  143620. matrix: Matrix;
  143621. /**
  143622. * Stores the position
  143623. */
  143624. position: Vector3;
  143625. /**
  143626. * Stores the rotation
  143627. */
  143628. rotation: Vector3;
  143629. /**
  143630. * Stores the rotation quaternion
  143631. */
  143632. rotationQuaternion: Nullable<Quaternion>;
  143633. /**
  143634. * Stores the scaling vector
  143635. */
  143636. scaling: Vector3;
  143637. /**
  143638. * Convert the Mesh to CSG
  143639. * @param mesh The Mesh to convert to CSG
  143640. * @returns A new CSG from the Mesh
  143641. */
  143642. static FromMesh(mesh: Mesh): CSG;
  143643. /**
  143644. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  143645. * @param polygons Polygons used to construct a CSG solid
  143646. */
  143647. private static FromPolygons;
  143648. /**
  143649. * Clones, or makes a deep copy, of the CSG
  143650. * @returns A new CSG
  143651. */
  143652. clone(): CSG;
  143653. /**
  143654. * Unions this CSG with another CSG
  143655. * @param csg The CSG to union against this CSG
  143656. * @returns The unioned CSG
  143657. */
  143658. union(csg: CSG): CSG;
  143659. /**
  143660. * Unions this CSG with another CSG in place
  143661. * @param csg The CSG to union against this CSG
  143662. */
  143663. unionInPlace(csg: CSG): void;
  143664. /**
  143665. * Subtracts this CSG with another CSG
  143666. * @param csg The CSG to subtract against this CSG
  143667. * @returns A new CSG
  143668. */
  143669. subtract(csg: CSG): CSG;
  143670. /**
  143671. * Subtracts this CSG with another CSG in place
  143672. * @param csg The CSG to subtact against this CSG
  143673. */
  143674. subtractInPlace(csg: CSG): void;
  143675. /**
  143676. * Intersect this CSG with another CSG
  143677. * @param csg The CSG to intersect against this CSG
  143678. * @returns A new CSG
  143679. */
  143680. intersect(csg: CSG): CSG;
  143681. /**
  143682. * Intersects this CSG with another CSG in place
  143683. * @param csg The CSG to intersect against this CSG
  143684. */
  143685. intersectInPlace(csg: CSG): void;
  143686. /**
  143687. * Return a new CSG solid with solid and empty space switched. This solid is
  143688. * not modified.
  143689. * @returns A new CSG solid with solid and empty space switched
  143690. */
  143691. inverse(): CSG;
  143692. /**
  143693. * Inverses the CSG in place
  143694. */
  143695. inverseInPlace(): void;
  143696. /**
  143697. * This is used to keep meshes transformations so they can be restored
  143698. * when we build back a Babylon Mesh
  143699. * NB : All CSG operations are performed in world coordinates
  143700. * @param csg The CSG to copy the transform attributes from
  143701. * @returns This CSG
  143702. */
  143703. copyTransformAttributes(csg: CSG): CSG;
  143704. /**
  143705. * Build Raw mesh from CSG
  143706. * Coordinates here are in world space
  143707. * @param name The name of the mesh geometry
  143708. * @param scene The Scene
  143709. * @param keepSubMeshes Specifies if the submeshes should be kept
  143710. * @returns A new Mesh
  143711. */
  143712. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143713. /**
  143714. * Build Mesh from CSG taking material and transforms into account
  143715. * @param name The name of the Mesh
  143716. * @param material The material of the Mesh
  143717. * @param scene The Scene
  143718. * @param keepSubMeshes Specifies if submeshes should be kept
  143719. * @returns The new Mesh
  143720. */
  143721. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143722. }
  143723. }
  143724. declare module BABYLON {
  143725. /**
  143726. * Class used to create a trail following a mesh
  143727. */
  143728. export class TrailMesh extends Mesh {
  143729. private _generator;
  143730. private _autoStart;
  143731. private _running;
  143732. private _diameter;
  143733. private _length;
  143734. private _sectionPolygonPointsCount;
  143735. private _sectionVectors;
  143736. private _sectionNormalVectors;
  143737. private _beforeRenderObserver;
  143738. /**
  143739. * @constructor
  143740. * @param name The value used by scene.getMeshByName() to do a lookup.
  143741. * @param generator The mesh or transform node to generate a trail.
  143742. * @param scene The scene to add this mesh to.
  143743. * @param diameter Diameter of trailing mesh. Default is 1.
  143744. * @param length Length of trailing mesh. Default is 60.
  143745. * @param autoStart Automatically start trailing mesh. Default true.
  143746. */
  143747. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  143748. /**
  143749. * "TrailMesh"
  143750. * @returns "TrailMesh"
  143751. */
  143752. getClassName(): string;
  143753. private _createMesh;
  143754. /**
  143755. * Start trailing mesh.
  143756. */
  143757. start(): void;
  143758. /**
  143759. * Stop trailing mesh.
  143760. */
  143761. stop(): void;
  143762. /**
  143763. * Update trailing mesh geometry.
  143764. */
  143765. update(): void;
  143766. /**
  143767. * Returns a new TrailMesh object.
  143768. * @param name is a string, the name given to the new mesh
  143769. * @param newGenerator use new generator object for cloned trail mesh
  143770. * @returns a new mesh
  143771. */
  143772. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  143773. /**
  143774. * Serializes this trail mesh
  143775. * @param serializationObject object to write serialization to
  143776. */
  143777. serialize(serializationObject: any): void;
  143778. /**
  143779. * Parses a serialized trail mesh
  143780. * @param parsedMesh the serialized mesh
  143781. * @param scene the scene to create the trail mesh in
  143782. * @returns the created trail mesh
  143783. */
  143784. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  143785. }
  143786. }
  143787. declare module BABYLON {
  143788. /**
  143789. * Class containing static functions to help procedurally build meshes
  143790. */
  143791. export class TiledBoxBuilder {
  143792. /**
  143793. * Creates a box mesh
  143794. * 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)
  143795. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143799. * @param name defines the name of the mesh
  143800. * @param options defines the options used to create the mesh
  143801. * @param scene defines the hosting scene
  143802. * @returns the box mesh
  143803. */
  143804. static CreateTiledBox(name: string, options: {
  143805. pattern?: number;
  143806. width?: number;
  143807. height?: number;
  143808. depth?: number;
  143809. tileSize?: number;
  143810. tileWidth?: number;
  143811. tileHeight?: number;
  143812. alignHorizontal?: number;
  143813. alignVertical?: number;
  143814. faceUV?: Vector4[];
  143815. faceColors?: Color4[];
  143816. sideOrientation?: number;
  143817. updatable?: boolean;
  143818. }, scene?: Nullable<Scene>): Mesh;
  143819. }
  143820. }
  143821. declare module BABYLON {
  143822. /**
  143823. * Class containing static functions to help procedurally build meshes
  143824. */
  143825. export class TorusKnotBuilder {
  143826. /**
  143827. * Creates a torus knot mesh
  143828. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143829. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143830. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143831. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143835. * @param name defines the name of the mesh
  143836. * @param options defines the options used to create the mesh
  143837. * @param scene defines the hosting scene
  143838. * @returns the torus knot mesh
  143839. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143840. */
  143841. static CreateTorusKnot(name: string, options: {
  143842. radius?: number;
  143843. tube?: number;
  143844. radialSegments?: number;
  143845. tubularSegments?: number;
  143846. p?: number;
  143847. q?: number;
  143848. updatable?: boolean;
  143849. sideOrientation?: number;
  143850. frontUVs?: Vector4;
  143851. backUVs?: Vector4;
  143852. }, scene: any): Mesh;
  143853. }
  143854. }
  143855. declare module BABYLON {
  143856. /**
  143857. * Polygon
  143858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  143859. */
  143860. export class Polygon {
  143861. /**
  143862. * Creates a rectangle
  143863. * @param xmin bottom X coord
  143864. * @param ymin bottom Y coord
  143865. * @param xmax top X coord
  143866. * @param ymax top Y coord
  143867. * @returns points that make the resulting rectation
  143868. */
  143869. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  143870. /**
  143871. * Creates a circle
  143872. * @param radius radius of circle
  143873. * @param cx scale in x
  143874. * @param cy scale in y
  143875. * @param numberOfSides number of sides that make up the circle
  143876. * @returns points that make the resulting circle
  143877. */
  143878. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  143879. /**
  143880. * Creates a polygon from input string
  143881. * @param input Input polygon data
  143882. * @returns the parsed points
  143883. */
  143884. static Parse(input: string): Vector2[];
  143885. /**
  143886. * Starts building a polygon from x and y coordinates
  143887. * @param x x coordinate
  143888. * @param y y coordinate
  143889. * @returns the started path2
  143890. */
  143891. static StartingAt(x: number, y: number): Path2;
  143892. }
  143893. /**
  143894. * Builds a polygon
  143895. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  143896. */
  143897. export class PolygonMeshBuilder {
  143898. private _points;
  143899. private _outlinepoints;
  143900. private _holes;
  143901. private _name;
  143902. private _scene;
  143903. private _epoints;
  143904. private _eholes;
  143905. private _addToepoint;
  143906. /**
  143907. * Babylon reference to the earcut plugin.
  143908. */
  143909. bjsEarcut: any;
  143910. /**
  143911. * Creates a PolygonMeshBuilder
  143912. * @param name name of the builder
  143913. * @param contours Path of the polygon
  143914. * @param scene scene to add to when creating the mesh
  143915. * @param earcutInjection can be used to inject your own earcut reference
  143916. */
  143917. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  143918. /**
  143919. * Adds a whole within the polygon
  143920. * @param hole Array of points defining the hole
  143921. * @returns this
  143922. */
  143923. addHole(hole: Vector2[]): PolygonMeshBuilder;
  143924. /**
  143925. * Creates the polygon
  143926. * @param updatable If the mesh should be updatable
  143927. * @param depth The depth of the mesh created
  143928. * @returns the created mesh
  143929. */
  143930. build(updatable?: boolean, depth?: number): Mesh;
  143931. /**
  143932. * Creates the polygon
  143933. * @param depth The depth of the mesh created
  143934. * @returns the created VertexData
  143935. */
  143936. buildVertexData(depth?: number): VertexData;
  143937. /**
  143938. * Adds a side to the polygon
  143939. * @param positions points that make the polygon
  143940. * @param normals normals of the polygon
  143941. * @param uvs uvs of the polygon
  143942. * @param indices indices of the polygon
  143943. * @param bounds bounds of the polygon
  143944. * @param points points of the polygon
  143945. * @param depth depth of the polygon
  143946. * @param flip flip of the polygon
  143947. */
  143948. private addSide;
  143949. }
  143950. }
  143951. declare module BABYLON {
  143952. /**
  143953. * Class containing static functions to help procedurally build meshes
  143954. */
  143955. export class PolygonBuilder {
  143956. /**
  143957. * Creates a polygon mesh
  143958. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143959. * * 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
  143960. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143963. * * Remember you can only change the shape positions, not their number when updating a polygon
  143964. * @param name defines the name of the mesh
  143965. * @param options defines the options used to create the mesh
  143966. * @param scene defines the hosting scene
  143967. * @param earcutInjection can be used to inject your own earcut reference
  143968. * @returns the polygon mesh
  143969. */
  143970. static CreatePolygon(name: string, options: {
  143971. shape: Vector3[];
  143972. holes?: Vector3[][];
  143973. depth?: number;
  143974. faceUV?: Vector4[];
  143975. faceColors?: Color4[];
  143976. updatable?: boolean;
  143977. sideOrientation?: number;
  143978. frontUVs?: Vector4;
  143979. backUVs?: Vector4;
  143980. wrap?: boolean;
  143981. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143982. /**
  143983. * Creates an extruded polygon mesh, with depth in the Y direction.
  143984. * * 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)
  143985. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143986. * @param name defines the name of the mesh
  143987. * @param options defines the options used to create the mesh
  143988. * @param scene defines the hosting scene
  143989. * @param earcutInjection can be used to inject your own earcut reference
  143990. * @returns the polygon mesh
  143991. */
  143992. static ExtrudePolygon(name: string, options: {
  143993. shape: Vector3[];
  143994. holes?: Vector3[][];
  143995. depth?: number;
  143996. faceUV?: Vector4[];
  143997. faceColors?: Color4[];
  143998. updatable?: boolean;
  143999. sideOrientation?: number;
  144000. frontUVs?: Vector4;
  144001. backUVs?: Vector4;
  144002. wrap?: boolean;
  144003. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144004. }
  144005. }
  144006. declare module BABYLON {
  144007. /**
  144008. * Class containing static functions to help procedurally build meshes
  144009. */
  144010. export class LatheBuilder {
  144011. /**
  144012. * Creates lathe mesh.
  144013. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144014. * * 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
  144015. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144016. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144017. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144018. * * 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
  144019. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144020. * * 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
  144021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144023. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144025. * @param name defines the name of the mesh
  144026. * @param options defines the options used to create the mesh
  144027. * @param scene defines the hosting scene
  144028. * @returns the lathe mesh
  144029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144030. */
  144031. static CreateLathe(name: string, options: {
  144032. shape: Vector3[];
  144033. radius?: number;
  144034. tessellation?: number;
  144035. clip?: number;
  144036. arc?: number;
  144037. closed?: boolean;
  144038. updatable?: boolean;
  144039. sideOrientation?: number;
  144040. frontUVs?: Vector4;
  144041. backUVs?: Vector4;
  144042. cap?: number;
  144043. invertUV?: boolean;
  144044. }, scene?: Nullable<Scene>): Mesh;
  144045. }
  144046. }
  144047. declare module BABYLON {
  144048. /**
  144049. * Class containing static functions to help procedurally build meshes
  144050. */
  144051. export class TiledPlaneBuilder {
  144052. /**
  144053. * Creates a tiled plane mesh
  144054. * * The parameter `pattern` will, depending on value, do nothing or
  144055. * * * flip (reflect about central vertical) alternate tiles across and up
  144056. * * * flip every tile on alternate rows
  144057. * * * rotate (180 degs) alternate tiles across and up
  144058. * * * rotate every tile on alternate rows
  144059. * * * flip and rotate alternate tiles across and up
  144060. * * * flip and rotate every tile on alternate rows
  144061. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  144062. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  144063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144064. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144065. * * 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)
  144066. * * 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)
  144067. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144068. * @param name defines the name of the mesh
  144069. * @param options defines the options used to create the mesh
  144070. * @param scene defines the hosting scene
  144071. * @returns the box mesh
  144072. */
  144073. static CreateTiledPlane(name: string, options: {
  144074. pattern?: number;
  144075. tileSize?: number;
  144076. tileWidth?: number;
  144077. tileHeight?: number;
  144078. size?: number;
  144079. width?: number;
  144080. height?: number;
  144081. alignHorizontal?: number;
  144082. alignVertical?: number;
  144083. sideOrientation?: number;
  144084. frontUVs?: Vector4;
  144085. backUVs?: Vector4;
  144086. updatable?: boolean;
  144087. }, scene?: Nullable<Scene>): Mesh;
  144088. }
  144089. }
  144090. declare module BABYLON {
  144091. /**
  144092. * Class containing static functions to help procedurally build meshes
  144093. */
  144094. export class TubeBuilder {
  144095. /**
  144096. * Creates a tube mesh.
  144097. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144098. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144099. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144100. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144101. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144102. * * 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)
  144103. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144104. * * 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
  144105. * * 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
  144106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144108. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144110. * @param name defines the name of the mesh
  144111. * @param options defines the options used to create the mesh
  144112. * @param scene defines the hosting scene
  144113. * @returns the tube mesh
  144114. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144115. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144116. */
  144117. static CreateTube(name: string, options: {
  144118. path: Vector3[];
  144119. radius?: number;
  144120. tessellation?: number;
  144121. radiusFunction?: {
  144122. (i: number, distance: number): number;
  144123. };
  144124. cap?: number;
  144125. arc?: number;
  144126. updatable?: boolean;
  144127. sideOrientation?: number;
  144128. frontUVs?: Vector4;
  144129. backUVs?: Vector4;
  144130. instance?: Mesh;
  144131. invertUV?: boolean;
  144132. }, scene?: Nullable<Scene>): Mesh;
  144133. }
  144134. }
  144135. declare module BABYLON {
  144136. /**
  144137. * Class containing static functions to help procedurally build meshes
  144138. */
  144139. export class IcoSphereBuilder {
  144140. /**
  144141. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144142. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144143. * * 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`)
  144144. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144145. * * 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
  144146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144149. * @param name defines the name of the mesh
  144150. * @param options defines the options used to create the mesh
  144151. * @param scene defines the hosting scene
  144152. * @returns the icosahedron mesh
  144153. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144154. */
  144155. static CreateIcoSphere(name: string, options: {
  144156. radius?: number;
  144157. radiusX?: number;
  144158. radiusY?: number;
  144159. radiusZ?: number;
  144160. flat?: boolean;
  144161. subdivisions?: number;
  144162. sideOrientation?: number;
  144163. frontUVs?: Vector4;
  144164. backUVs?: Vector4;
  144165. updatable?: boolean;
  144166. }, scene?: Nullable<Scene>): Mesh;
  144167. }
  144168. }
  144169. declare module BABYLON {
  144170. /**
  144171. * Class containing static functions to help procedurally build meshes
  144172. */
  144173. export class DecalBuilder {
  144174. /**
  144175. * Creates a decal mesh.
  144176. * 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
  144177. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144178. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144179. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144180. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144181. * @param name defines the name of the mesh
  144182. * @param sourceMesh defines the mesh where the decal must be applied
  144183. * @param options defines the options used to create the mesh
  144184. * @param scene defines the hosting scene
  144185. * @returns the decal mesh
  144186. * @see https://doc.babylonjs.com/how_to/decals
  144187. */
  144188. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144189. position?: Vector3;
  144190. normal?: Vector3;
  144191. size?: Vector3;
  144192. angle?: number;
  144193. }): Mesh;
  144194. }
  144195. }
  144196. declare module BABYLON {
  144197. /**
  144198. * Class containing static functions to help procedurally build meshes
  144199. */
  144200. export class MeshBuilder {
  144201. /**
  144202. * Creates a box mesh
  144203. * * The parameter `size` sets the size (float) of each box side (default 1)
  144204. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  144205. * * 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)
  144206. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144210. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144211. * @param name defines the name of the mesh
  144212. * @param options defines the options used to create the mesh
  144213. * @param scene defines the hosting scene
  144214. * @returns the box mesh
  144215. */
  144216. static CreateBox(name: string, options: {
  144217. size?: number;
  144218. width?: number;
  144219. height?: number;
  144220. depth?: number;
  144221. faceUV?: Vector4[];
  144222. faceColors?: Color4[];
  144223. sideOrientation?: number;
  144224. frontUVs?: Vector4;
  144225. backUVs?: Vector4;
  144226. wrap?: boolean;
  144227. topBaseAt?: number;
  144228. bottomBaseAt?: number;
  144229. updatable?: boolean;
  144230. }, scene?: Nullable<Scene>): Mesh;
  144231. /**
  144232. * Creates a tiled box mesh
  144233. * * faceTiles sets the pattern, tile size and number of tiles for a face
  144234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144235. * @param name defines the name of the mesh
  144236. * @param options defines the options used to create the mesh
  144237. * @param scene defines the hosting scene
  144238. * @returns the tiled box mesh
  144239. */
  144240. static CreateTiledBox(name: string, options: {
  144241. pattern?: number;
  144242. size?: number;
  144243. width?: number;
  144244. height?: number;
  144245. depth: number;
  144246. tileSize?: number;
  144247. tileWidth?: number;
  144248. tileHeight?: number;
  144249. faceUV?: Vector4[];
  144250. faceColors?: Color4[];
  144251. alignHorizontal?: number;
  144252. alignVertical?: number;
  144253. sideOrientation?: number;
  144254. updatable?: boolean;
  144255. }, scene?: Nullable<Scene>): Mesh;
  144256. /**
  144257. * Creates a sphere mesh
  144258. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  144259. * * 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`)
  144260. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  144261. * * 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
  144262. * * 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)
  144263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144266. * @param name defines the name of the mesh
  144267. * @param options defines the options used to create the mesh
  144268. * @param scene defines the hosting scene
  144269. * @returns the sphere mesh
  144270. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  144271. */
  144272. static CreateSphere(name: string, options: {
  144273. segments?: number;
  144274. diameter?: number;
  144275. diameterX?: number;
  144276. diameterY?: number;
  144277. diameterZ?: number;
  144278. arc?: number;
  144279. slice?: number;
  144280. sideOrientation?: number;
  144281. frontUVs?: Vector4;
  144282. backUVs?: Vector4;
  144283. updatable?: boolean;
  144284. }, scene?: Nullable<Scene>): Mesh;
  144285. /**
  144286. * Creates a plane polygonal mesh. By default, this is a disc
  144287. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  144288. * * 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
  144289. * * 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
  144290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144293. * @param name defines the name of the mesh
  144294. * @param options defines the options used to create the mesh
  144295. * @param scene defines the hosting scene
  144296. * @returns the plane polygonal mesh
  144297. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  144298. */
  144299. static CreateDisc(name: string, options: {
  144300. radius?: number;
  144301. tessellation?: number;
  144302. arc?: number;
  144303. updatable?: boolean;
  144304. sideOrientation?: number;
  144305. frontUVs?: Vector4;
  144306. backUVs?: Vector4;
  144307. }, scene?: Nullable<Scene>): Mesh;
  144308. /**
  144309. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144310. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144311. * * 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`)
  144312. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144313. * * 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
  144314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144317. * @param name defines the name of the mesh
  144318. * @param options defines the options used to create the mesh
  144319. * @param scene defines the hosting scene
  144320. * @returns the icosahedron mesh
  144321. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144322. */
  144323. static CreateIcoSphere(name: string, options: {
  144324. radius?: number;
  144325. radiusX?: number;
  144326. radiusY?: number;
  144327. radiusZ?: number;
  144328. flat?: boolean;
  144329. subdivisions?: number;
  144330. sideOrientation?: number;
  144331. frontUVs?: Vector4;
  144332. backUVs?: Vector4;
  144333. updatable?: boolean;
  144334. }, scene?: Nullable<Scene>): Mesh;
  144335. /**
  144336. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144337. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144338. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144339. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144340. * * 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
  144341. * * 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
  144342. * * 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
  144343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144346. * * 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
  144347. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144348. * * 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
  144349. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144351. * @param name defines the name of the mesh
  144352. * @param options defines the options used to create the mesh
  144353. * @param scene defines the hosting scene
  144354. * @returns the ribbon mesh
  144355. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  144356. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144357. */
  144358. static CreateRibbon(name: string, options: {
  144359. pathArray: Vector3[][];
  144360. closeArray?: boolean;
  144361. closePath?: boolean;
  144362. offset?: number;
  144363. updatable?: boolean;
  144364. sideOrientation?: number;
  144365. frontUVs?: Vector4;
  144366. backUVs?: Vector4;
  144367. instance?: Mesh;
  144368. invertUV?: boolean;
  144369. uvs?: Vector2[];
  144370. colors?: Color4[];
  144371. }, scene?: Nullable<Scene>): Mesh;
  144372. /**
  144373. * Creates a cylinder or a cone mesh
  144374. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  144375. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  144376. * * 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.
  144377. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  144378. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  144379. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  144380. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  144381. * * 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).
  144382. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  144383. * * 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).
  144384. * * 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
  144385. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  144386. * * 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
  144387. * * 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.
  144388. * * If `enclose` is false, a ring surface is one element.
  144389. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  144390. * * 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
  144391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144394. * @param name defines the name of the mesh
  144395. * @param options defines the options used to create the mesh
  144396. * @param scene defines the hosting scene
  144397. * @returns the cylinder mesh
  144398. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  144399. */
  144400. static CreateCylinder(name: string, options: {
  144401. height?: number;
  144402. diameterTop?: number;
  144403. diameterBottom?: number;
  144404. diameter?: number;
  144405. tessellation?: number;
  144406. subdivisions?: number;
  144407. arc?: number;
  144408. faceColors?: Color4[];
  144409. faceUV?: Vector4[];
  144410. updatable?: boolean;
  144411. hasRings?: boolean;
  144412. enclose?: boolean;
  144413. cap?: number;
  144414. sideOrientation?: number;
  144415. frontUVs?: Vector4;
  144416. backUVs?: Vector4;
  144417. }, scene?: Nullable<Scene>): Mesh;
  144418. /**
  144419. * Creates a torus mesh
  144420. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  144421. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  144422. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  144423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144426. * @param name defines the name of the mesh
  144427. * @param options defines the options used to create the mesh
  144428. * @param scene defines the hosting scene
  144429. * @returns the torus mesh
  144430. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  144431. */
  144432. static CreateTorus(name: string, options: {
  144433. diameter?: number;
  144434. thickness?: number;
  144435. tessellation?: number;
  144436. updatable?: boolean;
  144437. sideOrientation?: number;
  144438. frontUVs?: Vector4;
  144439. backUVs?: Vector4;
  144440. }, scene?: Nullable<Scene>): Mesh;
  144441. /**
  144442. * Creates a torus knot mesh
  144443. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144444. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144445. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144446. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144450. * @param name defines the name of the mesh
  144451. * @param options defines the options used to create the mesh
  144452. * @param scene defines the hosting scene
  144453. * @returns the torus knot mesh
  144454. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144455. */
  144456. static CreateTorusKnot(name: string, options: {
  144457. radius?: number;
  144458. tube?: number;
  144459. radialSegments?: number;
  144460. tubularSegments?: number;
  144461. p?: number;
  144462. q?: number;
  144463. updatable?: boolean;
  144464. sideOrientation?: number;
  144465. frontUVs?: Vector4;
  144466. backUVs?: Vector4;
  144467. }, scene?: Nullable<Scene>): Mesh;
  144468. /**
  144469. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  144470. * * 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
  144471. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  144472. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  144473. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  144474. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  144475. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  144476. * * 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
  144477. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  144478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  144480. * @param name defines the name of the new line system
  144481. * @param options defines the options used to create the line system
  144482. * @param scene defines the hosting scene
  144483. * @returns a new line system mesh
  144484. */
  144485. static CreateLineSystem(name: string, options: {
  144486. lines: Vector3[][];
  144487. updatable?: boolean;
  144488. instance?: Nullable<LinesMesh>;
  144489. colors?: Nullable<Color4[][]>;
  144490. useVertexAlpha?: boolean;
  144491. }, scene: Nullable<Scene>): LinesMesh;
  144492. /**
  144493. * Creates a line mesh
  144494. * 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
  144495. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144496. * * The parameter `points` is an array successive Vector3
  144497. * * 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
  144498. * * The optional parameter `colors` is an array of successive Color4, one per line point
  144499. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  144500. * * When updating an instance, remember that only point positions can change, not the number of points
  144501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  144503. * @param name defines the name of the new line system
  144504. * @param options defines the options used to create the line system
  144505. * @param scene defines the hosting scene
  144506. * @returns a new line mesh
  144507. */
  144508. static CreateLines(name: string, options: {
  144509. points: Vector3[];
  144510. updatable?: boolean;
  144511. instance?: Nullable<LinesMesh>;
  144512. colors?: Color4[];
  144513. useVertexAlpha?: boolean;
  144514. }, scene?: Nullable<Scene>): LinesMesh;
  144515. /**
  144516. * Creates a dashed line mesh
  144517. * * 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
  144518. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144519. * * The parameter `points` is an array successive Vector3
  144520. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  144521. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  144522. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  144523. * * 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
  144524. * * When updating an instance, remember that only point positions can change, not the number of points
  144525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144526. * @param name defines the name of the mesh
  144527. * @param options defines the options used to create the mesh
  144528. * @param scene defines the hosting scene
  144529. * @returns the dashed line mesh
  144530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  144531. */
  144532. static CreateDashedLines(name: string, options: {
  144533. points: Vector3[];
  144534. dashSize?: number;
  144535. gapSize?: number;
  144536. dashNb?: number;
  144537. updatable?: boolean;
  144538. instance?: LinesMesh;
  144539. }, scene?: Nullable<Scene>): LinesMesh;
  144540. /**
  144541. * 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.
  144542. * * 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.
  144543. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144544. * * 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.
  144545. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  144546. * * 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
  144547. * * 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
  144548. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  144549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  144552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144553. * @param name defines the name of the mesh
  144554. * @param options defines the options used to create the mesh
  144555. * @param scene defines the hosting scene
  144556. * @returns the extruded shape mesh
  144557. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144559. */
  144560. static ExtrudeShape(name: string, options: {
  144561. shape: Vector3[];
  144562. path: Vector3[];
  144563. scale?: number;
  144564. rotation?: number;
  144565. cap?: number;
  144566. updatable?: boolean;
  144567. sideOrientation?: number;
  144568. frontUVs?: Vector4;
  144569. backUVs?: Vector4;
  144570. instance?: Mesh;
  144571. invertUV?: boolean;
  144572. }, scene?: Nullable<Scene>): Mesh;
  144573. /**
  144574. * Creates an custom extruded shape mesh.
  144575. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  144576. * * 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.
  144577. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144578. * * 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
  144579. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  144580. * * 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
  144581. * * It must returns a float value that will be the scale value applied to the shape on each path point
  144582. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  144583. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  144584. * * 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
  144585. * * 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
  144586. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  144587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144589. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144591. * @param name defines the name of the mesh
  144592. * @param options defines the options used to create the mesh
  144593. * @param scene defines the hosting scene
  144594. * @returns the custom extruded shape mesh
  144595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  144596. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144598. */
  144599. static ExtrudeShapeCustom(name: string, options: {
  144600. shape: Vector3[];
  144601. path: Vector3[];
  144602. scaleFunction?: any;
  144603. rotationFunction?: any;
  144604. ribbonCloseArray?: boolean;
  144605. ribbonClosePath?: boolean;
  144606. cap?: number;
  144607. updatable?: boolean;
  144608. sideOrientation?: number;
  144609. frontUVs?: Vector4;
  144610. backUVs?: Vector4;
  144611. instance?: Mesh;
  144612. invertUV?: boolean;
  144613. }, scene?: Nullable<Scene>): Mesh;
  144614. /**
  144615. * Creates lathe mesh.
  144616. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144617. * * 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
  144618. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144619. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144620. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144621. * * 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
  144622. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144623. * * 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
  144624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144626. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144628. * @param name defines the name of the mesh
  144629. * @param options defines the options used to create the mesh
  144630. * @param scene defines the hosting scene
  144631. * @returns the lathe mesh
  144632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144633. */
  144634. static CreateLathe(name: string, options: {
  144635. shape: Vector3[];
  144636. radius?: number;
  144637. tessellation?: number;
  144638. clip?: number;
  144639. arc?: number;
  144640. closed?: boolean;
  144641. updatable?: boolean;
  144642. sideOrientation?: number;
  144643. frontUVs?: Vector4;
  144644. backUVs?: Vector4;
  144645. cap?: number;
  144646. invertUV?: boolean;
  144647. }, scene?: Nullable<Scene>): Mesh;
  144648. /**
  144649. * Creates a tiled plane mesh
  144650. * * You can set a limited pattern arrangement with the tiles
  144651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144654. * @param name defines the name of the mesh
  144655. * @param options defines the options used to create the mesh
  144656. * @param scene defines the hosting scene
  144657. * @returns the plane mesh
  144658. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144659. */
  144660. static CreateTiledPlane(name: string, options: {
  144661. pattern?: number;
  144662. tileSize?: number;
  144663. tileWidth?: number;
  144664. tileHeight?: number;
  144665. size?: number;
  144666. width?: number;
  144667. height?: number;
  144668. alignHorizontal?: number;
  144669. alignVertical?: number;
  144670. sideOrientation?: number;
  144671. frontUVs?: Vector4;
  144672. backUVs?: Vector4;
  144673. updatable?: boolean;
  144674. }, scene?: Nullable<Scene>): Mesh;
  144675. /**
  144676. * Creates a plane mesh
  144677. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  144678. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  144679. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  144680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144683. * @param name defines the name of the mesh
  144684. * @param options defines the options used to create the mesh
  144685. * @param scene defines the hosting scene
  144686. * @returns the plane mesh
  144687. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144688. */
  144689. static CreatePlane(name: string, options: {
  144690. size?: number;
  144691. width?: number;
  144692. height?: number;
  144693. sideOrientation?: number;
  144694. frontUVs?: Vector4;
  144695. backUVs?: Vector4;
  144696. updatable?: boolean;
  144697. sourcePlane?: Plane;
  144698. }, scene?: Nullable<Scene>): Mesh;
  144699. /**
  144700. * Creates a ground mesh
  144701. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  144702. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  144703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144704. * @param name defines the name of the mesh
  144705. * @param options defines the options used to create the mesh
  144706. * @param scene defines the hosting scene
  144707. * @returns the ground mesh
  144708. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  144709. */
  144710. static CreateGround(name: string, options: {
  144711. width?: number;
  144712. height?: number;
  144713. subdivisions?: number;
  144714. subdivisionsX?: number;
  144715. subdivisionsY?: number;
  144716. updatable?: boolean;
  144717. }, scene?: Nullable<Scene>): Mesh;
  144718. /**
  144719. * Creates a tiled ground mesh
  144720. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  144721. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  144722. * * 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
  144723. * * 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
  144724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144725. * @param name defines the name of the mesh
  144726. * @param options defines the options used to create the mesh
  144727. * @param scene defines the hosting scene
  144728. * @returns the tiled ground mesh
  144729. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  144730. */
  144731. static CreateTiledGround(name: string, options: {
  144732. xmin: number;
  144733. zmin: number;
  144734. xmax: number;
  144735. zmax: number;
  144736. subdivisions?: {
  144737. w: number;
  144738. h: number;
  144739. };
  144740. precision?: {
  144741. w: number;
  144742. h: number;
  144743. };
  144744. updatable?: boolean;
  144745. }, scene?: Nullable<Scene>): Mesh;
  144746. /**
  144747. * Creates a ground mesh from a height map
  144748. * * The parameter `url` sets the URL of the height map image resource.
  144749. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  144750. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  144751. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  144752. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  144753. * * 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.
  144754. * * 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).
  144755. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  144756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144757. * @param name defines the name of the mesh
  144758. * @param url defines the url to the height map
  144759. * @param options defines the options used to create the mesh
  144760. * @param scene defines the hosting scene
  144761. * @returns the ground mesh
  144762. * @see https://doc.babylonjs.com/babylon101/height_map
  144763. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  144764. */
  144765. static CreateGroundFromHeightMap(name: string, url: string, options: {
  144766. width?: number;
  144767. height?: number;
  144768. subdivisions?: number;
  144769. minHeight?: number;
  144770. maxHeight?: number;
  144771. colorFilter?: Color3;
  144772. alphaFilter?: number;
  144773. updatable?: boolean;
  144774. onReady?: (mesh: GroundMesh) => void;
  144775. }, scene?: Nullable<Scene>): GroundMesh;
  144776. /**
  144777. * Creates a polygon mesh
  144778. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144779. * * 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
  144780. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144783. * * Remember you can only change the shape positions, not their number when updating a polygon
  144784. * @param name defines the name of the mesh
  144785. * @param options defines the options used to create the mesh
  144786. * @param scene defines the hosting scene
  144787. * @param earcutInjection can be used to inject your own earcut reference
  144788. * @returns the polygon mesh
  144789. */
  144790. static CreatePolygon(name: string, options: {
  144791. shape: Vector3[];
  144792. holes?: Vector3[][];
  144793. depth?: number;
  144794. faceUV?: Vector4[];
  144795. faceColors?: Color4[];
  144796. updatable?: boolean;
  144797. sideOrientation?: number;
  144798. frontUVs?: Vector4;
  144799. backUVs?: Vector4;
  144800. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144801. /**
  144802. * Creates an extruded polygon mesh, with depth in the Y direction.
  144803. * * 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)
  144804. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144805. * @param name defines the name of the mesh
  144806. * @param options defines the options used to create the mesh
  144807. * @param scene defines the hosting scene
  144808. * @param earcutInjection can be used to inject your own earcut reference
  144809. * @returns the polygon mesh
  144810. */
  144811. static ExtrudePolygon(name: string, options: {
  144812. shape: Vector3[];
  144813. holes?: Vector3[][];
  144814. depth?: number;
  144815. faceUV?: Vector4[];
  144816. faceColors?: Color4[];
  144817. updatable?: boolean;
  144818. sideOrientation?: number;
  144819. frontUVs?: Vector4;
  144820. backUVs?: Vector4;
  144821. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144822. /**
  144823. * Creates a tube mesh.
  144824. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144825. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144826. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144827. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144828. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144829. * * 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)
  144830. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144831. * * 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
  144832. * * 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
  144833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144835. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144837. * @param name defines the name of the mesh
  144838. * @param options defines the options used to create the mesh
  144839. * @param scene defines the hosting scene
  144840. * @returns the tube mesh
  144841. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144842. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144843. */
  144844. static CreateTube(name: string, options: {
  144845. path: Vector3[];
  144846. radius?: number;
  144847. tessellation?: number;
  144848. radiusFunction?: {
  144849. (i: number, distance: number): number;
  144850. };
  144851. cap?: number;
  144852. arc?: number;
  144853. updatable?: boolean;
  144854. sideOrientation?: number;
  144855. frontUVs?: Vector4;
  144856. backUVs?: Vector4;
  144857. instance?: Mesh;
  144858. invertUV?: boolean;
  144859. }, scene?: Nullable<Scene>): Mesh;
  144860. /**
  144861. * Creates a polyhedron mesh
  144862. * * 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
  144863. * * The parameter `size` (positive float, default 1) sets the polygon size
  144864. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  144865. * * 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`
  144866. * * 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
  144867. * * 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)`)
  144868. * * 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
  144869. * * 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
  144870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144873. * @param name defines the name of the mesh
  144874. * @param options defines the options used to create the mesh
  144875. * @param scene defines the hosting scene
  144876. * @returns the polyhedron mesh
  144877. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  144878. */
  144879. static CreatePolyhedron(name: string, options: {
  144880. type?: number;
  144881. size?: number;
  144882. sizeX?: number;
  144883. sizeY?: number;
  144884. sizeZ?: number;
  144885. custom?: any;
  144886. faceUV?: Vector4[];
  144887. faceColors?: Color4[];
  144888. flat?: boolean;
  144889. updatable?: boolean;
  144890. sideOrientation?: number;
  144891. frontUVs?: Vector4;
  144892. backUVs?: Vector4;
  144893. }, scene?: Nullable<Scene>): Mesh;
  144894. /**
  144895. * Creates a decal mesh.
  144896. * 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
  144897. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144898. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144899. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144900. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144901. * @param name defines the name of the mesh
  144902. * @param sourceMesh defines the mesh where the decal must be applied
  144903. * @param options defines the options used to create the mesh
  144904. * @param scene defines the hosting scene
  144905. * @returns the decal mesh
  144906. * @see https://doc.babylonjs.com/how_to/decals
  144907. */
  144908. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144909. position?: Vector3;
  144910. normal?: Vector3;
  144911. size?: Vector3;
  144912. angle?: number;
  144913. }): Mesh;
  144914. }
  144915. }
  144916. declare module BABYLON {
  144917. /**
  144918. * A simplifier interface for future simplification implementations
  144919. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144920. */
  144921. export interface ISimplifier {
  144922. /**
  144923. * Simplification of a given mesh according to the given settings.
  144924. * Since this requires computation, it is assumed that the function runs async.
  144925. * @param settings The settings of the simplification, including quality and distance
  144926. * @param successCallback A callback that will be called after the mesh was simplified.
  144927. * @param errorCallback in case of an error, this callback will be called. optional.
  144928. */
  144929. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  144930. }
  144931. /**
  144932. * Expected simplification settings.
  144933. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  144934. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144935. */
  144936. export interface ISimplificationSettings {
  144937. /**
  144938. * Gets or sets the expected quality
  144939. */
  144940. quality: number;
  144941. /**
  144942. * Gets or sets the distance when this optimized version should be used
  144943. */
  144944. distance: number;
  144945. /**
  144946. * Gets an already optimized mesh
  144947. */
  144948. optimizeMesh?: boolean;
  144949. }
  144950. /**
  144951. * Class used to specify simplification options
  144952. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144953. */
  144954. export class SimplificationSettings implements ISimplificationSettings {
  144955. /** expected quality */
  144956. quality: number;
  144957. /** distance when this optimized version should be used */
  144958. distance: number;
  144959. /** already optimized mesh */
  144960. optimizeMesh?: boolean | undefined;
  144961. /**
  144962. * Creates a SimplificationSettings
  144963. * @param quality expected quality
  144964. * @param distance distance when this optimized version should be used
  144965. * @param optimizeMesh already optimized mesh
  144966. */
  144967. constructor(
  144968. /** expected quality */
  144969. quality: number,
  144970. /** distance when this optimized version should be used */
  144971. distance: number,
  144972. /** already optimized mesh */
  144973. optimizeMesh?: boolean | undefined);
  144974. }
  144975. /**
  144976. * Interface used to define a simplification task
  144977. */
  144978. export interface ISimplificationTask {
  144979. /**
  144980. * Array of settings
  144981. */
  144982. settings: Array<ISimplificationSettings>;
  144983. /**
  144984. * Simplification type
  144985. */
  144986. simplificationType: SimplificationType;
  144987. /**
  144988. * Mesh to simplify
  144989. */
  144990. mesh: Mesh;
  144991. /**
  144992. * Callback called on success
  144993. */
  144994. successCallback?: () => void;
  144995. /**
  144996. * Defines if parallel processing can be used
  144997. */
  144998. parallelProcessing: boolean;
  144999. }
  145000. /**
  145001. * Queue used to order the simplification tasks
  145002. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145003. */
  145004. export class SimplificationQueue {
  145005. private _simplificationArray;
  145006. /**
  145007. * Gets a boolean indicating that the process is still running
  145008. */
  145009. running: boolean;
  145010. /**
  145011. * Creates a new queue
  145012. */
  145013. constructor();
  145014. /**
  145015. * Adds a new simplification task
  145016. * @param task defines a task to add
  145017. */
  145018. addTask(task: ISimplificationTask): void;
  145019. /**
  145020. * Execute next task
  145021. */
  145022. executeNext(): void;
  145023. /**
  145024. * Execute a simplification task
  145025. * @param task defines the task to run
  145026. */
  145027. runSimplification(task: ISimplificationTask): void;
  145028. private getSimplifier;
  145029. }
  145030. /**
  145031. * The implemented types of simplification
  145032. * At the moment only Quadratic Error Decimation is implemented
  145033. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145034. */
  145035. export enum SimplificationType {
  145036. /** Quadratic error decimation */
  145037. QUADRATIC = 0
  145038. }
  145039. /**
  145040. * An implementation of the Quadratic Error simplification algorithm.
  145041. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  145042. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  145043. * @author RaananW
  145044. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145045. */
  145046. export class QuadraticErrorSimplification implements ISimplifier {
  145047. private _mesh;
  145048. private triangles;
  145049. private vertices;
  145050. private references;
  145051. private _reconstructedMesh;
  145052. /** Gets or sets the number pf sync interations */
  145053. syncIterations: number;
  145054. /** Gets or sets the aggressiveness of the simplifier */
  145055. aggressiveness: number;
  145056. /** Gets or sets the number of allowed iterations for decimation */
  145057. decimationIterations: number;
  145058. /** Gets or sets the espilon to use for bounding box computation */
  145059. boundingBoxEpsilon: number;
  145060. /**
  145061. * Creates a new QuadraticErrorSimplification
  145062. * @param _mesh defines the target mesh
  145063. */
  145064. constructor(_mesh: Mesh);
  145065. /**
  145066. * Simplification of a given mesh according to the given settings.
  145067. * Since this requires computation, it is assumed that the function runs async.
  145068. * @param settings The settings of the simplification, including quality and distance
  145069. * @param successCallback A callback that will be called after the mesh was simplified.
  145070. */
  145071. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  145072. private runDecimation;
  145073. private initWithMesh;
  145074. private init;
  145075. private reconstructMesh;
  145076. private initDecimatedMesh;
  145077. private isFlipped;
  145078. private updateTriangles;
  145079. private identifyBorder;
  145080. private updateMesh;
  145081. private vertexError;
  145082. private calculateError;
  145083. }
  145084. }
  145085. declare module BABYLON {
  145086. interface Scene {
  145087. /** @hidden (Backing field) */
  145088. _simplificationQueue: SimplificationQueue;
  145089. /**
  145090. * Gets or sets the simplification queue attached to the scene
  145091. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145092. */
  145093. simplificationQueue: SimplificationQueue;
  145094. }
  145095. interface Mesh {
  145096. /**
  145097. * Simplify the mesh according to the given array of settings.
  145098. * Function will return immediately and will simplify async
  145099. * @param settings a collection of simplification settings
  145100. * @param parallelProcessing should all levels calculate parallel or one after the other
  145101. * @param simplificationType the type of simplification to run
  145102. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  145103. * @returns the current mesh
  145104. */
  145105. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  145106. }
  145107. /**
  145108. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  145109. * created in a scene
  145110. */
  145111. export class SimplicationQueueSceneComponent implements ISceneComponent {
  145112. /**
  145113. * The component name helpfull to identify the component in the list of scene components.
  145114. */
  145115. readonly name: string;
  145116. /**
  145117. * The scene the component belongs to.
  145118. */
  145119. scene: Scene;
  145120. /**
  145121. * Creates a new instance of the component for the given scene
  145122. * @param scene Defines the scene to register the component in
  145123. */
  145124. constructor(scene: Scene);
  145125. /**
  145126. * Registers the component in a given scene
  145127. */
  145128. register(): void;
  145129. /**
  145130. * Rebuilds the elements related to this component in case of
  145131. * context lost for instance.
  145132. */
  145133. rebuild(): void;
  145134. /**
  145135. * Disposes the component and the associated ressources
  145136. */
  145137. dispose(): void;
  145138. private _beforeCameraUpdate;
  145139. }
  145140. }
  145141. declare module BABYLON {
  145142. interface Mesh {
  145143. /**
  145144. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  145145. */
  145146. thinInstanceEnablePicking: boolean;
  145147. /**
  145148. * Creates a new thin instance
  145149. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  145150. * @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
  145151. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  145152. */
  145153. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  145154. /**
  145155. * Adds the transformation (matrix) of the current mesh as a thin instance
  145156. * @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
  145157. * @returns the thin instance index number
  145158. */
  145159. thinInstanceAddSelf(refresh: boolean): number;
  145160. /**
  145161. * Registers a custom attribute to be used with thin instances
  145162. * @param kind name of the attribute
  145163. * @param stride size in floats of the attribute
  145164. */
  145165. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  145166. /**
  145167. * Sets the matrix of a thin instance
  145168. * @param index index of the thin instance
  145169. * @param matrix matrix to set
  145170. * @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
  145171. */
  145172. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  145173. /**
  145174. * Sets the value of a custom attribute for a thin instance
  145175. * @param kind name of the attribute
  145176. * @param index index of the thin instance
  145177. * @param value value to set
  145178. * @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
  145179. */
  145180. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  145181. /**
  145182. * 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.
  145183. */
  145184. thinInstanceCount: number;
  145185. /**
  145186. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  145187. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  145188. * @param buffer buffer to set
  145189. * @param stride size in floats of each value of the buffer
  145190. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  145191. */
  145192. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  145193. /**
  145194. * Gets the list of world matrices
  145195. * @return an array containing all the world matrices from the thin instances
  145196. */
  145197. thinInstanceGetWorldMatrices(): Matrix[];
  145198. /**
  145199. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  145200. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  145201. */
  145202. thinInstanceBufferUpdated(kind: string): void;
  145203. /**
  145204. * Refreshes the bounding info, taking into account all the thin instances defined
  145205. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  145206. */
  145207. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  145208. /** @hidden */
  145209. _thinInstanceInitializeUserStorage(): void;
  145210. /** @hidden */
  145211. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  145212. /** @hidden */
  145213. _userThinInstanceBuffersStorage: {
  145214. data: {
  145215. [key: string]: Float32Array;
  145216. };
  145217. sizes: {
  145218. [key: string]: number;
  145219. };
  145220. vertexBuffers: {
  145221. [key: string]: Nullable<VertexBuffer>;
  145222. };
  145223. strides: {
  145224. [key: string]: number;
  145225. };
  145226. };
  145227. }
  145228. }
  145229. declare module BABYLON {
  145230. /**
  145231. * Navigation plugin interface to add navigation constrained by a navigation mesh
  145232. */
  145233. export interface INavigationEnginePlugin {
  145234. /**
  145235. * plugin name
  145236. */
  145237. name: string;
  145238. /**
  145239. * Creates a navigation mesh
  145240. * @param meshes array of all the geometry used to compute the navigatio mesh
  145241. * @param parameters bunch of parameters used to filter geometry
  145242. */
  145243. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145244. /**
  145245. * Create a navigation mesh debug mesh
  145246. * @param scene is where the mesh will be added
  145247. * @returns debug display mesh
  145248. */
  145249. createDebugNavMesh(scene: Scene): Mesh;
  145250. /**
  145251. * Get a navigation mesh constrained position, closest to the parameter position
  145252. * @param position world position
  145253. * @returns the closest point to position constrained by the navigation mesh
  145254. */
  145255. getClosestPoint(position: Vector3): Vector3;
  145256. /**
  145257. * Get a navigation mesh constrained position, closest to the parameter position
  145258. * @param position world position
  145259. * @param result output the closest point to position constrained by the navigation mesh
  145260. */
  145261. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145262. /**
  145263. * Get a navigation mesh constrained position, within a particular radius
  145264. * @param position world position
  145265. * @param maxRadius the maximum distance to the constrained world position
  145266. * @returns the closest point to position constrained by the navigation mesh
  145267. */
  145268. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145269. /**
  145270. * Get a navigation mesh constrained position, within a particular radius
  145271. * @param position world position
  145272. * @param maxRadius the maximum distance to the constrained world position
  145273. * @param result output the closest point to position constrained by the navigation mesh
  145274. */
  145275. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145276. /**
  145277. * Compute the final position from a segment made of destination-position
  145278. * @param position world position
  145279. * @param destination world position
  145280. * @returns the resulting point along the navmesh
  145281. */
  145282. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145283. /**
  145284. * Compute the final position from a segment made of destination-position
  145285. * @param position world position
  145286. * @param destination world position
  145287. * @param result output the resulting point along the navmesh
  145288. */
  145289. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145290. /**
  145291. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145292. * @param start world position
  145293. * @param end world position
  145294. * @returns array containing world position composing the path
  145295. */
  145296. computePath(start: Vector3, end: Vector3): Vector3[];
  145297. /**
  145298. * If this plugin is supported
  145299. * @returns true if plugin is supported
  145300. */
  145301. isSupported(): boolean;
  145302. /**
  145303. * Create a new Crowd so you can add agents
  145304. * @param maxAgents the maximum agent count in the crowd
  145305. * @param maxAgentRadius the maximum radius an agent can have
  145306. * @param scene to attach the crowd to
  145307. * @returns the crowd you can add agents to
  145308. */
  145309. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145310. /**
  145311. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145312. * The queries will try to find a solution within those bounds
  145313. * default is (1,1,1)
  145314. * @param extent x,y,z value that define the extent around the queries point of reference
  145315. */
  145316. setDefaultQueryExtent(extent: Vector3): void;
  145317. /**
  145318. * Get the Bounding box extent specified by setDefaultQueryExtent
  145319. * @returns the box extent values
  145320. */
  145321. getDefaultQueryExtent(): Vector3;
  145322. /**
  145323. * build the navmesh from a previously saved state using getNavmeshData
  145324. * @param data the Uint8Array returned by getNavmeshData
  145325. */
  145326. buildFromNavmeshData(data: Uint8Array): void;
  145327. /**
  145328. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145329. * @returns data the Uint8Array that can be saved and reused
  145330. */
  145331. getNavmeshData(): Uint8Array;
  145332. /**
  145333. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145334. * @param result output the box extent values
  145335. */
  145336. getDefaultQueryExtentToRef(result: Vector3): void;
  145337. /**
  145338. * Release all resources
  145339. */
  145340. dispose(): void;
  145341. }
  145342. /**
  145343. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  145344. */
  145345. export interface ICrowd {
  145346. /**
  145347. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145348. * You can attach anything to that node. The node position is updated in the scene update tick.
  145349. * @param pos world position that will be constrained by the navigation mesh
  145350. * @param parameters agent parameters
  145351. * @param transform hooked to the agent that will be update by the scene
  145352. * @returns agent index
  145353. */
  145354. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145355. /**
  145356. * Returns the agent position in world space
  145357. * @param index agent index returned by addAgent
  145358. * @returns world space position
  145359. */
  145360. getAgentPosition(index: number): Vector3;
  145361. /**
  145362. * Gets the agent position result in world space
  145363. * @param index agent index returned by addAgent
  145364. * @param result output world space position
  145365. */
  145366. getAgentPositionToRef(index: number, result: Vector3): void;
  145367. /**
  145368. * Gets the agent velocity in world space
  145369. * @param index agent index returned by addAgent
  145370. * @returns world space velocity
  145371. */
  145372. getAgentVelocity(index: number): Vector3;
  145373. /**
  145374. * Gets the agent velocity result in world space
  145375. * @param index agent index returned by addAgent
  145376. * @param result output world space velocity
  145377. */
  145378. getAgentVelocityToRef(index: number, result: Vector3): void;
  145379. /**
  145380. * remove a particular agent previously created
  145381. * @param index agent index returned by addAgent
  145382. */
  145383. removeAgent(index: number): void;
  145384. /**
  145385. * get the list of all agents attached to this crowd
  145386. * @returns list of agent indices
  145387. */
  145388. getAgents(): number[];
  145389. /**
  145390. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145391. * @param deltaTime in seconds
  145392. */
  145393. update(deltaTime: number): void;
  145394. /**
  145395. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145396. * @param index agent index returned by addAgent
  145397. * @param destination targeted world position
  145398. */
  145399. agentGoto(index: number, destination: Vector3): void;
  145400. /**
  145401. * Teleport the agent to a new position
  145402. * @param index agent index returned by addAgent
  145403. * @param destination targeted world position
  145404. */
  145405. agentTeleport(index: number, destination: Vector3): void;
  145406. /**
  145407. * Update agent parameters
  145408. * @param index agent index returned by addAgent
  145409. * @param parameters agent parameters
  145410. */
  145411. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145412. /**
  145413. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145414. * The queries will try to find a solution within those bounds
  145415. * default is (1,1,1)
  145416. * @param extent x,y,z value that define the extent around the queries point of reference
  145417. */
  145418. setDefaultQueryExtent(extent: Vector3): void;
  145419. /**
  145420. * Get the Bounding box extent specified by setDefaultQueryExtent
  145421. * @returns the box extent values
  145422. */
  145423. getDefaultQueryExtent(): Vector3;
  145424. /**
  145425. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145426. * @param result output the box extent values
  145427. */
  145428. getDefaultQueryExtentToRef(result: Vector3): void;
  145429. /**
  145430. * Release all resources
  145431. */
  145432. dispose(): void;
  145433. }
  145434. /**
  145435. * Configures an agent
  145436. */
  145437. export interface IAgentParameters {
  145438. /**
  145439. * Agent radius. [Limit: >= 0]
  145440. */
  145441. radius: number;
  145442. /**
  145443. * Agent height. [Limit: > 0]
  145444. */
  145445. height: number;
  145446. /**
  145447. * Maximum allowed acceleration. [Limit: >= 0]
  145448. */
  145449. maxAcceleration: number;
  145450. /**
  145451. * Maximum allowed speed. [Limit: >= 0]
  145452. */
  145453. maxSpeed: number;
  145454. /**
  145455. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  145456. */
  145457. collisionQueryRange: number;
  145458. /**
  145459. * The path visibility optimization range. [Limit: > 0]
  145460. */
  145461. pathOptimizationRange: number;
  145462. /**
  145463. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  145464. */
  145465. separationWeight: number;
  145466. }
  145467. /**
  145468. * Configures the navigation mesh creation
  145469. */
  145470. export interface INavMeshParameters {
  145471. /**
  145472. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  145473. */
  145474. cs: number;
  145475. /**
  145476. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  145477. */
  145478. ch: number;
  145479. /**
  145480. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  145481. */
  145482. walkableSlopeAngle: number;
  145483. /**
  145484. * Minimum floor to 'ceiling' height that will still allow the floor area to
  145485. * be considered walkable. [Limit: >= 3] [Units: vx]
  145486. */
  145487. walkableHeight: number;
  145488. /**
  145489. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  145490. */
  145491. walkableClimb: number;
  145492. /**
  145493. * The distance to erode/shrink the walkable area of the heightfield away from
  145494. * obstructions. [Limit: >=0] [Units: vx]
  145495. */
  145496. walkableRadius: number;
  145497. /**
  145498. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  145499. */
  145500. maxEdgeLen: number;
  145501. /**
  145502. * The maximum distance a simplfied contour's border edges should deviate
  145503. * the original raw contour. [Limit: >=0] [Units: vx]
  145504. */
  145505. maxSimplificationError: number;
  145506. /**
  145507. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  145508. */
  145509. minRegionArea: number;
  145510. /**
  145511. * Any regions with a span count smaller than this value will, if possible,
  145512. * be merged with larger regions. [Limit: >=0] [Units: vx]
  145513. */
  145514. mergeRegionArea: number;
  145515. /**
  145516. * The maximum number of vertices allowed for polygons generated during the
  145517. * contour to polygon conversion process. [Limit: >= 3]
  145518. */
  145519. maxVertsPerPoly: number;
  145520. /**
  145521. * Sets the sampling distance to use when generating the detail mesh.
  145522. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  145523. */
  145524. detailSampleDist: number;
  145525. /**
  145526. * The maximum distance the detail mesh surface should deviate from heightfield
  145527. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  145528. */
  145529. detailSampleMaxError: number;
  145530. }
  145531. }
  145532. declare module BABYLON {
  145533. /**
  145534. * RecastJS navigation plugin
  145535. */
  145536. export class RecastJSPlugin implements INavigationEnginePlugin {
  145537. /**
  145538. * Reference to the Recast library
  145539. */
  145540. bjsRECAST: any;
  145541. /**
  145542. * plugin name
  145543. */
  145544. name: string;
  145545. /**
  145546. * the first navmesh created. We might extend this to support multiple navmeshes
  145547. */
  145548. navMesh: any;
  145549. /**
  145550. * Initializes the recastJS plugin
  145551. * @param recastInjection can be used to inject your own recast reference
  145552. */
  145553. constructor(recastInjection?: any);
  145554. /**
  145555. * Creates a navigation mesh
  145556. * @param meshes array of all the geometry used to compute the navigatio mesh
  145557. * @param parameters bunch of parameters used to filter geometry
  145558. */
  145559. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145560. /**
  145561. * Create a navigation mesh debug mesh
  145562. * @param scene is where the mesh will be added
  145563. * @returns debug display mesh
  145564. */
  145565. createDebugNavMesh(scene: Scene): Mesh;
  145566. /**
  145567. * Get a navigation mesh constrained position, closest to the parameter position
  145568. * @param position world position
  145569. * @returns the closest point to position constrained by the navigation mesh
  145570. */
  145571. getClosestPoint(position: Vector3): Vector3;
  145572. /**
  145573. * Get a navigation mesh constrained position, closest to the parameter position
  145574. * @param position world position
  145575. * @param result output the closest point to position constrained by the navigation mesh
  145576. */
  145577. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145578. /**
  145579. * Get a navigation mesh constrained position, within a particular radius
  145580. * @param position world position
  145581. * @param maxRadius the maximum distance to the constrained world position
  145582. * @returns the closest point to position constrained by the navigation mesh
  145583. */
  145584. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145585. /**
  145586. * Get a navigation mesh constrained position, within a particular radius
  145587. * @param position world position
  145588. * @param maxRadius the maximum distance to the constrained world position
  145589. * @param result output the closest point to position constrained by the navigation mesh
  145590. */
  145591. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145592. /**
  145593. * Compute the final position from a segment made of destination-position
  145594. * @param position world position
  145595. * @param destination world position
  145596. * @returns the resulting point along the navmesh
  145597. */
  145598. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145599. /**
  145600. * Compute the final position from a segment made of destination-position
  145601. * @param position world position
  145602. * @param destination world position
  145603. * @param result output the resulting point along the navmesh
  145604. */
  145605. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145606. /**
  145607. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145608. * @param start world position
  145609. * @param end world position
  145610. * @returns array containing world position composing the path
  145611. */
  145612. computePath(start: Vector3, end: Vector3): Vector3[];
  145613. /**
  145614. * Create a new Crowd so you can add agents
  145615. * @param maxAgents the maximum agent count in the crowd
  145616. * @param maxAgentRadius the maximum radius an agent can have
  145617. * @param scene to attach the crowd to
  145618. * @returns the crowd you can add agents to
  145619. */
  145620. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145621. /**
  145622. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145623. * The queries will try to find a solution within those bounds
  145624. * default is (1,1,1)
  145625. * @param extent x,y,z value that define the extent around the queries point of reference
  145626. */
  145627. setDefaultQueryExtent(extent: Vector3): void;
  145628. /**
  145629. * Get the Bounding box extent specified by setDefaultQueryExtent
  145630. * @returns the box extent values
  145631. */
  145632. getDefaultQueryExtent(): Vector3;
  145633. /**
  145634. * build the navmesh from a previously saved state using getNavmeshData
  145635. * @param data the Uint8Array returned by getNavmeshData
  145636. */
  145637. buildFromNavmeshData(data: Uint8Array): void;
  145638. /**
  145639. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145640. * @returns data the Uint8Array that can be saved and reused
  145641. */
  145642. getNavmeshData(): Uint8Array;
  145643. /**
  145644. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145645. * @param result output the box extent values
  145646. */
  145647. getDefaultQueryExtentToRef(result: Vector3): void;
  145648. /**
  145649. * Disposes
  145650. */
  145651. dispose(): void;
  145652. /**
  145653. * If this plugin is supported
  145654. * @returns true if plugin is supported
  145655. */
  145656. isSupported(): boolean;
  145657. }
  145658. /**
  145659. * Recast detour crowd implementation
  145660. */
  145661. export class RecastJSCrowd implements ICrowd {
  145662. /**
  145663. * Recast/detour plugin
  145664. */
  145665. bjsRECASTPlugin: RecastJSPlugin;
  145666. /**
  145667. * Link to the detour crowd
  145668. */
  145669. recastCrowd: any;
  145670. /**
  145671. * One transform per agent
  145672. */
  145673. transforms: TransformNode[];
  145674. /**
  145675. * All agents created
  145676. */
  145677. agents: number[];
  145678. /**
  145679. * Link to the scene is kept to unregister the crowd from the scene
  145680. */
  145681. private _scene;
  145682. /**
  145683. * Observer for crowd updates
  145684. */
  145685. private _onBeforeAnimationsObserver;
  145686. /**
  145687. * Constructor
  145688. * @param plugin recastJS plugin
  145689. * @param maxAgents the maximum agent count in the crowd
  145690. * @param maxAgentRadius the maximum radius an agent can have
  145691. * @param scene to attach the crowd to
  145692. * @returns the crowd you can add agents to
  145693. */
  145694. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  145695. /**
  145696. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145697. * You can attach anything to that node. The node position is updated in the scene update tick.
  145698. * @param pos world position that will be constrained by the navigation mesh
  145699. * @param parameters agent parameters
  145700. * @param transform hooked to the agent that will be update by the scene
  145701. * @returns agent index
  145702. */
  145703. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145704. /**
  145705. * Returns the agent position in world space
  145706. * @param index agent index returned by addAgent
  145707. * @returns world space position
  145708. */
  145709. getAgentPosition(index: number): Vector3;
  145710. /**
  145711. * Returns the agent position result in world space
  145712. * @param index agent index returned by addAgent
  145713. * @param result output world space position
  145714. */
  145715. getAgentPositionToRef(index: number, result: Vector3): void;
  145716. /**
  145717. * Returns the agent velocity in world space
  145718. * @param index agent index returned by addAgent
  145719. * @returns world space velocity
  145720. */
  145721. getAgentVelocity(index: number): Vector3;
  145722. /**
  145723. * Returns the agent velocity result in world space
  145724. * @param index agent index returned by addAgent
  145725. * @param result output world space velocity
  145726. */
  145727. getAgentVelocityToRef(index: number, result: Vector3): void;
  145728. /**
  145729. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145730. * @param index agent index returned by addAgent
  145731. * @param destination targeted world position
  145732. */
  145733. agentGoto(index: number, destination: Vector3): void;
  145734. /**
  145735. * Teleport the agent to a new position
  145736. * @param index agent index returned by addAgent
  145737. * @param destination targeted world position
  145738. */
  145739. agentTeleport(index: number, destination: Vector3): void;
  145740. /**
  145741. * Update agent parameters
  145742. * @param index agent index returned by addAgent
  145743. * @param parameters agent parameters
  145744. */
  145745. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145746. /**
  145747. * remove a particular agent previously created
  145748. * @param index agent index returned by addAgent
  145749. */
  145750. removeAgent(index: number): void;
  145751. /**
  145752. * get the list of all agents attached to this crowd
  145753. * @returns list of agent indices
  145754. */
  145755. getAgents(): number[];
  145756. /**
  145757. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145758. * @param deltaTime in seconds
  145759. */
  145760. update(deltaTime: number): void;
  145761. /**
  145762. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145763. * The queries will try to find a solution within those bounds
  145764. * default is (1,1,1)
  145765. * @param extent x,y,z value that define the extent around the queries point of reference
  145766. */
  145767. setDefaultQueryExtent(extent: Vector3): void;
  145768. /**
  145769. * Get the Bounding box extent specified by setDefaultQueryExtent
  145770. * @returns the box extent values
  145771. */
  145772. getDefaultQueryExtent(): Vector3;
  145773. /**
  145774. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145775. * @param result output the box extent values
  145776. */
  145777. getDefaultQueryExtentToRef(result: Vector3): void;
  145778. /**
  145779. * Release all resources
  145780. */
  145781. dispose(): void;
  145782. }
  145783. }
  145784. declare module BABYLON {
  145785. /**
  145786. * Class used to enable access to IndexedDB
  145787. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  145788. */
  145789. export class Database implements IOfflineProvider {
  145790. private _callbackManifestChecked;
  145791. private _currentSceneUrl;
  145792. private _db;
  145793. private _enableSceneOffline;
  145794. private _enableTexturesOffline;
  145795. private _manifestVersionFound;
  145796. private _mustUpdateRessources;
  145797. private _hasReachedQuota;
  145798. private _isSupported;
  145799. private _idbFactory;
  145800. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  145801. private static IsUASupportingBlobStorage;
  145802. /**
  145803. * Gets a boolean indicating if Database storate is enabled (off by default)
  145804. */
  145805. static IDBStorageEnabled: boolean;
  145806. /**
  145807. * Gets a boolean indicating if scene must be saved in the database
  145808. */
  145809. get enableSceneOffline(): boolean;
  145810. /**
  145811. * Gets a boolean indicating if textures must be saved in the database
  145812. */
  145813. get enableTexturesOffline(): boolean;
  145814. /**
  145815. * Creates a new Database
  145816. * @param urlToScene defines the url to load the scene
  145817. * @param callbackManifestChecked defines the callback to use when manifest is checked
  145818. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  145819. */
  145820. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  145821. private static _ParseURL;
  145822. private static _ReturnFullUrlLocation;
  145823. private _checkManifestFile;
  145824. /**
  145825. * Open the database and make it available
  145826. * @param successCallback defines the callback to call on success
  145827. * @param errorCallback defines the callback to call on error
  145828. */
  145829. open(successCallback: () => void, errorCallback: () => void): void;
  145830. /**
  145831. * Loads an image from the database
  145832. * @param url defines the url to load from
  145833. * @param image defines the target DOM image
  145834. */
  145835. loadImage(url: string, image: HTMLImageElement): void;
  145836. private _loadImageFromDBAsync;
  145837. private _saveImageIntoDBAsync;
  145838. private _checkVersionFromDB;
  145839. private _loadVersionFromDBAsync;
  145840. private _saveVersionIntoDBAsync;
  145841. /**
  145842. * Loads a file from database
  145843. * @param url defines the URL to load from
  145844. * @param sceneLoaded defines a callback to call on success
  145845. * @param progressCallBack defines a callback to call when progress changed
  145846. * @param errorCallback defines a callback to call on error
  145847. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  145848. */
  145849. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  145850. private _loadFileAsync;
  145851. private _saveFileAsync;
  145852. /**
  145853. * Validates if xhr data is correct
  145854. * @param xhr defines the request to validate
  145855. * @param dataType defines the expected data type
  145856. * @returns true if data is correct
  145857. */
  145858. private static _ValidateXHRData;
  145859. }
  145860. }
  145861. declare module BABYLON {
  145862. /** @hidden */
  145863. export var gpuUpdateParticlesPixelShader: {
  145864. name: string;
  145865. shader: string;
  145866. };
  145867. }
  145868. declare module BABYLON {
  145869. /** @hidden */
  145870. export var gpuUpdateParticlesVertexShader: {
  145871. name: string;
  145872. shader: string;
  145873. };
  145874. }
  145875. declare module BABYLON {
  145876. /** @hidden */
  145877. export var clipPlaneFragmentDeclaration2: {
  145878. name: string;
  145879. shader: string;
  145880. };
  145881. }
  145882. declare module BABYLON {
  145883. /** @hidden */
  145884. export var gpuRenderParticlesPixelShader: {
  145885. name: string;
  145886. shader: string;
  145887. };
  145888. }
  145889. declare module BABYLON {
  145890. /** @hidden */
  145891. export var clipPlaneVertexDeclaration2: {
  145892. name: string;
  145893. shader: string;
  145894. };
  145895. }
  145896. declare module BABYLON {
  145897. /** @hidden */
  145898. export var gpuRenderParticlesVertexShader: {
  145899. name: string;
  145900. shader: string;
  145901. };
  145902. }
  145903. declare module BABYLON {
  145904. /**
  145905. * This represents a GPU particle system in Babylon
  145906. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  145907. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  145908. */
  145909. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  145910. /**
  145911. * The layer mask we are rendering the particles through.
  145912. */
  145913. layerMask: number;
  145914. private _capacity;
  145915. private _activeCount;
  145916. private _currentActiveCount;
  145917. private _accumulatedCount;
  145918. private _renderEffect;
  145919. private _updateEffect;
  145920. private _buffer0;
  145921. private _buffer1;
  145922. private _spriteBuffer;
  145923. private _updateVAO;
  145924. private _renderVAO;
  145925. private _targetIndex;
  145926. private _sourceBuffer;
  145927. private _targetBuffer;
  145928. private _engine;
  145929. private _currentRenderId;
  145930. private _started;
  145931. private _stopped;
  145932. private _timeDelta;
  145933. private _randomTexture;
  145934. private _randomTexture2;
  145935. private _attributesStrideSize;
  145936. private _updateEffectOptions;
  145937. private _randomTextureSize;
  145938. private _actualFrame;
  145939. private _customEffect;
  145940. private readonly _rawTextureWidth;
  145941. /**
  145942. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  145943. */
  145944. static get IsSupported(): boolean;
  145945. /**
  145946. * An event triggered when the system is disposed.
  145947. */
  145948. onDisposeObservable: Observable<IParticleSystem>;
  145949. /**
  145950. * Gets the maximum number of particles active at the same time.
  145951. * @returns The max number of active particles.
  145952. */
  145953. getCapacity(): number;
  145954. /**
  145955. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  145956. * to override the particles.
  145957. */
  145958. forceDepthWrite: boolean;
  145959. /**
  145960. * Gets or set the number of active particles
  145961. */
  145962. get activeParticleCount(): number;
  145963. set activeParticleCount(value: number);
  145964. private _preWarmDone;
  145965. /**
  145966. * Specifies if the particles are updated in emitter local space or world space.
  145967. */
  145968. isLocal: boolean;
  145969. /**
  145970. * Is this system ready to be used/rendered
  145971. * @return true if the system is ready
  145972. */
  145973. isReady(): boolean;
  145974. /**
  145975. * Gets if the system has been started. (Note: this will still be true after stop is called)
  145976. * @returns True if it has been started, otherwise false.
  145977. */
  145978. isStarted(): boolean;
  145979. /**
  145980. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  145981. * @returns True if it has been stopped, otherwise false.
  145982. */
  145983. isStopped(): boolean;
  145984. /**
  145985. * Gets a boolean indicating that the system is stopping
  145986. * @returns true if the system is currently stopping
  145987. */
  145988. isStopping(): boolean;
  145989. /**
  145990. * Gets the number of particles active at the same time.
  145991. * @returns The number of active particles.
  145992. */
  145993. getActiveCount(): number;
  145994. /**
  145995. * Starts the particle system and begins to emit
  145996. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  145997. */
  145998. start(delay?: number): void;
  145999. /**
  146000. * Stops the particle system.
  146001. */
  146002. stop(): void;
  146003. /**
  146004. * Remove all active particles
  146005. */
  146006. reset(): void;
  146007. /**
  146008. * Returns the string "GPUParticleSystem"
  146009. * @returns a string containing the class name
  146010. */
  146011. getClassName(): string;
  146012. /**
  146013. * Gets the custom effect used to render the particles
  146014. * @param blendMode Blend mode for which the effect should be retrieved
  146015. * @returns The effect
  146016. */
  146017. getCustomEffect(blendMode?: number): Nullable<Effect>;
  146018. /**
  146019. * Sets the custom effect used to render the particles
  146020. * @param effect The effect to set
  146021. * @param blendMode Blend mode for which the effect should be set
  146022. */
  146023. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  146024. /** @hidden */
  146025. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  146026. /**
  146027. * Observable that will be called just before the particles are drawn
  146028. */
  146029. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  146030. /**
  146031. * Gets the name of the particle vertex shader
  146032. */
  146033. get vertexShaderName(): string;
  146034. private _colorGradientsTexture;
  146035. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  146036. /**
  146037. * Adds a new color gradient
  146038. * @param gradient defines the gradient to use (between 0 and 1)
  146039. * @param color1 defines the color to affect to the specified gradient
  146040. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  146041. * @returns the current particle system
  146042. */
  146043. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  146044. private _refreshColorGradient;
  146045. /** Force the system to rebuild all gradients that need to be resync */
  146046. forceRefreshGradients(): void;
  146047. /**
  146048. * Remove a specific color gradient
  146049. * @param gradient defines the gradient to remove
  146050. * @returns the current particle system
  146051. */
  146052. removeColorGradient(gradient: number): GPUParticleSystem;
  146053. private _angularSpeedGradientsTexture;
  146054. private _sizeGradientsTexture;
  146055. private _velocityGradientsTexture;
  146056. private _limitVelocityGradientsTexture;
  146057. private _dragGradientsTexture;
  146058. private _addFactorGradient;
  146059. /**
  146060. * Adds a new size gradient
  146061. * @param gradient defines the gradient to use (between 0 and 1)
  146062. * @param factor defines the size factor to affect to the specified gradient
  146063. * @returns the current particle system
  146064. */
  146065. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  146066. /**
  146067. * Remove a specific size gradient
  146068. * @param gradient defines the gradient to remove
  146069. * @returns the current particle system
  146070. */
  146071. removeSizeGradient(gradient: number): GPUParticleSystem;
  146072. private _refreshFactorGradient;
  146073. /**
  146074. * Adds a new angular speed gradient
  146075. * @param gradient defines the gradient to use (between 0 and 1)
  146076. * @param factor defines the angular speed to affect to the specified gradient
  146077. * @returns the current particle system
  146078. */
  146079. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  146080. /**
  146081. * Remove a specific angular speed gradient
  146082. * @param gradient defines the gradient to remove
  146083. * @returns the current particle system
  146084. */
  146085. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  146086. /**
  146087. * Adds a new velocity gradient
  146088. * @param gradient defines the gradient to use (between 0 and 1)
  146089. * @param factor defines the velocity to affect to the specified gradient
  146090. * @returns the current particle system
  146091. */
  146092. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146093. /**
  146094. * Remove a specific velocity gradient
  146095. * @param gradient defines the gradient to remove
  146096. * @returns the current particle system
  146097. */
  146098. removeVelocityGradient(gradient: number): GPUParticleSystem;
  146099. /**
  146100. * Adds a new limit velocity gradient
  146101. * @param gradient defines the gradient to use (between 0 and 1)
  146102. * @param factor defines the limit velocity value to affect to the specified gradient
  146103. * @returns the current particle system
  146104. */
  146105. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146106. /**
  146107. * Remove a specific limit velocity gradient
  146108. * @param gradient defines the gradient to remove
  146109. * @returns the current particle system
  146110. */
  146111. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  146112. /**
  146113. * Adds a new drag gradient
  146114. * @param gradient defines the gradient to use (between 0 and 1)
  146115. * @param factor defines the drag value to affect to the specified gradient
  146116. * @returns the current particle system
  146117. */
  146118. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  146119. /**
  146120. * Remove a specific drag gradient
  146121. * @param gradient defines the gradient to remove
  146122. * @returns the current particle system
  146123. */
  146124. removeDragGradient(gradient: number): GPUParticleSystem;
  146125. /**
  146126. * Not supported by GPUParticleSystem
  146127. * @param gradient defines the gradient to use (between 0 and 1)
  146128. * @param factor defines the emit rate value to affect to the specified gradient
  146129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146130. * @returns the current particle system
  146131. */
  146132. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146133. /**
  146134. * Not supported by GPUParticleSystem
  146135. * @param gradient defines the gradient to remove
  146136. * @returns the current particle system
  146137. */
  146138. removeEmitRateGradient(gradient: number): IParticleSystem;
  146139. /**
  146140. * Not supported by GPUParticleSystem
  146141. * @param gradient defines the gradient to use (between 0 and 1)
  146142. * @param factor defines the start size value to affect to the specified gradient
  146143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146144. * @returns the current particle system
  146145. */
  146146. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146147. /**
  146148. * Not supported by GPUParticleSystem
  146149. * @param gradient defines the gradient to remove
  146150. * @returns the current particle system
  146151. */
  146152. removeStartSizeGradient(gradient: number): IParticleSystem;
  146153. /**
  146154. * Not supported by GPUParticleSystem
  146155. * @param gradient defines the gradient to use (between 0 and 1)
  146156. * @param min defines the color remap minimal range
  146157. * @param max defines the color remap maximal range
  146158. * @returns the current particle system
  146159. */
  146160. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146161. /**
  146162. * Not supported by GPUParticleSystem
  146163. * @param gradient defines the gradient to remove
  146164. * @returns the current particle system
  146165. */
  146166. removeColorRemapGradient(): IParticleSystem;
  146167. /**
  146168. * Not supported by GPUParticleSystem
  146169. * @param gradient defines the gradient to use (between 0 and 1)
  146170. * @param min defines the alpha remap minimal range
  146171. * @param max defines the alpha remap maximal range
  146172. * @returns the current particle system
  146173. */
  146174. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146175. /**
  146176. * Not supported by GPUParticleSystem
  146177. * @param gradient defines the gradient to remove
  146178. * @returns the current particle system
  146179. */
  146180. removeAlphaRemapGradient(): IParticleSystem;
  146181. /**
  146182. * Not supported by GPUParticleSystem
  146183. * @param gradient defines the gradient to use (between 0 and 1)
  146184. * @param color defines the color to affect to the specified gradient
  146185. * @returns the current particle system
  146186. */
  146187. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  146188. /**
  146189. * Not supported by GPUParticleSystem
  146190. * @param gradient defines the gradient to remove
  146191. * @returns the current particle system
  146192. */
  146193. removeRampGradient(): IParticleSystem;
  146194. /**
  146195. * Not supported by GPUParticleSystem
  146196. * @returns the list of ramp gradients
  146197. */
  146198. getRampGradients(): Nullable<Array<Color3Gradient>>;
  146199. /**
  146200. * Not supported by GPUParticleSystem
  146201. * Gets or sets a boolean indicating that ramp gradients must be used
  146202. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  146203. */
  146204. get useRampGradients(): boolean;
  146205. set useRampGradients(value: boolean);
  146206. /**
  146207. * Not supported by GPUParticleSystem
  146208. * @param gradient defines the gradient to use (between 0 and 1)
  146209. * @param factor defines the life time factor to affect to the specified gradient
  146210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146211. * @returns the current particle system
  146212. */
  146213. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146214. /**
  146215. * Not supported by GPUParticleSystem
  146216. * @param gradient defines the gradient to remove
  146217. * @returns the current particle system
  146218. */
  146219. removeLifeTimeGradient(gradient: number): IParticleSystem;
  146220. /**
  146221. * Instantiates a GPU particle system.
  146222. * 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.
  146223. * @param name The name of the particle system
  146224. * @param options The options used to create the system
  146225. * @param scene The scene the particle system belongs to
  146226. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  146227. * @param customEffect a custom effect used to change the way particles are rendered by default
  146228. */
  146229. constructor(name: string, options: Partial<{
  146230. capacity: number;
  146231. randomTextureSize: number;
  146232. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  146233. protected _reset(): void;
  146234. private _createUpdateVAO;
  146235. private _createRenderVAO;
  146236. private _initialize;
  146237. /** @hidden */
  146238. _recreateUpdateEffect(): void;
  146239. private _getEffect;
  146240. /**
  146241. * Fill the defines array according to the current settings of the particle system
  146242. * @param defines Array to be updated
  146243. * @param blendMode blend mode to take into account when updating the array
  146244. */
  146245. fillDefines(defines: Array<string>, blendMode?: number): void;
  146246. /**
  146247. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  146248. * @param uniforms Uniforms array to fill
  146249. * @param attributes Attributes array to fill
  146250. * @param samplers Samplers array to fill
  146251. */
  146252. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  146253. /** @hidden */
  146254. _recreateRenderEffect(): Effect;
  146255. /**
  146256. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  146257. * @param preWarm defines if we are in the pre-warmimg phase
  146258. */
  146259. animate(preWarm?: boolean): void;
  146260. private _createFactorGradientTexture;
  146261. private _createSizeGradientTexture;
  146262. private _createAngularSpeedGradientTexture;
  146263. private _createVelocityGradientTexture;
  146264. private _createLimitVelocityGradientTexture;
  146265. private _createDragGradientTexture;
  146266. private _createColorGradientTexture;
  146267. /**
  146268. * Renders the particle system in its current state
  146269. * @param preWarm defines if the system should only update the particles but not render them
  146270. * @returns the current number of particles
  146271. */
  146272. render(preWarm?: boolean): number;
  146273. /**
  146274. * Rebuilds the particle system
  146275. */
  146276. rebuild(): void;
  146277. private _releaseBuffers;
  146278. private _releaseVAOs;
  146279. /**
  146280. * Disposes the particle system and free the associated resources
  146281. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  146282. */
  146283. dispose(disposeTexture?: boolean): void;
  146284. /**
  146285. * Clones the particle system.
  146286. * @param name The name of the cloned object
  146287. * @param newEmitter The new emitter to use
  146288. * @returns the cloned particle system
  146289. */
  146290. clone(name: string, newEmitter: any): GPUParticleSystem;
  146291. /**
  146292. * Serializes the particle system to a JSON object
  146293. * @param serializeTexture defines if the texture must be serialized as well
  146294. * @returns the JSON object
  146295. */
  146296. serialize(serializeTexture?: boolean): any;
  146297. /**
  146298. * Parses a JSON object to create a GPU particle system.
  146299. * @param parsedParticleSystem The JSON object to parse
  146300. * @param scene The scene to create the particle system in
  146301. * @param rootUrl The root url to use to load external dependencies like texture
  146302. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  146303. * @returns the parsed GPU particle system
  146304. */
  146305. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  146306. }
  146307. }
  146308. declare module BABYLON {
  146309. /**
  146310. * Represents a set of particle systems working together to create a specific effect
  146311. */
  146312. export class ParticleSystemSet implements IDisposable {
  146313. /**
  146314. * Gets or sets base Assets URL
  146315. */
  146316. static BaseAssetsUrl: string;
  146317. private _emitterCreationOptions;
  146318. private _emitterNode;
  146319. /**
  146320. * Gets the particle system list
  146321. */
  146322. systems: IParticleSystem[];
  146323. /**
  146324. * Gets the emitter node used with this set
  146325. */
  146326. get emitterNode(): Nullable<TransformNode>;
  146327. /**
  146328. * Creates a new emitter mesh as a sphere
  146329. * @param options defines the options used to create the sphere
  146330. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  146331. * @param scene defines the hosting scene
  146332. */
  146333. setEmitterAsSphere(options: {
  146334. diameter: number;
  146335. segments: number;
  146336. color: Color3;
  146337. }, renderingGroupId: number, scene: Scene): void;
  146338. /**
  146339. * Starts all particle systems of the set
  146340. * @param emitter defines an optional mesh to use as emitter for the particle systems
  146341. */
  146342. start(emitter?: AbstractMesh): void;
  146343. /**
  146344. * Release all associated resources
  146345. */
  146346. dispose(): void;
  146347. /**
  146348. * Serialize the set into a JSON compatible object
  146349. * @param serializeTexture defines if the texture must be serialized as well
  146350. * @returns a JSON compatible representation of the set
  146351. */
  146352. serialize(serializeTexture?: boolean): any;
  146353. /**
  146354. * Parse a new ParticleSystemSet from a serialized source
  146355. * @param data defines a JSON compatible representation of the set
  146356. * @param scene defines the hosting scene
  146357. * @param gpu defines if we want GPU particles or CPU particles
  146358. * @returns a new ParticleSystemSet
  146359. */
  146360. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  146361. }
  146362. }
  146363. declare module BABYLON {
  146364. /**
  146365. * This class is made for on one-liner static method to help creating particle system set.
  146366. */
  146367. export class ParticleHelper {
  146368. /**
  146369. * Gets or sets base Assets URL
  146370. */
  146371. static BaseAssetsUrl: string;
  146372. /** Define the Url to load snippets */
  146373. static SnippetUrl: string;
  146374. /**
  146375. * Create a default particle system that you can tweak
  146376. * @param emitter defines the emitter to use
  146377. * @param capacity defines the system capacity (default is 500 particles)
  146378. * @param scene defines the hosting scene
  146379. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  146380. * @returns the new Particle system
  146381. */
  146382. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  146383. /**
  146384. * This is the main static method (one-liner) of this helper to create different particle systems
  146385. * @param type This string represents the type to the particle system to create
  146386. * @param scene The scene where the particle system should live
  146387. * @param gpu If the system will use gpu
  146388. * @returns the ParticleSystemSet created
  146389. */
  146390. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  146391. /**
  146392. * Static function used to export a particle system to a ParticleSystemSet variable.
  146393. * Please note that the emitter shape is not exported
  146394. * @param systems defines the particle systems to export
  146395. * @returns the created particle system set
  146396. */
  146397. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  146398. /**
  146399. * Creates a particle system from a snippet saved in a remote file
  146400. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  146401. * @param url defines the url to load from
  146402. * @param scene defines the hosting scene
  146403. * @param gpu If the system will use gpu
  146404. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146405. * @returns a promise that will resolve to the new particle system
  146406. */
  146407. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146408. /**
  146409. * Creates a particle system from a snippet saved by the particle system editor
  146410. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  146411. * @param scene defines the hosting scene
  146412. * @param gpu If the system will use gpu
  146413. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146414. * @returns a promise that will resolve to the new particle system
  146415. */
  146416. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146417. }
  146418. }
  146419. declare module BABYLON {
  146420. interface Engine {
  146421. /**
  146422. * Create an effect to use with particle systems.
  146423. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  146424. * the particle system for which you want to create a custom effect in the last parameter
  146425. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  146426. * @param uniformsNames defines a list of attribute names
  146427. * @param samplers defines an array of string used to represent textures
  146428. * @param defines defines the string containing the defines to use to compile the shaders
  146429. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  146430. * @param onCompiled defines a function to call when the effect creation is successful
  146431. * @param onError defines a function to call when the effect creation has failed
  146432. * @param particleSystem the particle system you want to create the effect for
  146433. * @returns the new Effect
  146434. */
  146435. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  146436. }
  146437. interface Mesh {
  146438. /**
  146439. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  146440. * @returns an array of IParticleSystem
  146441. */
  146442. getEmittedParticleSystems(): IParticleSystem[];
  146443. /**
  146444. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  146445. * @returns an array of IParticleSystem
  146446. */
  146447. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  146448. }
  146449. }
  146450. declare module BABYLON {
  146451. /** Defines the 4 color options */
  146452. export enum PointColor {
  146453. /** color value */
  146454. Color = 2,
  146455. /** uv value */
  146456. UV = 1,
  146457. /** random value */
  146458. Random = 0,
  146459. /** stated value */
  146460. Stated = 3
  146461. }
  146462. /**
  146463. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  146464. * 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.
  146465. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  146466. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  146467. *
  146468. * Full documentation here : TO BE ENTERED
  146469. */
  146470. export class PointsCloudSystem implements IDisposable {
  146471. /**
  146472. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  146473. * Example : var p = SPS.particles[i];
  146474. */
  146475. particles: CloudPoint[];
  146476. /**
  146477. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  146478. */
  146479. nbParticles: number;
  146480. /**
  146481. * This a counter for your own usage. It's not set by any SPS functions.
  146482. */
  146483. counter: number;
  146484. /**
  146485. * The PCS name. This name is also given to the underlying mesh.
  146486. */
  146487. name: string;
  146488. /**
  146489. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  146490. */
  146491. mesh: Mesh;
  146492. /**
  146493. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  146494. * Please read :
  146495. */
  146496. vars: any;
  146497. /**
  146498. * @hidden
  146499. */
  146500. _size: number;
  146501. private _scene;
  146502. private _promises;
  146503. private _positions;
  146504. private _indices;
  146505. private _normals;
  146506. private _colors;
  146507. private _uvs;
  146508. private _indices32;
  146509. private _positions32;
  146510. private _colors32;
  146511. private _uvs32;
  146512. private _updatable;
  146513. private _isVisibilityBoxLocked;
  146514. private _alwaysVisible;
  146515. private _groups;
  146516. private _groupCounter;
  146517. private _computeParticleColor;
  146518. private _computeParticleTexture;
  146519. private _computeParticleRotation;
  146520. private _computeBoundingBox;
  146521. private _isReady;
  146522. /**
  146523. * Creates a PCS (Points Cloud System) object
  146524. * @param name (String) is the PCS name, this will be the underlying mesh name
  146525. * @param pointSize (number) is the size for each point
  146526. * @param scene (Scene) is the scene in which the PCS is added
  146527. * @param options defines the options of the PCS e.g.
  146528. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  146529. */
  146530. constructor(name: string, pointSize: number, scene: Scene, options?: {
  146531. updatable?: boolean;
  146532. });
  146533. /**
  146534. * Builds the PCS underlying mesh. Returns a standard Mesh.
  146535. * If no points were added to the PCS, the returned mesh is just a single point.
  146536. * @returns a promise for the created mesh
  146537. */
  146538. buildMeshAsync(): Promise<Mesh>;
  146539. /**
  146540. * @hidden
  146541. */
  146542. private _buildMesh;
  146543. private _addParticle;
  146544. private _randomUnitVector;
  146545. private _getColorIndicesForCoord;
  146546. private _setPointsColorOrUV;
  146547. private _colorFromTexture;
  146548. private _calculateDensity;
  146549. /**
  146550. * Adds points to the PCS in random positions within a unit sphere
  146551. * @param nb (positive integer) the number of particles to be created from this model
  146552. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  146553. * @returns the number of groups in the system
  146554. */
  146555. addPoints(nb: number, pointFunction?: any): number;
  146556. /**
  146557. * Adds points to the PCS from the surface of 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. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146566. /**
  146567. * Adds points to the PCS inside the model shape
  146568. * @param mesh is any Mesh object that will be used as a surface model for the points
  146569. * @param nb (positive integer) the number of particles to be created from this model
  146570. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146571. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146572. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146573. * @returns the number of groups in the system
  146574. */
  146575. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146576. /**
  146577. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  146578. * This method calls `updateParticle()` for each particle of the SPS.
  146579. * For an animated SPS, it is usually called within the render loop.
  146580. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  146581. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  146582. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  146583. * @returns the PCS.
  146584. */
  146585. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  146586. /**
  146587. * Disposes the PCS.
  146588. */
  146589. dispose(): void;
  146590. /**
  146591. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  146592. * doc :
  146593. * @returns the PCS.
  146594. */
  146595. refreshVisibleSize(): PointsCloudSystem;
  146596. /**
  146597. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  146598. * @param size the size (float) of the visibility box
  146599. * note : this doesn't lock the PCS mesh bounding box.
  146600. * doc :
  146601. */
  146602. setVisibilityBox(size: number): void;
  146603. /**
  146604. * Gets whether the PCS is always visible or not
  146605. * doc :
  146606. */
  146607. get isAlwaysVisible(): boolean;
  146608. /**
  146609. * Sets the PCS as always visible or not
  146610. * doc :
  146611. */
  146612. set isAlwaysVisible(val: boolean);
  146613. /**
  146614. * Tells to `setParticles()` to compute the particle rotations or not
  146615. * Default value : false. The PCS is faster when it's set to false
  146616. * Note : particle rotations are only applied to parent particles
  146617. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  146618. */
  146619. set computeParticleRotation(val: boolean);
  146620. /**
  146621. * Tells to `setParticles()` to compute the particle colors or not.
  146622. * Default value : true. The PCS is faster when it's set to false.
  146623. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146624. */
  146625. set computeParticleColor(val: boolean);
  146626. set computeParticleTexture(val: boolean);
  146627. /**
  146628. * Gets if `setParticles()` computes the particle colors or not.
  146629. * Default value : false. The PCS is faster when it's set to false.
  146630. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146631. */
  146632. get computeParticleColor(): boolean;
  146633. /**
  146634. * Gets if `setParticles()` computes the particle textures or not.
  146635. * Default value : false. The PCS is faster when it's set to false.
  146636. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  146637. */
  146638. get computeParticleTexture(): boolean;
  146639. /**
  146640. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  146641. */
  146642. set computeBoundingBox(val: boolean);
  146643. /**
  146644. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  146645. */
  146646. get computeBoundingBox(): boolean;
  146647. /**
  146648. * This function does nothing. It may be overwritten to set all the particle first values.
  146649. * The PCS doesn't call this function, you may have to call it by your own.
  146650. * doc :
  146651. */
  146652. initParticles(): void;
  146653. /**
  146654. * This function does nothing. It may be overwritten to recycle a particle
  146655. * The PCS doesn't call this function, you can to call it
  146656. * doc :
  146657. * @param particle The particle to recycle
  146658. * @returns the recycled particle
  146659. */
  146660. recycleParticle(particle: CloudPoint): CloudPoint;
  146661. /**
  146662. * Updates a particle : this function should be overwritten by the user.
  146663. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  146664. * doc :
  146665. * @example : just set a particle position or velocity and recycle conditions
  146666. * @param particle The particle to update
  146667. * @returns the updated particle
  146668. */
  146669. updateParticle(particle: CloudPoint): CloudPoint;
  146670. /**
  146671. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  146672. * This does nothing and may be overwritten by the user.
  146673. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146674. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146675. * @param update the boolean update value actually passed to setParticles()
  146676. */
  146677. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146678. /**
  146679. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  146680. * This will be passed three parameters.
  146681. * This does nothing and may be overwritten by the user.
  146682. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146683. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146684. * @param update the boolean update value actually passed to setParticles()
  146685. */
  146686. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146687. }
  146688. }
  146689. declare module BABYLON {
  146690. /**
  146691. * Represents one particle of a points cloud system.
  146692. */
  146693. export class CloudPoint {
  146694. /**
  146695. * particle global index
  146696. */
  146697. idx: number;
  146698. /**
  146699. * The color of the particle
  146700. */
  146701. color: Nullable<Color4>;
  146702. /**
  146703. * The world space position of the particle.
  146704. */
  146705. position: Vector3;
  146706. /**
  146707. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  146708. */
  146709. rotation: Vector3;
  146710. /**
  146711. * The world space rotation quaternion of the particle.
  146712. */
  146713. rotationQuaternion: Nullable<Quaternion>;
  146714. /**
  146715. * The uv of the particle.
  146716. */
  146717. uv: Nullable<Vector2>;
  146718. /**
  146719. * The current speed of the particle.
  146720. */
  146721. velocity: Vector3;
  146722. /**
  146723. * The pivot point in the particle local space.
  146724. */
  146725. pivot: Vector3;
  146726. /**
  146727. * Must the particle be translated from its pivot point in its local space ?
  146728. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  146729. * Default : false
  146730. */
  146731. translateFromPivot: boolean;
  146732. /**
  146733. * Index of this particle in the global "positions" array (Internal use)
  146734. * @hidden
  146735. */
  146736. _pos: number;
  146737. /**
  146738. * @hidden Index of this particle in the global "indices" array (Internal use)
  146739. */
  146740. _ind: number;
  146741. /**
  146742. * Group this particle belongs to
  146743. */
  146744. _group: PointsGroup;
  146745. /**
  146746. * Group id of this particle
  146747. */
  146748. groupId: number;
  146749. /**
  146750. * Index of the particle in its group id (Internal use)
  146751. */
  146752. idxInGroup: number;
  146753. /**
  146754. * @hidden Particle BoundingInfo object (Internal use)
  146755. */
  146756. _boundingInfo: BoundingInfo;
  146757. /**
  146758. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  146759. */
  146760. _pcs: PointsCloudSystem;
  146761. /**
  146762. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  146763. */
  146764. _stillInvisible: boolean;
  146765. /**
  146766. * @hidden Last computed particle rotation matrix
  146767. */
  146768. _rotationMatrix: number[];
  146769. /**
  146770. * Parent particle Id, if any.
  146771. * Default null.
  146772. */
  146773. parentId: Nullable<number>;
  146774. /**
  146775. * @hidden Internal global position in the PCS.
  146776. */
  146777. _globalPosition: Vector3;
  146778. /**
  146779. * Creates a Point Cloud object.
  146780. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  146781. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  146782. * @param group (PointsGroup) is the group the particle belongs to
  146783. * @param groupId (integer) is the group identifier in the PCS.
  146784. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  146785. * @param pcs defines the PCS it is associated to
  146786. */
  146787. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  146788. /**
  146789. * get point size
  146790. */
  146791. get size(): Vector3;
  146792. /**
  146793. * Set point size
  146794. */
  146795. set size(scale: Vector3);
  146796. /**
  146797. * Legacy support, changed quaternion to rotationQuaternion
  146798. */
  146799. get quaternion(): Nullable<Quaternion>;
  146800. /**
  146801. * Legacy support, changed quaternion to rotationQuaternion
  146802. */
  146803. set quaternion(q: Nullable<Quaternion>);
  146804. /**
  146805. * Returns a boolean. True if the particle intersects a mesh, else false
  146806. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  146807. * @param target is the object (point or mesh) what the intersection is computed against
  146808. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  146809. * @returns true if it intersects
  146810. */
  146811. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  146812. /**
  146813. * get the rotation matrix of the particle
  146814. * @hidden
  146815. */
  146816. getRotationMatrix(m: Matrix): void;
  146817. }
  146818. /**
  146819. * Represents a group of points in a points cloud system
  146820. * * PCS internal tool, don't use it manually.
  146821. */
  146822. export class PointsGroup {
  146823. /**
  146824. * The group id
  146825. * @hidden
  146826. */
  146827. groupID: number;
  146828. /**
  146829. * image data for group (internal use)
  146830. * @hidden
  146831. */
  146832. _groupImageData: Nullable<ArrayBufferView>;
  146833. /**
  146834. * Image Width (internal use)
  146835. * @hidden
  146836. */
  146837. _groupImgWidth: number;
  146838. /**
  146839. * Image Height (internal use)
  146840. * @hidden
  146841. */
  146842. _groupImgHeight: number;
  146843. /**
  146844. * Custom position function (internal use)
  146845. * @hidden
  146846. */
  146847. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  146848. /**
  146849. * density per facet for surface points
  146850. * @hidden
  146851. */
  146852. _groupDensity: number[];
  146853. /**
  146854. * Only when points are colored by texture carries pointer to texture list array
  146855. * @hidden
  146856. */
  146857. _textureNb: number;
  146858. /**
  146859. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  146860. * PCS internal tool, don't use it manually.
  146861. * @hidden
  146862. */
  146863. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  146864. }
  146865. }
  146866. declare module BABYLON {
  146867. interface Scene {
  146868. /** @hidden (Backing field) */
  146869. _physicsEngine: Nullable<IPhysicsEngine>;
  146870. /** @hidden */
  146871. _physicsTimeAccumulator: number;
  146872. /**
  146873. * Gets the current physics engine
  146874. * @returns a IPhysicsEngine or null if none attached
  146875. */
  146876. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  146877. /**
  146878. * Enables physics to the current scene
  146879. * @param gravity defines the scene's gravity for the physics engine
  146880. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  146881. * @return a boolean indicating if the physics engine was initialized
  146882. */
  146883. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  146884. /**
  146885. * Disables and disposes the physics engine associated with the scene
  146886. */
  146887. disablePhysicsEngine(): void;
  146888. /**
  146889. * Gets a boolean indicating if there is an active physics engine
  146890. * @returns a boolean indicating if there is an active physics engine
  146891. */
  146892. isPhysicsEnabled(): boolean;
  146893. /**
  146894. * Deletes a physics compound impostor
  146895. * @param compound defines the compound to delete
  146896. */
  146897. deleteCompoundImpostor(compound: any): void;
  146898. /**
  146899. * An event triggered when physic simulation is about to be run
  146900. */
  146901. onBeforePhysicsObservable: Observable<Scene>;
  146902. /**
  146903. * An event triggered when physic simulation has been done
  146904. */
  146905. onAfterPhysicsObservable: Observable<Scene>;
  146906. }
  146907. interface AbstractMesh {
  146908. /** @hidden */
  146909. _physicsImpostor: Nullable<PhysicsImpostor>;
  146910. /**
  146911. * Gets or sets impostor used for physic simulation
  146912. * @see https://doc.babylonjs.com/features/physics_engine
  146913. */
  146914. physicsImpostor: Nullable<PhysicsImpostor>;
  146915. /**
  146916. * Gets the current physics impostor
  146917. * @see https://doc.babylonjs.com/features/physics_engine
  146918. * @returns a physics impostor or null
  146919. */
  146920. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  146921. /** Apply a physic impulse to the mesh
  146922. * @param force defines the force to apply
  146923. * @param contactPoint defines where to apply the force
  146924. * @returns the current mesh
  146925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  146926. */
  146927. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  146928. /**
  146929. * Creates a physic joint between two meshes
  146930. * @param otherMesh defines the other mesh to use
  146931. * @param pivot1 defines the pivot to use on this mesh
  146932. * @param pivot2 defines the pivot to use on the other mesh
  146933. * @param options defines additional options (can be plugin dependent)
  146934. * @returns the current mesh
  146935. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  146936. */
  146937. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  146938. /** @hidden */
  146939. _disposePhysicsObserver: Nullable<Observer<Node>>;
  146940. }
  146941. /**
  146942. * Defines the physics engine scene component responsible to manage a physics engine
  146943. */
  146944. export class PhysicsEngineSceneComponent implements ISceneComponent {
  146945. /**
  146946. * The component name helpful to identify the component in the list of scene components.
  146947. */
  146948. readonly name: string;
  146949. /**
  146950. * The scene the component belongs to.
  146951. */
  146952. scene: Scene;
  146953. /**
  146954. * Creates a new instance of the component for the given scene
  146955. * @param scene Defines the scene to register the component in
  146956. */
  146957. constructor(scene: Scene);
  146958. /**
  146959. * Registers the component in a given scene
  146960. */
  146961. register(): void;
  146962. /**
  146963. * Rebuilds the elements related to this component in case of
  146964. * context lost for instance.
  146965. */
  146966. rebuild(): void;
  146967. /**
  146968. * Disposes the component and the associated ressources
  146969. */
  146970. dispose(): void;
  146971. }
  146972. }
  146973. declare module BABYLON {
  146974. /**
  146975. * A helper for physics simulations
  146976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146977. */
  146978. export class PhysicsHelper {
  146979. private _scene;
  146980. private _physicsEngine;
  146981. /**
  146982. * Initializes the Physics helper
  146983. * @param scene Babylon.js scene
  146984. */
  146985. constructor(scene: Scene);
  146986. /**
  146987. * Applies a radial explosion impulse
  146988. * @param origin the origin of the explosion
  146989. * @param radiusOrEventOptions the radius or the options of radial explosion
  146990. * @param strength the explosion strength
  146991. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146992. * @returns A physics radial explosion event, or null
  146993. */
  146994. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146995. /**
  146996. * Applies a radial explosion force
  146997. * @param origin the origin of the explosion
  146998. * @param radiusOrEventOptions the radius or the options of radial explosion
  146999. * @param strength the explosion strength
  147000. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147001. * @returns A physics radial explosion event, or null
  147002. */
  147003. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147004. /**
  147005. * Creates a gravitational field
  147006. * @param origin the origin of the explosion
  147007. * @param radiusOrEventOptions the radius or the options of radial explosion
  147008. * @param strength the explosion strength
  147009. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147010. * @returns A physics gravitational field event, or null
  147011. */
  147012. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  147013. /**
  147014. * Creates a physics updraft event
  147015. * @param origin the origin of the updraft
  147016. * @param radiusOrEventOptions the radius or the options of the updraft
  147017. * @param strength the strength of the updraft
  147018. * @param height the height of the updraft
  147019. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  147020. * @returns A physics updraft event, or null
  147021. */
  147022. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  147023. /**
  147024. * Creates a physics vortex event
  147025. * @param origin the of the vortex
  147026. * @param radiusOrEventOptions the radius or the options of the vortex
  147027. * @param strength the strength of the vortex
  147028. * @param height the height of the vortex
  147029. * @returns a Physics vortex event, or null
  147030. * A physics vortex event or null
  147031. */
  147032. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  147033. }
  147034. /**
  147035. * Represents a physics radial explosion event
  147036. */
  147037. class PhysicsRadialExplosionEvent {
  147038. private _scene;
  147039. private _options;
  147040. private _sphere;
  147041. private _dataFetched;
  147042. /**
  147043. * Initializes a radial explosioin event
  147044. * @param _scene BabylonJS scene
  147045. * @param _options The options for the vortex event
  147046. */
  147047. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  147048. /**
  147049. * Returns the data related to the radial explosion event (sphere).
  147050. * @returns The radial explosion event data
  147051. */
  147052. getData(): PhysicsRadialExplosionEventData;
  147053. /**
  147054. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  147055. * @param impostor A physics imposter
  147056. * @param origin the origin of the explosion
  147057. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  147058. */
  147059. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  147060. /**
  147061. * Triggers affecterd impostors callbacks
  147062. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  147063. */
  147064. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  147065. /**
  147066. * Disposes the sphere.
  147067. * @param force Specifies if the sphere should be disposed by force
  147068. */
  147069. dispose(force?: boolean): void;
  147070. /*** Helpers ***/
  147071. private _prepareSphere;
  147072. private _intersectsWithSphere;
  147073. }
  147074. /**
  147075. * Represents a gravitational field event
  147076. */
  147077. class PhysicsGravitationalFieldEvent {
  147078. private _physicsHelper;
  147079. private _scene;
  147080. private _origin;
  147081. private _options;
  147082. private _tickCallback;
  147083. private _sphere;
  147084. private _dataFetched;
  147085. /**
  147086. * Initializes the physics gravitational field event
  147087. * @param _physicsHelper A physics helper
  147088. * @param _scene BabylonJS scene
  147089. * @param _origin The origin position of the gravitational field event
  147090. * @param _options The options for the vortex event
  147091. */
  147092. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  147093. /**
  147094. * Returns the data related to the gravitational field event (sphere).
  147095. * @returns A gravitational field event
  147096. */
  147097. getData(): PhysicsGravitationalFieldEventData;
  147098. /**
  147099. * Enables the gravitational field.
  147100. */
  147101. enable(): void;
  147102. /**
  147103. * Disables the gravitational field.
  147104. */
  147105. disable(): void;
  147106. /**
  147107. * Disposes the sphere.
  147108. * @param force The force to dispose from the gravitational field event
  147109. */
  147110. dispose(force?: boolean): void;
  147111. private _tick;
  147112. }
  147113. /**
  147114. * Represents a physics updraft event
  147115. */
  147116. class PhysicsUpdraftEvent {
  147117. private _scene;
  147118. private _origin;
  147119. private _options;
  147120. private _physicsEngine;
  147121. private _originTop;
  147122. private _originDirection;
  147123. private _tickCallback;
  147124. private _cylinder;
  147125. private _cylinderPosition;
  147126. private _dataFetched;
  147127. /**
  147128. * Initializes the physics updraft event
  147129. * @param _scene BabylonJS scene
  147130. * @param _origin The origin position of the updraft
  147131. * @param _options The options for the updraft event
  147132. */
  147133. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  147134. /**
  147135. * Returns the data related to the updraft event (cylinder).
  147136. * @returns A physics updraft event
  147137. */
  147138. getData(): PhysicsUpdraftEventData;
  147139. /**
  147140. * Enables the updraft.
  147141. */
  147142. enable(): void;
  147143. /**
  147144. * Disables the updraft.
  147145. */
  147146. disable(): void;
  147147. /**
  147148. * Disposes the cylinder.
  147149. * @param force Specifies if the updraft should be disposed by force
  147150. */
  147151. dispose(force?: boolean): void;
  147152. private getImpostorHitData;
  147153. private _tick;
  147154. /*** Helpers ***/
  147155. private _prepareCylinder;
  147156. private _intersectsWithCylinder;
  147157. }
  147158. /**
  147159. * Represents a physics vortex event
  147160. */
  147161. class PhysicsVortexEvent {
  147162. private _scene;
  147163. private _origin;
  147164. private _options;
  147165. private _physicsEngine;
  147166. private _originTop;
  147167. private _tickCallback;
  147168. private _cylinder;
  147169. private _cylinderPosition;
  147170. private _dataFetched;
  147171. /**
  147172. * Initializes the physics vortex event
  147173. * @param _scene The BabylonJS scene
  147174. * @param _origin The origin position of the vortex
  147175. * @param _options The options for the vortex event
  147176. */
  147177. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  147178. /**
  147179. * Returns the data related to the vortex event (cylinder).
  147180. * @returns The physics vortex event data
  147181. */
  147182. getData(): PhysicsVortexEventData;
  147183. /**
  147184. * Enables the vortex.
  147185. */
  147186. enable(): void;
  147187. /**
  147188. * Disables the cortex.
  147189. */
  147190. disable(): void;
  147191. /**
  147192. * Disposes the sphere.
  147193. * @param force
  147194. */
  147195. dispose(force?: boolean): void;
  147196. private getImpostorHitData;
  147197. private _tick;
  147198. /*** Helpers ***/
  147199. private _prepareCylinder;
  147200. private _intersectsWithCylinder;
  147201. }
  147202. /**
  147203. * Options fot the radial explosion event
  147204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147205. */
  147206. export class PhysicsRadialExplosionEventOptions {
  147207. /**
  147208. * The radius of the sphere for the radial explosion.
  147209. */
  147210. radius: number;
  147211. /**
  147212. * The strenth of the explosion.
  147213. */
  147214. strength: number;
  147215. /**
  147216. * The strenght of the force in correspondence to the distance of the affected object
  147217. */
  147218. falloff: PhysicsRadialImpulseFalloff;
  147219. /**
  147220. * Sphere options for the radial explosion.
  147221. */
  147222. sphere: {
  147223. segments: number;
  147224. diameter: number;
  147225. };
  147226. /**
  147227. * Sphere options for the radial explosion.
  147228. */
  147229. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  147230. }
  147231. /**
  147232. * Options fot the updraft event
  147233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147234. */
  147235. export class PhysicsUpdraftEventOptions {
  147236. /**
  147237. * The radius of the cylinder for the vortex
  147238. */
  147239. radius: number;
  147240. /**
  147241. * The strenth of the updraft.
  147242. */
  147243. strength: number;
  147244. /**
  147245. * The height of the cylinder for the updraft.
  147246. */
  147247. height: number;
  147248. /**
  147249. * The mode for the the updraft.
  147250. */
  147251. updraftMode: PhysicsUpdraftMode;
  147252. }
  147253. /**
  147254. * Options fot the vortex event
  147255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147256. */
  147257. export class PhysicsVortexEventOptions {
  147258. /**
  147259. * The radius of the cylinder for the vortex
  147260. */
  147261. radius: number;
  147262. /**
  147263. * The strenth of the vortex.
  147264. */
  147265. strength: number;
  147266. /**
  147267. * The height of the cylinder for the vortex.
  147268. */
  147269. height: number;
  147270. /**
  147271. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  147272. */
  147273. centripetalForceThreshold: number;
  147274. /**
  147275. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  147276. */
  147277. centripetalForceMultiplier: number;
  147278. /**
  147279. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  147280. */
  147281. centrifugalForceMultiplier: number;
  147282. /**
  147283. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  147284. */
  147285. updraftForceMultiplier: number;
  147286. }
  147287. /**
  147288. * The strenght 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 PhysicsRadialImpulseFalloff {
  147292. /** Defines that impulse is constant in strength across it's whole radius */
  147293. Constant = 0,
  147294. /** Defines that impulse gets weaker if it's further from the origin */
  147295. Linear = 1
  147296. }
  147297. /**
  147298. * The strength of the force in correspondence to the distance of the affected object
  147299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147300. */
  147301. export enum PhysicsUpdraftMode {
  147302. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  147303. Center = 0,
  147304. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  147305. Perpendicular = 1
  147306. }
  147307. /**
  147308. * Interface for a physics hit data
  147309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147310. */
  147311. export interface PhysicsHitData {
  147312. /**
  147313. * The force applied at the contact point
  147314. */
  147315. force: Vector3;
  147316. /**
  147317. * The contact point
  147318. */
  147319. contactPoint: Vector3;
  147320. /**
  147321. * The distance from the origin to the contact point
  147322. */
  147323. distanceFromOrigin: number;
  147324. }
  147325. /**
  147326. * Interface for radial explosion event data
  147327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147328. */
  147329. export interface PhysicsRadialExplosionEventData {
  147330. /**
  147331. * A sphere used for the radial explosion event
  147332. */
  147333. sphere: Mesh;
  147334. }
  147335. /**
  147336. * Interface for gravitational field event data
  147337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147338. */
  147339. export interface PhysicsGravitationalFieldEventData {
  147340. /**
  147341. * A sphere mesh used for the gravitational field event
  147342. */
  147343. sphere: Mesh;
  147344. }
  147345. /**
  147346. * Interface for updraft event data
  147347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147348. */
  147349. export interface PhysicsUpdraftEventData {
  147350. /**
  147351. * A cylinder used for the updraft event
  147352. */
  147353. cylinder: Mesh;
  147354. }
  147355. /**
  147356. * Interface for vortex event data
  147357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147358. */
  147359. export interface PhysicsVortexEventData {
  147360. /**
  147361. * A cylinder used for the vortex event
  147362. */
  147363. cylinder: Mesh;
  147364. }
  147365. /**
  147366. * Interface for an affected physics impostor
  147367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147368. */
  147369. export interface PhysicsAffectedImpostorWithData {
  147370. /**
  147371. * The impostor affected by the effect
  147372. */
  147373. impostor: PhysicsImpostor;
  147374. /**
  147375. * The data about the hit/horce from the explosion
  147376. */
  147377. hitData: PhysicsHitData;
  147378. }
  147379. }
  147380. declare module BABYLON {
  147381. /** @hidden */
  147382. export var blackAndWhitePixelShader: {
  147383. name: string;
  147384. shader: string;
  147385. };
  147386. }
  147387. declare module BABYLON {
  147388. /**
  147389. * Post process used to render in black and white
  147390. */
  147391. export class BlackAndWhitePostProcess extends PostProcess {
  147392. /**
  147393. * Linear about to convert he result to black and white (default: 1)
  147394. */
  147395. degree: number;
  147396. /**
  147397. * Creates a black and white post process
  147398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  147399. * @param name The name of the effect.
  147400. * @param options The required width/height ratio to downsize to before computing the render pass.
  147401. * @param camera The camera to apply the render pass to.
  147402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147403. * @param engine The engine which the post process will be applied. (default: current engine)
  147404. * @param reusable If the post process can be reused on the same frame. (default: false)
  147405. */
  147406. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147407. }
  147408. }
  147409. declare module BABYLON {
  147410. /**
  147411. * This represents a set of one or more post processes in Babylon.
  147412. * A post process can be used to apply a shader to a texture after it is rendered.
  147413. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147414. */
  147415. export class PostProcessRenderEffect {
  147416. private _postProcesses;
  147417. private _getPostProcesses;
  147418. private _singleInstance;
  147419. private _cameras;
  147420. private _indicesForCamera;
  147421. /**
  147422. * Name of the effect
  147423. * @hidden
  147424. */
  147425. _name: string;
  147426. /**
  147427. * Instantiates a post process render effect.
  147428. * A post process can be used to apply a shader to a texture after it is rendered.
  147429. * @param engine The engine the effect is tied to
  147430. * @param name The name of the effect
  147431. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  147432. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  147433. */
  147434. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  147435. /**
  147436. * Checks if all the post processes in the effect are supported.
  147437. */
  147438. get isSupported(): boolean;
  147439. /**
  147440. * Updates the current state of the effect
  147441. * @hidden
  147442. */
  147443. _update(): void;
  147444. /**
  147445. * Attaches the effect on cameras
  147446. * @param cameras The camera to attach to.
  147447. * @hidden
  147448. */
  147449. _attachCameras(cameras: Camera): void;
  147450. /**
  147451. * Attaches the effect on cameras
  147452. * @param cameras The camera to attach to.
  147453. * @hidden
  147454. */
  147455. _attachCameras(cameras: Camera[]): void;
  147456. /**
  147457. * Detaches the effect on cameras
  147458. * @param cameras The camera to detatch from.
  147459. * @hidden
  147460. */
  147461. _detachCameras(cameras: Camera): void;
  147462. /**
  147463. * Detatches the effect on cameras
  147464. * @param cameras The camera to detatch from.
  147465. * @hidden
  147466. */
  147467. _detachCameras(cameras: Camera[]): void;
  147468. /**
  147469. * Enables the effect on given cameras
  147470. * @param cameras The camera to enable.
  147471. * @hidden
  147472. */
  147473. _enable(cameras: Camera): void;
  147474. /**
  147475. * Enables the effect on given cameras
  147476. * @param cameras The camera to enable.
  147477. * @hidden
  147478. */
  147479. _enable(cameras: Nullable<Camera[]>): void;
  147480. /**
  147481. * Disables the effect on the given cameras
  147482. * @param cameras The camera to disable.
  147483. * @hidden
  147484. */
  147485. _disable(cameras: Camera): void;
  147486. /**
  147487. * Disables the effect on the given cameras
  147488. * @param cameras The camera to disable.
  147489. * @hidden
  147490. */
  147491. _disable(cameras: Nullable<Camera[]>): void;
  147492. /**
  147493. * Gets a list of the post processes contained in the effect.
  147494. * @param camera The camera to get the post processes on.
  147495. * @returns The list of the post processes in the effect.
  147496. */
  147497. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  147498. }
  147499. }
  147500. declare module BABYLON {
  147501. /** @hidden */
  147502. export var extractHighlightsPixelShader: {
  147503. name: string;
  147504. shader: string;
  147505. };
  147506. }
  147507. declare module BABYLON {
  147508. /**
  147509. * 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.
  147510. */
  147511. export class ExtractHighlightsPostProcess extends PostProcess {
  147512. /**
  147513. * The luminance threshold, pixels below this value will be set to black.
  147514. */
  147515. threshold: number;
  147516. /** @hidden */
  147517. _exposure: number;
  147518. /**
  147519. * Post process which has the input texture to be used when performing highlight extraction
  147520. * @hidden
  147521. */
  147522. _inputPostProcess: Nullable<PostProcess>;
  147523. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147524. }
  147525. }
  147526. declare module BABYLON {
  147527. /** @hidden */
  147528. export var bloomMergePixelShader: {
  147529. name: string;
  147530. shader: string;
  147531. };
  147532. }
  147533. declare module BABYLON {
  147534. /**
  147535. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147536. */
  147537. export class BloomMergePostProcess extends PostProcess {
  147538. /** Weight of the bloom to be added to the original input. */
  147539. weight: number;
  147540. /**
  147541. * Creates a new instance of @see BloomMergePostProcess
  147542. * @param name The name of the effect.
  147543. * @param originalFromInput Post process which's input will be used for the merge.
  147544. * @param blurred Blurred highlights post process which's output will be used.
  147545. * @param weight Weight of the bloom to be added to the original input.
  147546. * @param options The required width/height ratio to downsize to before computing the render pass.
  147547. * @param camera The camera to apply the render pass to.
  147548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147549. * @param engine The engine which the post process will be applied. (default: current engine)
  147550. * @param reusable If the post process can be reused on the same frame. (default: false)
  147551. * @param textureType Type of textures used when performing the post process. (default: 0)
  147552. * @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)
  147553. */
  147554. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  147555. /** Weight of the bloom to be added to the original input. */
  147556. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147557. }
  147558. }
  147559. declare module BABYLON {
  147560. /**
  147561. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  147562. */
  147563. export class BloomEffect extends PostProcessRenderEffect {
  147564. private bloomScale;
  147565. /**
  147566. * @hidden Internal
  147567. */
  147568. _effects: Array<PostProcess>;
  147569. /**
  147570. * @hidden Internal
  147571. */
  147572. _downscale: ExtractHighlightsPostProcess;
  147573. private _blurX;
  147574. private _blurY;
  147575. private _merge;
  147576. /**
  147577. * The luminance threshold to find bright areas of the image to bloom.
  147578. */
  147579. get threshold(): number;
  147580. set threshold(value: number);
  147581. /**
  147582. * The strength of the bloom.
  147583. */
  147584. get weight(): number;
  147585. set weight(value: number);
  147586. /**
  147587. * Specifies the size of the bloom blur kernel, relative to the final output size
  147588. */
  147589. get kernel(): number;
  147590. set kernel(value: number);
  147591. /**
  147592. * Creates a new instance of @see BloomEffect
  147593. * @param scene The scene the effect belongs to.
  147594. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  147595. * @param bloomKernel The size of the kernel to be used when applying the blur.
  147596. * @param bloomWeight The the strength of bloom.
  147597. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147598. * @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)
  147599. */
  147600. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  147601. /**
  147602. * Disposes each of the internal effects for a given camera.
  147603. * @param camera The camera to dispose the effect on.
  147604. */
  147605. disposeEffects(camera: Camera): void;
  147606. /**
  147607. * @hidden Internal
  147608. */
  147609. _updateEffects(): void;
  147610. /**
  147611. * Internal
  147612. * @returns if all the contained post processes are ready.
  147613. * @hidden
  147614. */
  147615. _isReady(): boolean;
  147616. }
  147617. }
  147618. declare module BABYLON {
  147619. /** @hidden */
  147620. export var chromaticAberrationPixelShader: {
  147621. name: string;
  147622. shader: string;
  147623. };
  147624. }
  147625. declare module BABYLON {
  147626. /**
  147627. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  147628. */
  147629. export class ChromaticAberrationPostProcess extends PostProcess {
  147630. /**
  147631. * The amount of seperation of rgb channels (default: 30)
  147632. */
  147633. aberrationAmount: number;
  147634. /**
  147635. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  147636. */
  147637. radialIntensity: number;
  147638. /**
  147639. * 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))
  147640. */
  147641. direction: Vector2;
  147642. /**
  147643. * 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))
  147644. */
  147645. centerPosition: Vector2;
  147646. /**
  147647. * Creates a new instance ChromaticAberrationPostProcess
  147648. * @param name The name of the effect.
  147649. * @param screenWidth The width of the screen to apply the effect on.
  147650. * @param screenHeight The height of the screen to apply the effect on.
  147651. * @param options The required width/height ratio to downsize to before computing the render pass.
  147652. * @param camera The camera to apply the render pass to.
  147653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147654. * @param engine The engine which the post process will be applied. (default: current engine)
  147655. * @param reusable If the post process can be reused on the same frame. (default: false)
  147656. * @param textureType Type of textures used when performing the post process. (default: 0)
  147657. * @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)
  147658. */
  147659. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147660. }
  147661. }
  147662. declare module BABYLON {
  147663. /** @hidden */
  147664. export var circleOfConfusionPixelShader: {
  147665. name: string;
  147666. shader: string;
  147667. };
  147668. }
  147669. declare module BABYLON {
  147670. /**
  147671. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  147672. */
  147673. export class CircleOfConfusionPostProcess extends PostProcess {
  147674. /**
  147675. * 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.
  147676. */
  147677. lensSize: number;
  147678. /**
  147679. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147680. */
  147681. fStop: number;
  147682. /**
  147683. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147684. */
  147685. focusDistance: number;
  147686. /**
  147687. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  147688. */
  147689. focalLength: number;
  147690. private _depthTexture;
  147691. /**
  147692. * Creates a new instance CircleOfConfusionPostProcess
  147693. * @param name The name of the effect.
  147694. * @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.
  147695. * @param options The required width/height ratio to downsize to before computing the render pass.
  147696. * @param camera The camera to apply the render pass to.
  147697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147698. * @param engine The engine which the post process will be applied. (default: current engine)
  147699. * @param reusable If the post process can be reused on the same frame. (default: false)
  147700. * @param textureType Type of textures used when performing the post process. (default: 0)
  147701. * @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)
  147702. */
  147703. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147704. /**
  147705. * 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.
  147706. */
  147707. set depthTexture(value: RenderTargetTexture);
  147708. }
  147709. }
  147710. declare module BABYLON {
  147711. /** @hidden */
  147712. export var colorCorrectionPixelShader: {
  147713. name: string;
  147714. shader: string;
  147715. };
  147716. }
  147717. declare module BABYLON {
  147718. /**
  147719. *
  147720. * This post-process allows the modification of rendered colors by using
  147721. * a 'look-up table' (LUT). This effect is also called Color Grading.
  147722. *
  147723. * The object needs to be provided an url to a texture containing the color
  147724. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  147725. * Use an image editing software to tweak the LUT to match your needs.
  147726. *
  147727. * For an example of a color LUT, see here:
  147728. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  147729. * For explanations on color grading, see here:
  147730. * @see http://udn.epicgames.com/Three/ColorGrading.html
  147731. *
  147732. */
  147733. export class ColorCorrectionPostProcess extends PostProcess {
  147734. private _colorTableTexture;
  147735. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147736. }
  147737. }
  147738. declare module BABYLON {
  147739. /** @hidden */
  147740. export var convolutionPixelShader: {
  147741. name: string;
  147742. shader: string;
  147743. };
  147744. }
  147745. declare module BABYLON {
  147746. /**
  147747. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  147748. * input texture to perform effects such as edge detection or sharpening
  147749. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147750. */
  147751. export class ConvolutionPostProcess extends PostProcess {
  147752. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147753. kernel: number[];
  147754. /**
  147755. * Creates a new instance ConvolutionPostProcess
  147756. * @param name The name of the effect.
  147757. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  147758. * @param options The required width/height ratio to downsize to before computing the render pass.
  147759. * @param camera The camera to apply the render pass to.
  147760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147761. * @param engine The engine which the post process will be applied. (default: current engine)
  147762. * @param reusable If the post process can be reused on the same frame. (default: false)
  147763. * @param textureType Type of textures used when performing the post process. (default: 0)
  147764. */
  147765. constructor(name: string,
  147766. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147767. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147768. /**
  147769. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147770. */
  147771. static EdgeDetect0Kernel: number[];
  147772. /**
  147773. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147774. */
  147775. static EdgeDetect1Kernel: number[];
  147776. /**
  147777. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147778. */
  147779. static EdgeDetect2Kernel: number[];
  147780. /**
  147781. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147782. */
  147783. static SharpenKernel: number[];
  147784. /**
  147785. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147786. */
  147787. static EmbossKernel: number[];
  147788. /**
  147789. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147790. */
  147791. static GaussianKernel: number[];
  147792. }
  147793. }
  147794. declare module BABYLON {
  147795. /**
  147796. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  147797. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  147798. * based on samples that have a large difference in distance than the center pixel.
  147799. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  147800. */
  147801. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  147802. direction: Vector2;
  147803. /**
  147804. * Creates a new instance CircleOfConfusionPostProcess
  147805. * @param name The name of the effect.
  147806. * @param scene The scene the effect belongs to.
  147807. * @param direction The direction the blur should be applied.
  147808. * @param kernel The size of the kernel used to blur.
  147809. * @param options The required width/height ratio to downsize to before computing the render pass.
  147810. * @param camera The camera to apply the render pass to.
  147811. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  147812. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  147813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147814. * @param engine The engine which the post process will be applied. (default: current engine)
  147815. * @param reusable If the post process can be reused on the same frame. (default: false)
  147816. * @param textureType Type of textures used when performing the post process. (default: 0)
  147817. * @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)
  147818. */
  147819. 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);
  147820. }
  147821. }
  147822. declare module BABYLON {
  147823. /** @hidden */
  147824. export var depthOfFieldMergePixelShader: {
  147825. name: string;
  147826. shader: string;
  147827. };
  147828. }
  147829. declare module BABYLON {
  147830. /**
  147831. * Options to be set when merging outputs from the default pipeline.
  147832. */
  147833. export class DepthOfFieldMergePostProcessOptions {
  147834. /**
  147835. * The original image to merge on top of
  147836. */
  147837. originalFromInput: PostProcess;
  147838. /**
  147839. * Parameters to perform the merge of the depth of field effect
  147840. */
  147841. depthOfField?: {
  147842. circleOfConfusion: PostProcess;
  147843. blurSteps: Array<PostProcess>;
  147844. };
  147845. /**
  147846. * Parameters to perform the merge of bloom effect
  147847. */
  147848. bloom?: {
  147849. blurred: PostProcess;
  147850. weight: number;
  147851. };
  147852. }
  147853. /**
  147854. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147855. */
  147856. export class DepthOfFieldMergePostProcess extends PostProcess {
  147857. private blurSteps;
  147858. /**
  147859. * Creates a new instance of DepthOfFieldMergePostProcess
  147860. * @param name The name of the effect.
  147861. * @param originalFromInput Post process which's input will be used for the merge.
  147862. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  147863. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  147864. * @param options The required width/height ratio to downsize to before computing the render pass.
  147865. * @param camera The camera to apply the render pass to.
  147866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147867. * @param engine The engine which the post process will be applied. (default: current engine)
  147868. * @param reusable If the post process can be reused on the same frame. (default: false)
  147869. * @param textureType Type of textures used when performing the post process. (default: 0)
  147870. * @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)
  147871. */
  147872. 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);
  147873. /**
  147874. * Updates the effect with the current post process compile time values and recompiles the shader.
  147875. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  147876. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  147877. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  147878. * @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
  147879. * @param onCompiled Called when the shader has been compiled.
  147880. * @param onError Called if there is an error when compiling a shader.
  147881. */
  147882. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  147883. }
  147884. }
  147885. declare module BABYLON {
  147886. /**
  147887. * Specifies the level of max blur that should be applied when using the depth of field effect
  147888. */
  147889. export enum DepthOfFieldEffectBlurLevel {
  147890. /**
  147891. * Subtle blur
  147892. */
  147893. Low = 0,
  147894. /**
  147895. * Medium blur
  147896. */
  147897. Medium = 1,
  147898. /**
  147899. * Large blur
  147900. */
  147901. High = 2
  147902. }
  147903. /**
  147904. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  147905. */
  147906. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  147907. private _circleOfConfusion;
  147908. /**
  147909. * @hidden Internal, blurs from high to low
  147910. */
  147911. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  147912. private _depthOfFieldBlurY;
  147913. private _dofMerge;
  147914. /**
  147915. * @hidden Internal post processes in depth of field effect
  147916. */
  147917. _effects: Array<PostProcess>;
  147918. /**
  147919. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  147920. */
  147921. set focalLength(value: number);
  147922. get focalLength(): number;
  147923. /**
  147924. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147925. */
  147926. set fStop(value: number);
  147927. get fStop(): number;
  147928. /**
  147929. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147930. */
  147931. set focusDistance(value: number);
  147932. get focusDistance(): number;
  147933. /**
  147934. * 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.
  147935. */
  147936. set lensSize(value: number);
  147937. get lensSize(): number;
  147938. /**
  147939. * Creates a new instance DepthOfFieldEffect
  147940. * @param scene The scene the effect belongs to.
  147941. * @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.
  147942. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147943. * @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)
  147944. */
  147945. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  147946. /**
  147947. * Get the current class name of the current effet
  147948. * @returns "DepthOfFieldEffect"
  147949. */
  147950. getClassName(): string;
  147951. /**
  147952. * 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.
  147953. */
  147954. set depthTexture(value: RenderTargetTexture);
  147955. /**
  147956. * Disposes each of the internal effects for a given camera.
  147957. * @param camera The camera to dispose the effect on.
  147958. */
  147959. disposeEffects(camera: Camera): void;
  147960. /**
  147961. * @hidden Internal
  147962. */
  147963. _updateEffects(): void;
  147964. /**
  147965. * Internal
  147966. * @returns if all the contained post processes are ready.
  147967. * @hidden
  147968. */
  147969. _isReady(): boolean;
  147970. }
  147971. }
  147972. declare module BABYLON {
  147973. /** @hidden */
  147974. export var displayPassPixelShader: {
  147975. name: string;
  147976. shader: string;
  147977. };
  147978. }
  147979. declare module BABYLON {
  147980. /**
  147981. * DisplayPassPostProcess which produces an output the same as it's input
  147982. */
  147983. export class DisplayPassPostProcess extends PostProcess {
  147984. /**
  147985. * Creates the DisplayPassPostProcess
  147986. * @param name The name of the effect.
  147987. * @param options The required width/height ratio to downsize to before computing the render pass.
  147988. * @param camera The camera to apply the render pass to.
  147989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147990. * @param engine The engine which the post process will be applied. (default: current engine)
  147991. * @param reusable If the post process can be reused on the same frame. (default: false)
  147992. */
  147993. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147994. }
  147995. }
  147996. declare module BABYLON {
  147997. /** @hidden */
  147998. export var filterPixelShader: {
  147999. name: string;
  148000. shader: string;
  148001. };
  148002. }
  148003. declare module BABYLON {
  148004. /**
  148005. * Applies a kernel filter to the image
  148006. */
  148007. export class FilterPostProcess extends PostProcess {
  148008. /** The matrix to be applied to the image */
  148009. kernelMatrix: Matrix;
  148010. /**
  148011. *
  148012. * @param name The name of the effect.
  148013. * @param kernelMatrix The matrix to be applied to the image
  148014. * @param options The required width/height ratio to downsize to before computing the render pass.
  148015. * @param camera The camera to apply the render pass to.
  148016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148017. * @param engine The engine which the post process will be applied. (default: current engine)
  148018. * @param reusable If the post process can be reused on the same frame. (default: false)
  148019. */
  148020. constructor(name: string,
  148021. /** The matrix to be applied to the image */
  148022. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148023. }
  148024. }
  148025. declare module BABYLON {
  148026. /** @hidden */
  148027. export var fxaaPixelShader: {
  148028. name: string;
  148029. shader: string;
  148030. };
  148031. }
  148032. declare module BABYLON {
  148033. /** @hidden */
  148034. export var fxaaVertexShader: {
  148035. name: string;
  148036. shader: string;
  148037. };
  148038. }
  148039. declare module BABYLON {
  148040. /**
  148041. * Fxaa post process
  148042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  148043. */
  148044. export class FxaaPostProcess extends PostProcess {
  148045. /** @hidden */
  148046. texelWidth: number;
  148047. /** @hidden */
  148048. texelHeight: number;
  148049. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148050. private _getDefines;
  148051. }
  148052. }
  148053. declare module BABYLON {
  148054. /** @hidden */
  148055. export var grainPixelShader: {
  148056. name: string;
  148057. shader: string;
  148058. };
  148059. }
  148060. declare module BABYLON {
  148061. /**
  148062. * The GrainPostProcess adds noise to the image at mid luminance levels
  148063. */
  148064. export class GrainPostProcess extends PostProcess {
  148065. /**
  148066. * The intensity of the grain added (default: 30)
  148067. */
  148068. intensity: number;
  148069. /**
  148070. * If the grain should be randomized on every frame
  148071. */
  148072. animated: boolean;
  148073. /**
  148074. * Creates a new instance of @see GrainPostProcess
  148075. * @param name The name of the effect.
  148076. * @param options The required width/height ratio to downsize to before computing the render pass.
  148077. * @param camera The camera to apply the render pass to.
  148078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148079. * @param engine The engine which the post process will be applied. (default: current engine)
  148080. * @param reusable If the post process can be reused on the same frame. (default: false)
  148081. * @param textureType Type of textures used when performing the post process. (default: 0)
  148082. * @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)
  148083. */
  148084. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148085. }
  148086. }
  148087. declare module BABYLON {
  148088. /** @hidden */
  148089. export var highlightsPixelShader: {
  148090. name: string;
  148091. shader: string;
  148092. };
  148093. }
  148094. declare module BABYLON {
  148095. /**
  148096. * Extracts highlights from the image
  148097. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148098. */
  148099. export class HighlightsPostProcess extends PostProcess {
  148100. /**
  148101. * Extracts highlights from the image
  148102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148103. * @param name The name of the effect.
  148104. * @param options The required width/height ratio to downsize to before computing the render pass.
  148105. * @param camera The camera to apply the render pass to.
  148106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148107. * @param engine The engine which the post process will be applied. (default: current engine)
  148108. * @param reusable If the post process can be reused on the same frame. (default: false)
  148109. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  148110. */
  148111. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148112. }
  148113. }
  148114. declare module BABYLON {
  148115. /** @hidden */
  148116. export var mrtFragmentDeclaration: {
  148117. name: string;
  148118. shader: string;
  148119. };
  148120. }
  148121. declare module BABYLON {
  148122. /** @hidden */
  148123. export var geometryPixelShader: {
  148124. name: string;
  148125. shader: string;
  148126. };
  148127. }
  148128. declare module BABYLON {
  148129. /** @hidden */
  148130. export var geometryVertexShader: {
  148131. name: string;
  148132. shader: string;
  148133. };
  148134. }
  148135. declare module BABYLON {
  148136. /** @hidden */
  148137. interface ISavedTransformationMatrix {
  148138. world: Matrix;
  148139. viewProjection: Matrix;
  148140. }
  148141. /**
  148142. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  148143. */
  148144. export class GeometryBufferRenderer {
  148145. /**
  148146. * Constant used to retrieve the position texture index in the G-Buffer textures array
  148147. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  148148. */
  148149. static readonly POSITION_TEXTURE_TYPE: number;
  148150. /**
  148151. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  148152. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  148153. */
  148154. static readonly VELOCITY_TEXTURE_TYPE: number;
  148155. /**
  148156. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  148157. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  148158. */
  148159. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  148160. /**
  148161. * Dictionary used to store the previous transformation matrices of each rendered mesh
  148162. * in order to compute objects velocities when enableVelocity is set to "true"
  148163. * @hidden
  148164. */
  148165. _previousTransformationMatrices: {
  148166. [index: number]: ISavedTransformationMatrix;
  148167. };
  148168. /**
  148169. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  148170. * in order to compute objects velocities when enableVelocity is set to "true"
  148171. * @hidden
  148172. */
  148173. _previousBonesTransformationMatrices: {
  148174. [index: number]: Float32Array;
  148175. };
  148176. /**
  148177. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  148178. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  148179. */
  148180. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  148181. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  148182. renderTransparentMeshes: boolean;
  148183. private _scene;
  148184. private _resizeObserver;
  148185. private _multiRenderTarget;
  148186. private _ratio;
  148187. private _enablePosition;
  148188. private _enableVelocity;
  148189. private _enableReflectivity;
  148190. private _positionIndex;
  148191. private _velocityIndex;
  148192. private _reflectivityIndex;
  148193. protected _effect: Effect;
  148194. protected _cachedDefines: string;
  148195. /**
  148196. * Set the render list (meshes to be rendered) used in the G buffer.
  148197. */
  148198. set renderList(meshes: Mesh[]);
  148199. /**
  148200. * Gets wether or not G buffer are supported by the running hardware.
  148201. * This requires draw buffer supports
  148202. */
  148203. get isSupported(): boolean;
  148204. /**
  148205. * Returns the index of the given texture type in the G-Buffer textures array
  148206. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  148207. * @returns the index of the given texture type in the G-Buffer textures array
  148208. */
  148209. getTextureIndex(textureType: number): number;
  148210. /**
  148211. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  148212. */
  148213. get enablePosition(): boolean;
  148214. /**
  148215. * Sets whether or not objects positions are enabled for the G buffer.
  148216. */
  148217. set enablePosition(enable: boolean);
  148218. /**
  148219. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  148220. */
  148221. get enableVelocity(): boolean;
  148222. /**
  148223. * Sets wether or not objects velocities are enabled for the G buffer.
  148224. */
  148225. set enableVelocity(enable: boolean);
  148226. /**
  148227. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  148228. */
  148229. get enableReflectivity(): boolean;
  148230. /**
  148231. * Sets wether or not objects roughness are enabled for the G buffer.
  148232. */
  148233. set enableReflectivity(enable: boolean);
  148234. /**
  148235. * Gets the scene associated with the buffer.
  148236. */
  148237. get scene(): Scene;
  148238. /**
  148239. * Gets the ratio used by the buffer during its creation.
  148240. * How big is the buffer related to the main canvas.
  148241. */
  148242. get ratio(): number;
  148243. /** @hidden */
  148244. static _SceneComponentInitialization: (scene: Scene) => void;
  148245. /**
  148246. * Creates a new G Buffer for the scene
  148247. * @param scene The scene the buffer belongs to
  148248. * @param ratio How big is the buffer related to the main canvas.
  148249. */
  148250. constructor(scene: Scene, ratio?: number);
  148251. /**
  148252. * Checks wether everything is ready to render a submesh to the G buffer.
  148253. * @param subMesh the submesh to check readiness for
  148254. * @param useInstances is the mesh drawn using instance or not
  148255. * @returns true if ready otherwise false
  148256. */
  148257. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148258. /**
  148259. * Gets the current underlying G Buffer.
  148260. * @returns the buffer
  148261. */
  148262. getGBuffer(): MultiRenderTarget;
  148263. /**
  148264. * Gets the number of samples used to render the buffer (anti aliasing).
  148265. */
  148266. get samples(): number;
  148267. /**
  148268. * Sets the number of samples used to render the buffer (anti aliasing).
  148269. */
  148270. set samples(value: number);
  148271. /**
  148272. * Disposes the renderer and frees up associated resources.
  148273. */
  148274. dispose(): void;
  148275. protected _createRenderTargets(): void;
  148276. private _copyBonesTransformationMatrices;
  148277. }
  148278. }
  148279. declare module BABYLON {
  148280. interface Scene {
  148281. /** @hidden (Backing field) */
  148282. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148283. /**
  148284. * Gets or Sets the current geometry buffer associated to the scene.
  148285. */
  148286. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148287. /**
  148288. * Enables a GeometryBufferRender and associates it with the scene
  148289. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  148290. * @returns the GeometryBufferRenderer
  148291. */
  148292. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  148293. /**
  148294. * Disables the GeometryBufferRender associated with the scene
  148295. */
  148296. disableGeometryBufferRenderer(): void;
  148297. }
  148298. /**
  148299. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  148300. * in several rendering techniques.
  148301. */
  148302. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  148303. /**
  148304. * The component name helpful to identify the component in the list of scene components.
  148305. */
  148306. readonly name: string;
  148307. /**
  148308. * The scene the component belongs to.
  148309. */
  148310. scene: Scene;
  148311. /**
  148312. * Creates a new instance of the component for the given scene
  148313. * @param scene Defines the scene to register the component in
  148314. */
  148315. constructor(scene: Scene);
  148316. /**
  148317. * Registers the component in a given scene
  148318. */
  148319. register(): void;
  148320. /**
  148321. * Rebuilds the elements related to this component in case of
  148322. * context lost for instance.
  148323. */
  148324. rebuild(): void;
  148325. /**
  148326. * Disposes the component and the associated ressources
  148327. */
  148328. dispose(): void;
  148329. private _gatherRenderTargets;
  148330. }
  148331. }
  148332. declare module BABYLON {
  148333. /** @hidden */
  148334. export var motionBlurPixelShader: {
  148335. name: string;
  148336. shader: string;
  148337. };
  148338. }
  148339. declare module BABYLON {
  148340. /**
  148341. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  148342. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  148343. * As an example, all you have to do is to create the post-process:
  148344. * var mb = new BABYLON.MotionBlurPostProcess(
  148345. * 'mb', // The name of the effect.
  148346. * scene, // The scene containing the objects to blur according to their velocity.
  148347. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  148348. * camera // The camera to apply the render pass to.
  148349. * );
  148350. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  148351. */
  148352. export class MotionBlurPostProcess extends PostProcess {
  148353. /**
  148354. * Defines how much the image is blurred by the movement. Default value is equal to 1
  148355. */
  148356. motionStrength: number;
  148357. /**
  148358. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  148359. */
  148360. get motionBlurSamples(): number;
  148361. /**
  148362. * Sets the number of iterations to be used for motion blur quality
  148363. */
  148364. set motionBlurSamples(samples: number);
  148365. private _motionBlurSamples;
  148366. private _geometryBufferRenderer;
  148367. /**
  148368. * Creates a new instance MotionBlurPostProcess
  148369. * @param name The name of the effect.
  148370. * @param scene The scene containing the objects to blur according to their velocity.
  148371. * @param options The required width/height ratio to downsize to before computing the render pass.
  148372. * @param camera The camera to apply the render pass to.
  148373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148374. * @param engine The engine which the post process will be applied. (default: current engine)
  148375. * @param reusable If the post process can be reused on the same frame. (default: false)
  148376. * @param textureType Type of textures used when performing the post process. (default: 0)
  148377. * @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)
  148378. */
  148379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148380. /**
  148381. * Excludes the given skinned mesh from computing bones velocities.
  148382. * 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.
  148383. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  148384. */
  148385. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148386. /**
  148387. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  148388. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  148389. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  148390. */
  148391. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148392. /**
  148393. * Disposes the post process.
  148394. * @param camera The camera to dispose the post process on.
  148395. */
  148396. dispose(camera?: Camera): void;
  148397. }
  148398. }
  148399. declare module BABYLON {
  148400. /** @hidden */
  148401. export var refractionPixelShader: {
  148402. name: string;
  148403. shader: string;
  148404. };
  148405. }
  148406. declare module BABYLON {
  148407. /**
  148408. * Post process which applies a refractin texture
  148409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148410. */
  148411. export class RefractionPostProcess extends PostProcess {
  148412. /** the base color of the refraction (used to taint the rendering) */
  148413. color: Color3;
  148414. /** simulated refraction depth */
  148415. depth: number;
  148416. /** the coefficient of the base color (0 to remove base color tainting) */
  148417. colorLevel: number;
  148418. private _refTexture;
  148419. private _ownRefractionTexture;
  148420. /**
  148421. * Gets or sets the refraction texture
  148422. * Please note that you are responsible for disposing the texture if you set it manually
  148423. */
  148424. get refractionTexture(): Texture;
  148425. set refractionTexture(value: Texture);
  148426. /**
  148427. * Initializes the RefractionPostProcess
  148428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148429. * @param name The name of the effect.
  148430. * @param refractionTextureUrl Url of the refraction texture to use
  148431. * @param color the base color of the refraction (used to taint the rendering)
  148432. * @param depth simulated refraction depth
  148433. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  148434. * @param camera The camera to apply the render pass to.
  148435. * @param options The required width/height ratio to downsize to before computing the render pass.
  148436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148437. * @param engine The engine which the post process will be applied. (default: current engine)
  148438. * @param reusable If the post process can be reused on the same frame. (default: false)
  148439. */
  148440. constructor(name: string, refractionTextureUrl: string,
  148441. /** the base color of the refraction (used to taint the rendering) */
  148442. color: Color3,
  148443. /** simulated refraction depth */
  148444. depth: number,
  148445. /** the coefficient of the base color (0 to remove base color tainting) */
  148446. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148447. /**
  148448. * Disposes of the post process
  148449. * @param camera Camera to dispose post process on
  148450. */
  148451. dispose(camera: Camera): void;
  148452. }
  148453. }
  148454. declare module BABYLON {
  148455. /** @hidden */
  148456. export var sharpenPixelShader: {
  148457. name: string;
  148458. shader: string;
  148459. };
  148460. }
  148461. declare module BABYLON {
  148462. /**
  148463. * The SharpenPostProcess applies a sharpen kernel to every pixel
  148464. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148465. */
  148466. export class SharpenPostProcess extends PostProcess {
  148467. /**
  148468. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  148469. */
  148470. colorAmount: number;
  148471. /**
  148472. * How much sharpness should be applied (default: 0.3)
  148473. */
  148474. edgeAmount: number;
  148475. /**
  148476. * Creates a new instance ConvolutionPostProcess
  148477. * @param name The name of the effect.
  148478. * @param options The required width/height ratio to downsize to before computing the render pass.
  148479. * @param camera The camera to apply the render pass to.
  148480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148481. * @param engine The engine which the post process will be applied. (default: current engine)
  148482. * @param reusable If the post process can be reused on the same frame. (default: false)
  148483. * @param textureType Type of textures used when performing the post process. (default: 0)
  148484. * @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)
  148485. */
  148486. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148487. }
  148488. }
  148489. declare module BABYLON {
  148490. /**
  148491. * PostProcessRenderPipeline
  148492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148493. */
  148494. export class PostProcessRenderPipeline {
  148495. private engine;
  148496. private _renderEffects;
  148497. private _renderEffectsForIsolatedPass;
  148498. /**
  148499. * List of inspectable custom properties (used by the Inspector)
  148500. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  148501. */
  148502. inspectableCustomProperties: IInspectable[];
  148503. /**
  148504. * @hidden
  148505. */
  148506. protected _cameras: Camera[];
  148507. /** @hidden */
  148508. _name: string;
  148509. /**
  148510. * Gets pipeline name
  148511. */
  148512. get name(): string;
  148513. /** Gets the list of attached cameras */
  148514. get cameras(): Camera[];
  148515. /**
  148516. * Initializes a PostProcessRenderPipeline
  148517. * @param engine engine to add the pipeline to
  148518. * @param name name of the pipeline
  148519. */
  148520. constructor(engine: Engine, name: string);
  148521. /**
  148522. * Gets the class name
  148523. * @returns "PostProcessRenderPipeline"
  148524. */
  148525. getClassName(): string;
  148526. /**
  148527. * If all the render effects in the pipeline are supported
  148528. */
  148529. get isSupported(): boolean;
  148530. /**
  148531. * Adds an effect to the pipeline
  148532. * @param renderEffect the effect to add
  148533. */
  148534. addEffect(renderEffect: PostProcessRenderEffect): void;
  148535. /** @hidden */
  148536. _rebuild(): void;
  148537. /** @hidden */
  148538. _enableEffect(renderEffectName: string, cameras: Camera): void;
  148539. /** @hidden */
  148540. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  148541. /** @hidden */
  148542. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148543. /** @hidden */
  148544. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148545. /** @hidden */
  148546. _attachCameras(cameras: Camera, unique: boolean): void;
  148547. /** @hidden */
  148548. _attachCameras(cameras: Camera[], unique: boolean): void;
  148549. /** @hidden */
  148550. _detachCameras(cameras: Camera): void;
  148551. /** @hidden */
  148552. _detachCameras(cameras: Nullable<Camera[]>): void;
  148553. /** @hidden */
  148554. _update(): void;
  148555. /** @hidden */
  148556. _reset(): void;
  148557. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  148558. /**
  148559. * Sets the required values to the prepass renderer.
  148560. * @param prePassRenderer defines the prepass renderer to setup.
  148561. * @returns true if the pre pass is needed.
  148562. */
  148563. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  148564. /**
  148565. * Disposes of the pipeline
  148566. */
  148567. dispose(): void;
  148568. }
  148569. }
  148570. declare module BABYLON {
  148571. /**
  148572. * PostProcessRenderPipelineManager class
  148573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148574. */
  148575. export class PostProcessRenderPipelineManager {
  148576. private _renderPipelines;
  148577. /**
  148578. * Initializes a PostProcessRenderPipelineManager
  148579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148580. */
  148581. constructor();
  148582. /**
  148583. * Gets the list of supported render pipelines
  148584. */
  148585. get supportedPipelines(): PostProcessRenderPipeline[];
  148586. /**
  148587. * Adds a pipeline to the manager
  148588. * @param renderPipeline The pipeline to add
  148589. */
  148590. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  148591. /**
  148592. * Attaches a camera to the pipeline
  148593. * @param renderPipelineName The name of the pipeline to attach to
  148594. * @param cameras the camera to attach
  148595. * @param unique if the camera can be attached multiple times to the pipeline
  148596. */
  148597. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  148598. /**
  148599. * Detaches a camera from the pipeline
  148600. * @param renderPipelineName The name of the pipeline to detach from
  148601. * @param cameras the camera to detach
  148602. */
  148603. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  148604. /**
  148605. * Enables an effect by name on a pipeline
  148606. * @param renderPipelineName the name of the pipeline to enable the effect in
  148607. * @param renderEffectName the name of the effect to enable
  148608. * @param cameras the cameras that the effect should be enabled on
  148609. */
  148610. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148611. /**
  148612. * Disables an effect by name on a pipeline
  148613. * @param renderPipelineName the name of the pipeline to disable the effect in
  148614. * @param renderEffectName the name of the effect to disable
  148615. * @param cameras the cameras that the effect should be disabled on
  148616. */
  148617. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148618. /**
  148619. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  148620. */
  148621. update(): void;
  148622. /** @hidden */
  148623. _rebuild(): void;
  148624. /**
  148625. * Disposes of the manager and pipelines
  148626. */
  148627. dispose(): void;
  148628. }
  148629. }
  148630. declare module BABYLON {
  148631. interface Scene {
  148632. /** @hidden (Backing field) */
  148633. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148634. /**
  148635. * Gets the postprocess render pipeline manager
  148636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148637. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148638. */
  148639. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148640. }
  148641. /**
  148642. * Defines the Render Pipeline scene component responsible to rendering pipelines
  148643. */
  148644. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  148645. /**
  148646. * The component name helpfull to identify the component in the list of scene components.
  148647. */
  148648. readonly name: string;
  148649. /**
  148650. * The scene the component belongs to.
  148651. */
  148652. scene: Scene;
  148653. /**
  148654. * Creates a new instance of the component for the given scene
  148655. * @param scene Defines the scene to register the component in
  148656. */
  148657. constructor(scene: Scene);
  148658. /**
  148659. * Registers the component in a given scene
  148660. */
  148661. register(): void;
  148662. /**
  148663. * Rebuilds the elements related to this component in case of
  148664. * context lost for instance.
  148665. */
  148666. rebuild(): void;
  148667. /**
  148668. * Disposes the component and the associated ressources
  148669. */
  148670. dispose(): void;
  148671. private _gatherRenderTargets;
  148672. }
  148673. }
  148674. declare module BABYLON {
  148675. /**
  148676. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  148677. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148678. */
  148679. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148680. private _scene;
  148681. private _camerasToBeAttached;
  148682. /**
  148683. * ID of the sharpen post process,
  148684. */
  148685. private readonly SharpenPostProcessId;
  148686. /**
  148687. * @ignore
  148688. * ID of the image processing post process;
  148689. */
  148690. readonly ImageProcessingPostProcessId: string;
  148691. /**
  148692. * @ignore
  148693. * ID of the Fast Approximate Anti-Aliasing post process;
  148694. */
  148695. readonly FxaaPostProcessId: string;
  148696. /**
  148697. * ID of the chromatic aberration post process,
  148698. */
  148699. private readonly ChromaticAberrationPostProcessId;
  148700. /**
  148701. * ID of the grain post process
  148702. */
  148703. private readonly GrainPostProcessId;
  148704. /**
  148705. * Sharpen post process which will apply a sharpen convolution to enhance edges
  148706. */
  148707. sharpen: SharpenPostProcess;
  148708. private _sharpenEffect;
  148709. private bloom;
  148710. /**
  148711. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  148712. */
  148713. depthOfField: DepthOfFieldEffect;
  148714. /**
  148715. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148716. */
  148717. fxaa: FxaaPostProcess;
  148718. /**
  148719. * Image post processing pass used to perform operations such as tone mapping or color grading.
  148720. */
  148721. imageProcessing: ImageProcessingPostProcess;
  148722. /**
  148723. * Chromatic aberration post process which will shift rgb colors in the image
  148724. */
  148725. chromaticAberration: ChromaticAberrationPostProcess;
  148726. private _chromaticAberrationEffect;
  148727. /**
  148728. * Grain post process which add noise to the image
  148729. */
  148730. grain: GrainPostProcess;
  148731. private _grainEffect;
  148732. /**
  148733. * Glow post process which adds a glow to emissive areas of the image
  148734. */
  148735. private _glowLayer;
  148736. /**
  148737. * Animations which can be used to tweak settings over a period of time
  148738. */
  148739. animations: Animation[];
  148740. private _imageProcessingConfigurationObserver;
  148741. private _sharpenEnabled;
  148742. private _bloomEnabled;
  148743. private _depthOfFieldEnabled;
  148744. private _depthOfFieldBlurLevel;
  148745. private _fxaaEnabled;
  148746. private _imageProcessingEnabled;
  148747. private _defaultPipelineTextureType;
  148748. private _bloomScale;
  148749. private _chromaticAberrationEnabled;
  148750. private _grainEnabled;
  148751. private _buildAllowed;
  148752. /**
  148753. * Gets active scene
  148754. */
  148755. get scene(): Scene;
  148756. /**
  148757. * Enable or disable the sharpen process from the pipeline
  148758. */
  148759. set sharpenEnabled(enabled: boolean);
  148760. get sharpenEnabled(): boolean;
  148761. private _resizeObserver;
  148762. private _hardwareScaleLevel;
  148763. private _bloomKernel;
  148764. /**
  148765. * Specifies the size of the bloom blur kernel, relative to the final output size
  148766. */
  148767. get bloomKernel(): number;
  148768. set bloomKernel(value: number);
  148769. /**
  148770. * Specifies the weight of the bloom in the final rendering
  148771. */
  148772. private _bloomWeight;
  148773. /**
  148774. * Specifies the luma threshold for the area that will be blurred by the bloom
  148775. */
  148776. private _bloomThreshold;
  148777. private _hdr;
  148778. /**
  148779. * The strength of the bloom.
  148780. */
  148781. set bloomWeight(value: number);
  148782. get bloomWeight(): number;
  148783. /**
  148784. * The strength of the bloom.
  148785. */
  148786. set bloomThreshold(value: number);
  148787. get bloomThreshold(): number;
  148788. /**
  148789. * The scale of the bloom, lower value will provide better performance.
  148790. */
  148791. set bloomScale(value: number);
  148792. get bloomScale(): number;
  148793. /**
  148794. * Enable or disable the bloom from the pipeline
  148795. */
  148796. set bloomEnabled(enabled: boolean);
  148797. get bloomEnabled(): boolean;
  148798. private _rebuildBloom;
  148799. /**
  148800. * If the depth of field is enabled.
  148801. */
  148802. get depthOfFieldEnabled(): boolean;
  148803. set depthOfFieldEnabled(enabled: boolean);
  148804. /**
  148805. * Blur level of the depth of field effect. (Higher blur will effect performance)
  148806. */
  148807. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  148808. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  148809. /**
  148810. * If the anti aliasing is enabled.
  148811. */
  148812. set fxaaEnabled(enabled: boolean);
  148813. get fxaaEnabled(): boolean;
  148814. private _samples;
  148815. /**
  148816. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148817. */
  148818. set samples(sampleCount: number);
  148819. get samples(): number;
  148820. /**
  148821. * If image processing is enabled.
  148822. */
  148823. set imageProcessingEnabled(enabled: boolean);
  148824. get imageProcessingEnabled(): boolean;
  148825. /**
  148826. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  148827. */
  148828. set glowLayerEnabled(enabled: boolean);
  148829. get glowLayerEnabled(): boolean;
  148830. /**
  148831. * Gets the glow layer (or null if not defined)
  148832. */
  148833. get glowLayer(): Nullable<GlowLayer>;
  148834. /**
  148835. * Enable or disable the chromaticAberration process from the pipeline
  148836. */
  148837. set chromaticAberrationEnabled(enabled: boolean);
  148838. get chromaticAberrationEnabled(): boolean;
  148839. /**
  148840. * Enable or disable the grain process from the pipeline
  148841. */
  148842. set grainEnabled(enabled: boolean);
  148843. get grainEnabled(): boolean;
  148844. /**
  148845. * @constructor
  148846. * @param name - The rendering pipeline name (default: "")
  148847. * @param hdr - If high dynamic range textures should be used (default: true)
  148848. * @param scene - The scene linked to this pipeline (default: the last created scene)
  148849. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  148850. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  148851. */
  148852. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  148853. /**
  148854. * Get the class name
  148855. * @returns "DefaultRenderingPipeline"
  148856. */
  148857. getClassName(): string;
  148858. /**
  148859. * Force the compilation of the entire pipeline.
  148860. */
  148861. prepare(): void;
  148862. private _hasCleared;
  148863. private _prevPostProcess;
  148864. private _prevPrevPostProcess;
  148865. private _setAutoClearAndTextureSharing;
  148866. private _depthOfFieldSceneObserver;
  148867. private _buildPipeline;
  148868. private _disposePostProcesses;
  148869. /**
  148870. * Adds a camera to the pipeline
  148871. * @param camera the camera to be added
  148872. */
  148873. addCamera(camera: Camera): void;
  148874. /**
  148875. * Removes a camera from the pipeline
  148876. * @param camera the camera to remove
  148877. */
  148878. removeCamera(camera: Camera): void;
  148879. /**
  148880. * Dispose of the pipeline and stop all post processes
  148881. */
  148882. dispose(): void;
  148883. /**
  148884. * Serialize the rendering pipeline (Used when exporting)
  148885. * @returns the serialized object
  148886. */
  148887. serialize(): any;
  148888. /**
  148889. * Parse the serialized pipeline
  148890. * @param source Source pipeline.
  148891. * @param scene The scene to load the pipeline to.
  148892. * @param rootUrl The URL of the serialized pipeline.
  148893. * @returns An instantiated pipeline from the serialized object.
  148894. */
  148895. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  148896. }
  148897. }
  148898. declare module BABYLON {
  148899. /** @hidden */
  148900. export var lensHighlightsPixelShader: {
  148901. name: string;
  148902. shader: string;
  148903. };
  148904. }
  148905. declare module BABYLON {
  148906. /** @hidden */
  148907. export var depthOfFieldPixelShader: {
  148908. name: string;
  148909. shader: string;
  148910. };
  148911. }
  148912. declare module BABYLON {
  148913. /**
  148914. * BABYLON.JS Chromatic Aberration GLSL Shader
  148915. * Author: Olivier Guyot
  148916. * Separates very slightly R, G and B colors on the edges of the screen
  148917. * Inspired by Francois Tarlier & Martins Upitis
  148918. */
  148919. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  148920. /**
  148921. * @ignore
  148922. * The chromatic aberration PostProcess id in the pipeline
  148923. */
  148924. LensChromaticAberrationEffect: string;
  148925. /**
  148926. * @ignore
  148927. * The highlights enhancing PostProcess id in the pipeline
  148928. */
  148929. HighlightsEnhancingEffect: string;
  148930. /**
  148931. * @ignore
  148932. * The depth-of-field PostProcess id in the pipeline
  148933. */
  148934. LensDepthOfFieldEffect: string;
  148935. private _scene;
  148936. private _depthTexture;
  148937. private _grainTexture;
  148938. private _chromaticAberrationPostProcess;
  148939. private _highlightsPostProcess;
  148940. private _depthOfFieldPostProcess;
  148941. private _edgeBlur;
  148942. private _grainAmount;
  148943. private _chromaticAberration;
  148944. private _distortion;
  148945. private _highlightsGain;
  148946. private _highlightsThreshold;
  148947. private _dofDistance;
  148948. private _dofAperture;
  148949. private _dofDarken;
  148950. private _dofPentagon;
  148951. private _blurNoise;
  148952. /**
  148953. * @constructor
  148954. *
  148955. * Effect parameters are as follow:
  148956. * {
  148957. * chromatic_aberration: number; // from 0 to x (1 for realism)
  148958. * edge_blur: number; // from 0 to x (1 for realism)
  148959. * distortion: number; // from 0 to x (1 for realism)
  148960. * grain_amount: number; // from 0 to 1
  148961. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  148962. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  148963. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  148964. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  148965. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  148966. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  148967. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  148968. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  148969. * }
  148970. * Note: if an effect parameter is unset, effect is disabled
  148971. *
  148972. * @param name The rendering pipeline name
  148973. * @param parameters - An object containing all parameters (see above)
  148974. * @param scene The scene linked to this pipeline
  148975. * @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)
  148976. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148977. */
  148978. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  148979. /**
  148980. * Get the class name
  148981. * @returns "LensRenderingPipeline"
  148982. */
  148983. getClassName(): string;
  148984. /**
  148985. * Gets associated scene
  148986. */
  148987. get scene(): Scene;
  148988. /**
  148989. * Gets or sets the edge blur
  148990. */
  148991. get edgeBlur(): number;
  148992. set edgeBlur(value: number);
  148993. /**
  148994. * Gets or sets the grain amount
  148995. */
  148996. get grainAmount(): number;
  148997. set grainAmount(value: number);
  148998. /**
  148999. * Gets or sets the chromatic aberration amount
  149000. */
  149001. get chromaticAberration(): number;
  149002. set chromaticAberration(value: number);
  149003. /**
  149004. * Gets or sets the depth of field aperture
  149005. */
  149006. get dofAperture(): number;
  149007. set dofAperture(value: number);
  149008. /**
  149009. * Gets or sets the edge distortion
  149010. */
  149011. get edgeDistortion(): number;
  149012. set edgeDistortion(value: number);
  149013. /**
  149014. * Gets or sets the depth of field distortion
  149015. */
  149016. get dofDistortion(): number;
  149017. set dofDistortion(value: number);
  149018. /**
  149019. * Gets or sets the darken out of focus amount
  149020. */
  149021. get darkenOutOfFocus(): number;
  149022. set darkenOutOfFocus(value: number);
  149023. /**
  149024. * Gets or sets a boolean indicating if blur noise is enabled
  149025. */
  149026. get blurNoise(): boolean;
  149027. set blurNoise(value: boolean);
  149028. /**
  149029. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  149030. */
  149031. get pentagonBokeh(): boolean;
  149032. set pentagonBokeh(value: boolean);
  149033. /**
  149034. * Gets or sets the highlight grain amount
  149035. */
  149036. get highlightsGain(): number;
  149037. set highlightsGain(value: number);
  149038. /**
  149039. * Gets or sets the highlight threshold
  149040. */
  149041. get highlightsThreshold(): number;
  149042. set highlightsThreshold(value: number);
  149043. /**
  149044. * Sets the amount of blur at the edges
  149045. * @param amount blur amount
  149046. */
  149047. setEdgeBlur(amount: number): void;
  149048. /**
  149049. * Sets edge blur to 0
  149050. */
  149051. disableEdgeBlur(): void;
  149052. /**
  149053. * Sets the amout of grain
  149054. * @param amount Amount of grain
  149055. */
  149056. setGrainAmount(amount: number): void;
  149057. /**
  149058. * Set grain amount to 0
  149059. */
  149060. disableGrain(): void;
  149061. /**
  149062. * Sets the chromatic aberration amount
  149063. * @param amount amount of chromatic aberration
  149064. */
  149065. setChromaticAberration(amount: number): void;
  149066. /**
  149067. * Sets chromatic aberration amount to 0
  149068. */
  149069. disableChromaticAberration(): void;
  149070. /**
  149071. * Sets the EdgeDistortion amount
  149072. * @param amount amount of EdgeDistortion
  149073. */
  149074. setEdgeDistortion(amount: number): void;
  149075. /**
  149076. * Sets edge distortion to 0
  149077. */
  149078. disableEdgeDistortion(): void;
  149079. /**
  149080. * Sets the FocusDistance amount
  149081. * @param amount amount of FocusDistance
  149082. */
  149083. setFocusDistance(amount: number): void;
  149084. /**
  149085. * Disables depth of field
  149086. */
  149087. disableDepthOfField(): void;
  149088. /**
  149089. * Sets the Aperture amount
  149090. * @param amount amount of Aperture
  149091. */
  149092. setAperture(amount: number): void;
  149093. /**
  149094. * Sets the DarkenOutOfFocus amount
  149095. * @param amount amount of DarkenOutOfFocus
  149096. */
  149097. setDarkenOutOfFocus(amount: number): void;
  149098. private _pentagonBokehIsEnabled;
  149099. /**
  149100. * Creates a pentagon bokeh effect
  149101. */
  149102. enablePentagonBokeh(): void;
  149103. /**
  149104. * Disables the pentagon bokeh effect
  149105. */
  149106. disablePentagonBokeh(): void;
  149107. /**
  149108. * Enables noise blur
  149109. */
  149110. enableNoiseBlur(): void;
  149111. /**
  149112. * Disables noise blur
  149113. */
  149114. disableNoiseBlur(): void;
  149115. /**
  149116. * Sets the HighlightsGain amount
  149117. * @param amount amount of HighlightsGain
  149118. */
  149119. setHighlightsGain(amount: number): void;
  149120. /**
  149121. * Sets the HighlightsThreshold amount
  149122. * @param amount amount of HighlightsThreshold
  149123. */
  149124. setHighlightsThreshold(amount: number): void;
  149125. /**
  149126. * Disables highlights
  149127. */
  149128. disableHighlights(): void;
  149129. /**
  149130. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  149131. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  149132. */
  149133. dispose(disableDepthRender?: boolean): void;
  149134. private _createChromaticAberrationPostProcess;
  149135. private _createHighlightsPostProcess;
  149136. private _createDepthOfFieldPostProcess;
  149137. private _createGrainTexture;
  149138. }
  149139. }
  149140. declare module BABYLON {
  149141. /** @hidden */
  149142. export var ssao2PixelShader: {
  149143. name: string;
  149144. shader: string;
  149145. };
  149146. }
  149147. declare module BABYLON {
  149148. /** @hidden */
  149149. export var ssaoCombinePixelShader: {
  149150. name: string;
  149151. shader: string;
  149152. };
  149153. }
  149154. declare module BABYLON {
  149155. /**
  149156. * Render pipeline to produce ssao effect
  149157. */
  149158. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  149159. /**
  149160. * @ignore
  149161. * The PassPostProcess id in the pipeline that contains the original scene color
  149162. */
  149163. SSAOOriginalSceneColorEffect: string;
  149164. /**
  149165. * @ignore
  149166. * The SSAO PostProcess id in the pipeline
  149167. */
  149168. SSAORenderEffect: string;
  149169. /**
  149170. * @ignore
  149171. * The horizontal blur PostProcess id in the pipeline
  149172. */
  149173. SSAOBlurHRenderEffect: string;
  149174. /**
  149175. * @ignore
  149176. * The vertical blur PostProcess id in the pipeline
  149177. */
  149178. SSAOBlurVRenderEffect: string;
  149179. /**
  149180. * @ignore
  149181. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149182. */
  149183. SSAOCombineRenderEffect: string;
  149184. /**
  149185. * The output strength of the SSAO post-process. Default value is 1.0.
  149186. */
  149187. totalStrength: number;
  149188. /**
  149189. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  149190. */
  149191. maxZ: number;
  149192. /**
  149193. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  149194. */
  149195. minZAspect: number;
  149196. private _samples;
  149197. /**
  149198. * Number of samples used for the SSAO calculations. Default value is 8
  149199. */
  149200. set samples(n: number);
  149201. get samples(): number;
  149202. private _textureSamples;
  149203. /**
  149204. * Number of samples to use for antialiasing
  149205. */
  149206. set textureSamples(n: number);
  149207. get textureSamples(): number;
  149208. /**
  149209. * Force rendering the geometry through geometry buffer
  149210. */
  149211. private _forceGeometryBuffer;
  149212. /**
  149213. * Ratio object used for SSAO ratio and blur ratio
  149214. */
  149215. private _ratio;
  149216. /**
  149217. * Dynamically generated sphere sampler.
  149218. */
  149219. private _sampleSphere;
  149220. /**
  149221. * Blur filter offsets
  149222. */
  149223. private _samplerOffsets;
  149224. private _expensiveBlur;
  149225. /**
  149226. * If bilateral blur should be used
  149227. */
  149228. set expensiveBlur(b: boolean);
  149229. get expensiveBlur(): boolean;
  149230. /**
  149231. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  149232. */
  149233. radius: number;
  149234. /**
  149235. * The base color of the SSAO post-process
  149236. * The final result is "base + ssao" between [0, 1]
  149237. */
  149238. base: number;
  149239. /**
  149240. * Support test.
  149241. */
  149242. static get IsSupported(): boolean;
  149243. private _scene;
  149244. private _randomTexture;
  149245. private _originalColorPostProcess;
  149246. private _ssaoPostProcess;
  149247. private _blurHPostProcess;
  149248. private _blurVPostProcess;
  149249. private _ssaoCombinePostProcess;
  149250. private _prePassRenderer;
  149251. /**
  149252. * Gets active scene
  149253. */
  149254. get scene(): Scene;
  149255. /**
  149256. * @constructor
  149257. * @param name The rendering pipeline name
  149258. * @param scene The scene linked to this pipeline
  149259. * @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 }
  149260. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149261. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  149262. */
  149263. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  149264. /**
  149265. * Get the class name
  149266. * @returns "SSAO2RenderingPipeline"
  149267. */
  149268. getClassName(): string;
  149269. /**
  149270. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149271. */
  149272. dispose(disableGeometryBufferRenderer?: boolean): void;
  149273. private _createBlurPostProcess;
  149274. /** @hidden */
  149275. _rebuild(): void;
  149276. private _bits;
  149277. private _radicalInverse_VdC;
  149278. private _hammersley;
  149279. private _hemisphereSample_uniform;
  149280. private _generateHemisphere;
  149281. private _getDefinesForSSAO;
  149282. private _createSSAOPostProcess;
  149283. private _createSSAOCombinePostProcess;
  149284. private _createRandomTexture;
  149285. /**
  149286. * Serialize the rendering pipeline (Used when exporting)
  149287. * @returns the serialized object
  149288. */
  149289. serialize(): any;
  149290. /**
  149291. * Parse the serialized pipeline
  149292. * @param source Source pipeline.
  149293. * @param scene The scene to load the pipeline to.
  149294. * @param rootUrl The URL of the serialized pipeline.
  149295. * @returns An instantiated pipeline from the serialized object.
  149296. */
  149297. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  149298. /**
  149299. * Sets the required values to the prepass renderer.
  149300. * @param prePassRenderer defines the prepass renderer to setup
  149301. * @returns true if the pre pass is needed.
  149302. */
  149303. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149304. }
  149305. }
  149306. declare module BABYLON {
  149307. /** @hidden */
  149308. export var ssaoPixelShader: {
  149309. name: string;
  149310. shader: string;
  149311. };
  149312. }
  149313. declare module BABYLON {
  149314. /**
  149315. * Render pipeline to produce ssao effect
  149316. */
  149317. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  149318. /**
  149319. * @ignore
  149320. * The PassPostProcess id in the pipeline that contains the original scene color
  149321. */
  149322. SSAOOriginalSceneColorEffect: string;
  149323. /**
  149324. * @ignore
  149325. * The SSAO PostProcess id in the pipeline
  149326. */
  149327. SSAORenderEffect: string;
  149328. /**
  149329. * @ignore
  149330. * The horizontal blur PostProcess id in the pipeline
  149331. */
  149332. SSAOBlurHRenderEffect: string;
  149333. /**
  149334. * @ignore
  149335. * The vertical blur PostProcess id in the pipeline
  149336. */
  149337. SSAOBlurVRenderEffect: string;
  149338. /**
  149339. * @ignore
  149340. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149341. */
  149342. SSAOCombineRenderEffect: string;
  149343. /**
  149344. * The output strength of the SSAO post-process. Default value is 1.0.
  149345. */
  149346. totalStrength: number;
  149347. /**
  149348. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  149349. */
  149350. radius: number;
  149351. /**
  149352. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  149353. * Must not be equal to fallOff and superior to fallOff.
  149354. * Default value is 0.0075
  149355. */
  149356. area: number;
  149357. /**
  149358. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  149359. * Must not be equal to area and inferior to area.
  149360. * Default value is 0.000001
  149361. */
  149362. fallOff: number;
  149363. /**
  149364. * The base color of the SSAO post-process
  149365. * The final result is "base + ssao" between [0, 1]
  149366. */
  149367. base: number;
  149368. private _scene;
  149369. private _depthTexture;
  149370. private _randomTexture;
  149371. private _originalColorPostProcess;
  149372. private _ssaoPostProcess;
  149373. private _blurHPostProcess;
  149374. private _blurVPostProcess;
  149375. private _ssaoCombinePostProcess;
  149376. private _firstUpdate;
  149377. /**
  149378. * Gets active scene
  149379. */
  149380. get scene(): Scene;
  149381. /**
  149382. * @constructor
  149383. * @param name - The rendering pipeline name
  149384. * @param scene - The scene linked to this pipeline
  149385. * @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 }
  149386. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  149387. */
  149388. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  149389. /**
  149390. * Get the class name
  149391. * @returns "SSAORenderingPipeline"
  149392. */
  149393. getClassName(): string;
  149394. /**
  149395. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149396. */
  149397. dispose(disableDepthRender?: boolean): void;
  149398. private _createBlurPostProcess;
  149399. /** @hidden */
  149400. _rebuild(): void;
  149401. private _createSSAOPostProcess;
  149402. private _createSSAOCombinePostProcess;
  149403. private _createRandomTexture;
  149404. }
  149405. }
  149406. declare module BABYLON {
  149407. /** @hidden */
  149408. export var screenSpaceReflectionPixelShader: {
  149409. name: string;
  149410. shader: string;
  149411. };
  149412. }
  149413. declare module BABYLON {
  149414. /**
  149415. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  149416. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  149417. */
  149418. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  149419. /**
  149420. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  149421. */
  149422. threshold: number;
  149423. /**
  149424. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  149425. */
  149426. strength: number;
  149427. /**
  149428. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  149429. */
  149430. reflectionSpecularFalloffExponent: number;
  149431. /**
  149432. * 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]
  149433. */
  149434. step: number;
  149435. /**
  149436. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  149437. */
  149438. roughnessFactor: number;
  149439. private _geometryBufferRenderer;
  149440. private _enableSmoothReflections;
  149441. private _reflectionSamples;
  149442. private _smoothSteps;
  149443. /**
  149444. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  149445. * @param name The name of the effect.
  149446. * @param scene The scene containing the objects to calculate reflections.
  149447. * @param options The required width/height ratio to downsize to before computing the render pass.
  149448. * @param camera The camera to apply the render pass to.
  149449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149450. * @param engine The engine which the post process will be applied. (default: current engine)
  149451. * @param reusable If the post process can be reused on the same frame. (default: false)
  149452. * @param textureType Type of textures used when performing the post process. (default: 0)
  149453. * @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)
  149454. */
  149455. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149456. /**
  149457. * Gets wether or not smoothing reflections is enabled.
  149458. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149459. */
  149460. get enableSmoothReflections(): boolean;
  149461. /**
  149462. * Sets wether or not smoothing reflections is enabled.
  149463. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149464. */
  149465. set enableSmoothReflections(enabled: boolean);
  149466. /**
  149467. * Gets the number of samples taken while computing reflections. More samples count is high,
  149468. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149469. */
  149470. get reflectionSamples(): number;
  149471. /**
  149472. * Sets the number of samples taken while computing reflections. More samples count is high,
  149473. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149474. */
  149475. set reflectionSamples(samples: number);
  149476. /**
  149477. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  149478. * more the post-process will require GPU power and can generate a drop in FPS.
  149479. * Default value (5.0) work pretty well in all cases but can be adjusted.
  149480. */
  149481. get smoothSteps(): number;
  149482. set smoothSteps(steps: number);
  149483. private _updateEffectDefines;
  149484. }
  149485. }
  149486. declare module BABYLON {
  149487. /** @hidden */
  149488. export var standardPixelShader: {
  149489. name: string;
  149490. shader: string;
  149491. };
  149492. }
  149493. declare module BABYLON {
  149494. /**
  149495. * Standard rendering pipeline
  149496. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149497. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  149498. */
  149499. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149500. /**
  149501. * Public members
  149502. */
  149503. /**
  149504. * Post-process which contains the original scene color before the pipeline applies all the effects
  149505. */
  149506. originalPostProcess: Nullable<PostProcess>;
  149507. /**
  149508. * Post-process used to down scale an image x4
  149509. */
  149510. downSampleX4PostProcess: Nullable<PostProcess>;
  149511. /**
  149512. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  149513. */
  149514. brightPassPostProcess: Nullable<PostProcess>;
  149515. /**
  149516. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  149517. */
  149518. blurHPostProcesses: PostProcess[];
  149519. /**
  149520. * Post-process array storing all the vertical blur post-processes used by the pipeline
  149521. */
  149522. blurVPostProcesses: PostProcess[];
  149523. /**
  149524. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  149525. */
  149526. textureAdderPostProcess: Nullable<PostProcess>;
  149527. /**
  149528. * Post-process used to create volumetric lighting effect
  149529. */
  149530. volumetricLightPostProcess: Nullable<PostProcess>;
  149531. /**
  149532. * Post-process used to smooth the previous volumetric light post-process on the X axis
  149533. */
  149534. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  149535. /**
  149536. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  149537. */
  149538. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  149539. /**
  149540. * Post-process used to merge the volumetric light effect and the real scene color
  149541. */
  149542. volumetricLightMergePostProces: Nullable<PostProcess>;
  149543. /**
  149544. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  149545. */
  149546. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  149547. /**
  149548. * Base post-process used to calculate the average luminance of the final image for HDR
  149549. */
  149550. luminancePostProcess: Nullable<PostProcess>;
  149551. /**
  149552. * Post-processes used to create down sample post-processes in order to get
  149553. * the average luminance of the final image for HDR
  149554. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  149555. */
  149556. luminanceDownSamplePostProcesses: PostProcess[];
  149557. /**
  149558. * Post-process used to create a HDR effect (light adaptation)
  149559. */
  149560. hdrPostProcess: Nullable<PostProcess>;
  149561. /**
  149562. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  149563. */
  149564. textureAdderFinalPostProcess: Nullable<PostProcess>;
  149565. /**
  149566. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  149567. */
  149568. lensFlareFinalPostProcess: Nullable<PostProcess>;
  149569. /**
  149570. * Post-process used to merge the final HDR post-process and the real scene color
  149571. */
  149572. hdrFinalPostProcess: Nullable<PostProcess>;
  149573. /**
  149574. * Post-process used to create a lens flare effect
  149575. */
  149576. lensFlarePostProcess: Nullable<PostProcess>;
  149577. /**
  149578. * Post-process that merges the result of the lens flare post-process and the real scene color
  149579. */
  149580. lensFlareComposePostProcess: Nullable<PostProcess>;
  149581. /**
  149582. * Post-process used to create a motion blur effect
  149583. */
  149584. motionBlurPostProcess: Nullable<PostProcess>;
  149585. /**
  149586. * Post-process used to create a depth of field effect
  149587. */
  149588. depthOfFieldPostProcess: Nullable<PostProcess>;
  149589. /**
  149590. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149591. */
  149592. fxaaPostProcess: Nullable<FxaaPostProcess>;
  149593. /**
  149594. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  149595. */
  149596. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  149597. /**
  149598. * Represents the brightness threshold in order to configure the illuminated surfaces
  149599. */
  149600. brightThreshold: number;
  149601. /**
  149602. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  149603. */
  149604. blurWidth: number;
  149605. /**
  149606. * Sets if the blur for highlighted surfaces must be only horizontal
  149607. */
  149608. horizontalBlur: boolean;
  149609. /**
  149610. * Gets the overall exposure used by the pipeline
  149611. */
  149612. get exposure(): number;
  149613. /**
  149614. * Sets the overall exposure used by the pipeline
  149615. */
  149616. set exposure(value: number);
  149617. /**
  149618. * Texture used typically to simulate "dirty" on camera lens
  149619. */
  149620. lensTexture: Nullable<Texture>;
  149621. /**
  149622. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  149623. */
  149624. volumetricLightCoefficient: number;
  149625. /**
  149626. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  149627. */
  149628. volumetricLightPower: number;
  149629. /**
  149630. * Used the set the blur intensity to smooth the volumetric lights
  149631. */
  149632. volumetricLightBlurScale: number;
  149633. /**
  149634. * Light (spot or directional) used to generate the volumetric lights rays
  149635. * The source light must have a shadow generate so the pipeline can get its
  149636. * depth map
  149637. */
  149638. sourceLight: Nullable<SpotLight | DirectionalLight>;
  149639. /**
  149640. * For eye adaptation, represents the minimum luminance the eye can see
  149641. */
  149642. hdrMinimumLuminance: number;
  149643. /**
  149644. * For eye adaptation, represents the decrease luminance speed
  149645. */
  149646. hdrDecreaseRate: number;
  149647. /**
  149648. * For eye adaptation, represents the increase luminance speed
  149649. */
  149650. hdrIncreaseRate: number;
  149651. /**
  149652. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149653. */
  149654. get hdrAutoExposure(): boolean;
  149655. /**
  149656. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149657. */
  149658. set hdrAutoExposure(value: boolean);
  149659. /**
  149660. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  149661. */
  149662. lensColorTexture: Nullable<Texture>;
  149663. /**
  149664. * The overall strengh for the lens flare effect
  149665. */
  149666. lensFlareStrength: number;
  149667. /**
  149668. * Dispersion coefficient for lens flare ghosts
  149669. */
  149670. lensFlareGhostDispersal: number;
  149671. /**
  149672. * Main lens flare halo width
  149673. */
  149674. lensFlareHaloWidth: number;
  149675. /**
  149676. * Based on the lens distortion effect, defines how much the lens flare result
  149677. * is distorted
  149678. */
  149679. lensFlareDistortionStrength: number;
  149680. /**
  149681. * Configures the blur intensity used for for lens flare (halo)
  149682. */
  149683. lensFlareBlurWidth: number;
  149684. /**
  149685. * Lens star texture must be used to simulate rays on the flares and is available
  149686. * in the documentation
  149687. */
  149688. lensStarTexture: Nullable<Texture>;
  149689. /**
  149690. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  149691. * flare effect by taking account of the dirt texture
  149692. */
  149693. lensFlareDirtTexture: Nullable<Texture>;
  149694. /**
  149695. * Represents the focal length for the depth of field effect
  149696. */
  149697. depthOfFieldDistance: number;
  149698. /**
  149699. * Represents the blur intensity for the blurred part of the depth of field effect
  149700. */
  149701. depthOfFieldBlurWidth: number;
  149702. /**
  149703. * Gets how much the image is blurred by the movement while using the motion blur post-process
  149704. */
  149705. get motionStrength(): number;
  149706. /**
  149707. * Sets how much the image is blurred by the movement while using the motion blur post-process
  149708. */
  149709. set motionStrength(strength: number);
  149710. /**
  149711. * Gets wether or not the motion blur post-process is object based or screen based.
  149712. */
  149713. get objectBasedMotionBlur(): boolean;
  149714. /**
  149715. * Sets wether or not the motion blur post-process should be object based or screen based
  149716. */
  149717. set objectBasedMotionBlur(value: boolean);
  149718. /**
  149719. * List of animations for the pipeline (IAnimatable implementation)
  149720. */
  149721. animations: Animation[];
  149722. /**
  149723. * Private members
  149724. */
  149725. private _scene;
  149726. private _currentDepthOfFieldSource;
  149727. private _basePostProcess;
  149728. private _fixedExposure;
  149729. private _currentExposure;
  149730. private _hdrAutoExposure;
  149731. private _hdrCurrentLuminance;
  149732. private _motionStrength;
  149733. private _isObjectBasedMotionBlur;
  149734. private _floatTextureType;
  149735. private _camerasToBeAttached;
  149736. private _ratio;
  149737. private _bloomEnabled;
  149738. private _depthOfFieldEnabled;
  149739. private _vlsEnabled;
  149740. private _lensFlareEnabled;
  149741. private _hdrEnabled;
  149742. private _motionBlurEnabled;
  149743. private _fxaaEnabled;
  149744. private _screenSpaceReflectionsEnabled;
  149745. private _motionBlurSamples;
  149746. private _volumetricLightStepsCount;
  149747. private _samples;
  149748. /**
  149749. * @ignore
  149750. * Specifies if the bloom pipeline is enabled
  149751. */
  149752. get BloomEnabled(): boolean;
  149753. set BloomEnabled(enabled: boolean);
  149754. /**
  149755. * @ignore
  149756. * Specifies if the depth of field pipeline is enabed
  149757. */
  149758. get DepthOfFieldEnabled(): boolean;
  149759. set DepthOfFieldEnabled(enabled: boolean);
  149760. /**
  149761. * @ignore
  149762. * Specifies if the lens flare pipeline is enabed
  149763. */
  149764. get LensFlareEnabled(): boolean;
  149765. set LensFlareEnabled(enabled: boolean);
  149766. /**
  149767. * @ignore
  149768. * Specifies if the HDR pipeline is enabled
  149769. */
  149770. get HDREnabled(): boolean;
  149771. set HDREnabled(enabled: boolean);
  149772. /**
  149773. * @ignore
  149774. * Specifies if the volumetric lights scattering effect is enabled
  149775. */
  149776. get VLSEnabled(): boolean;
  149777. set VLSEnabled(enabled: boolean);
  149778. /**
  149779. * @ignore
  149780. * Specifies if the motion blur effect is enabled
  149781. */
  149782. get MotionBlurEnabled(): boolean;
  149783. set MotionBlurEnabled(enabled: boolean);
  149784. /**
  149785. * Specifies if anti-aliasing is enabled
  149786. */
  149787. get fxaaEnabled(): boolean;
  149788. set fxaaEnabled(enabled: boolean);
  149789. /**
  149790. * Specifies if screen space reflections are enabled.
  149791. */
  149792. get screenSpaceReflectionsEnabled(): boolean;
  149793. set screenSpaceReflectionsEnabled(enabled: boolean);
  149794. /**
  149795. * Specifies the number of steps used to calculate the volumetric lights
  149796. * Typically in interval [50, 200]
  149797. */
  149798. get volumetricLightStepsCount(): number;
  149799. set volumetricLightStepsCount(count: number);
  149800. /**
  149801. * Specifies the number of samples used for the motion blur effect
  149802. * Typically in interval [16, 64]
  149803. */
  149804. get motionBlurSamples(): number;
  149805. set motionBlurSamples(samples: number);
  149806. /**
  149807. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149808. */
  149809. get samples(): number;
  149810. set samples(sampleCount: number);
  149811. /**
  149812. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149813. * @constructor
  149814. * @param name The rendering pipeline name
  149815. * @param scene The scene linked to this pipeline
  149816. * @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)
  149817. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  149818. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149819. */
  149820. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  149821. private _buildPipeline;
  149822. private _createDownSampleX4PostProcess;
  149823. private _createBrightPassPostProcess;
  149824. private _createBlurPostProcesses;
  149825. private _createTextureAdderPostProcess;
  149826. private _createVolumetricLightPostProcess;
  149827. private _createLuminancePostProcesses;
  149828. private _createHdrPostProcess;
  149829. private _createLensFlarePostProcess;
  149830. private _createDepthOfFieldPostProcess;
  149831. private _createMotionBlurPostProcess;
  149832. private _getDepthTexture;
  149833. private _disposePostProcesses;
  149834. /**
  149835. * Dispose of the pipeline and stop all post processes
  149836. */
  149837. dispose(): void;
  149838. /**
  149839. * Serialize the rendering pipeline (Used when exporting)
  149840. * @returns the serialized object
  149841. */
  149842. serialize(): any;
  149843. /**
  149844. * Parse the serialized pipeline
  149845. * @param source Source pipeline.
  149846. * @param scene The scene to load the pipeline to.
  149847. * @param rootUrl The URL of the serialized pipeline.
  149848. * @returns An instantiated pipeline from the serialized object.
  149849. */
  149850. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  149851. /**
  149852. * Luminance steps
  149853. */
  149854. static LuminanceSteps: number;
  149855. }
  149856. }
  149857. declare module BABYLON {
  149858. /** @hidden */
  149859. export var stereoscopicInterlacePixelShader: {
  149860. name: string;
  149861. shader: string;
  149862. };
  149863. }
  149864. declare module BABYLON {
  149865. /**
  149866. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  149867. */
  149868. export class StereoscopicInterlacePostProcessI extends PostProcess {
  149869. private _stepSize;
  149870. private _passedProcess;
  149871. /**
  149872. * Initializes a StereoscopicInterlacePostProcessI
  149873. * @param name The name of the effect.
  149874. * @param rigCameras The rig cameras to be appled to the post process
  149875. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  149876. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  149877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149878. * @param engine The engine which the post process will be applied. (default: current engine)
  149879. * @param reusable If the post process can be reused on the same frame. (default: false)
  149880. */
  149881. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149882. }
  149883. /**
  149884. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  149885. */
  149886. export class StereoscopicInterlacePostProcess extends PostProcess {
  149887. private _stepSize;
  149888. private _passedProcess;
  149889. /**
  149890. * Initializes a StereoscopicInterlacePostProcess
  149891. * @param name The name of the effect.
  149892. * @param rigCameras The rig cameras to be appled to the post process
  149893. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  149894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149895. * @param engine The engine which the post process will be applied. (default: current engine)
  149896. * @param reusable If the post process can be reused on the same frame. (default: false)
  149897. */
  149898. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149899. }
  149900. }
  149901. declare module BABYLON {
  149902. /** @hidden */
  149903. export var tonemapPixelShader: {
  149904. name: string;
  149905. shader: string;
  149906. };
  149907. }
  149908. declare module BABYLON {
  149909. /** Defines operator used for tonemapping */
  149910. export enum TonemappingOperator {
  149911. /** Hable */
  149912. Hable = 0,
  149913. /** Reinhard */
  149914. Reinhard = 1,
  149915. /** HejiDawson */
  149916. HejiDawson = 2,
  149917. /** Photographic */
  149918. Photographic = 3
  149919. }
  149920. /**
  149921. * Defines a post process to apply tone mapping
  149922. */
  149923. export class TonemapPostProcess extends PostProcess {
  149924. private _operator;
  149925. /** Defines the required exposure adjustement */
  149926. exposureAdjustment: number;
  149927. /**
  149928. * Creates a new TonemapPostProcess
  149929. * @param name defines the name of the postprocess
  149930. * @param _operator defines the operator to use
  149931. * @param exposureAdjustment defines the required exposure adjustement
  149932. * @param camera defines the camera to use (can be null)
  149933. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  149934. * @param engine defines the hosting engine (can be ignore if camera is set)
  149935. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  149936. */
  149937. constructor(name: string, _operator: TonemappingOperator,
  149938. /** Defines the required exposure adjustement */
  149939. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  149940. }
  149941. }
  149942. declare module BABYLON {
  149943. /** @hidden */
  149944. export var volumetricLightScatteringPixelShader: {
  149945. name: string;
  149946. shader: string;
  149947. };
  149948. }
  149949. declare module BABYLON {
  149950. /** @hidden */
  149951. export var volumetricLightScatteringPassVertexShader: {
  149952. name: string;
  149953. shader: string;
  149954. };
  149955. }
  149956. declare module BABYLON {
  149957. /** @hidden */
  149958. export var volumetricLightScatteringPassPixelShader: {
  149959. name: string;
  149960. shader: string;
  149961. };
  149962. }
  149963. declare module BABYLON {
  149964. /**
  149965. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  149966. */
  149967. export class VolumetricLightScatteringPostProcess extends PostProcess {
  149968. private _volumetricLightScatteringPass;
  149969. private _volumetricLightScatteringRTT;
  149970. private _viewPort;
  149971. private _screenCoordinates;
  149972. private _cachedDefines;
  149973. /**
  149974. * If not undefined, the mesh position is computed from the attached node position
  149975. */
  149976. attachedNode: {
  149977. position: Vector3;
  149978. };
  149979. /**
  149980. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  149981. */
  149982. customMeshPosition: Vector3;
  149983. /**
  149984. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  149985. */
  149986. useCustomMeshPosition: boolean;
  149987. /**
  149988. * If the post-process should inverse the light scattering direction
  149989. */
  149990. invert: boolean;
  149991. /**
  149992. * The internal mesh used by the post-process
  149993. */
  149994. mesh: Mesh;
  149995. /**
  149996. * @hidden
  149997. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  149998. */
  149999. get useDiffuseColor(): boolean;
  150000. set useDiffuseColor(useDiffuseColor: boolean);
  150001. /**
  150002. * Array containing the excluded meshes not rendered in the internal pass
  150003. */
  150004. excludedMeshes: AbstractMesh[];
  150005. /**
  150006. * Controls the overall intensity of the post-process
  150007. */
  150008. exposure: number;
  150009. /**
  150010. * Dissipates each sample's contribution in range [0, 1]
  150011. */
  150012. decay: number;
  150013. /**
  150014. * Controls the overall intensity of each sample
  150015. */
  150016. weight: number;
  150017. /**
  150018. * Controls the density of each sample
  150019. */
  150020. density: number;
  150021. /**
  150022. * @constructor
  150023. * @param name The post-process name
  150024. * @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)
  150025. * @param camera The camera that the post-process will be attached to
  150026. * @param mesh The mesh used to create the light scattering
  150027. * @param samples The post-process quality, default 100
  150028. * @param samplingModeThe post-process filtering mode
  150029. * @param engine The babylon engine
  150030. * @param reusable If the post-process is reusable
  150031. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  150032. */
  150033. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  150034. /**
  150035. * Returns the string "VolumetricLightScatteringPostProcess"
  150036. * @returns "VolumetricLightScatteringPostProcess"
  150037. */
  150038. getClassName(): string;
  150039. private _isReady;
  150040. /**
  150041. * Sets the new light position for light scattering effect
  150042. * @param position The new custom light position
  150043. */
  150044. setCustomMeshPosition(position: Vector3): void;
  150045. /**
  150046. * Returns the light position for light scattering effect
  150047. * @return Vector3 The custom light position
  150048. */
  150049. getCustomMeshPosition(): Vector3;
  150050. /**
  150051. * Disposes the internal assets and detaches the post-process from the camera
  150052. */
  150053. dispose(camera: Camera): void;
  150054. /**
  150055. * Returns the render target texture used by the post-process
  150056. * @return the render target texture used by the post-process
  150057. */
  150058. getPass(): RenderTargetTexture;
  150059. private _meshExcluded;
  150060. private _createPass;
  150061. private _updateMeshScreenCoordinates;
  150062. /**
  150063. * Creates a default mesh for the Volumeric Light Scattering post-process
  150064. * @param name The mesh name
  150065. * @param scene The scene where to create the mesh
  150066. * @return the default mesh
  150067. */
  150068. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  150069. }
  150070. }
  150071. declare module BABYLON {
  150072. /** @hidden */
  150073. export var screenSpaceCurvaturePixelShader: {
  150074. name: string;
  150075. shader: string;
  150076. };
  150077. }
  150078. declare module BABYLON {
  150079. /**
  150080. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  150081. */
  150082. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  150083. /**
  150084. * Defines how much ridge the curvature effect displays.
  150085. */
  150086. ridge: number;
  150087. /**
  150088. * Defines how much valley the curvature effect displays.
  150089. */
  150090. valley: number;
  150091. private _geometryBufferRenderer;
  150092. /**
  150093. * Creates a new instance ScreenSpaceCurvaturePostProcess
  150094. * @param name The name of the effect.
  150095. * @param scene The scene containing the objects to blur according to their velocity.
  150096. * @param options The required width/height ratio to downsize to before computing the render pass.
  150097. * @param camera The camera to apply the render pass to.
  150098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150099. * @param engine The engine which the post process will be applied. (default: current engine)
  150100. * @param reusable If the post process can be reused on the same frame. (default: false)
  150101. * @param textureType Type of textures used when performing the post process. (default: 0)
  150102. * @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)
  150103. */
  150104. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150105. /**
  150106. * Support test.
  150107. */
  150108. static get IsSupported(): boolean;
  150109. }
  150110. }
  150111. declare module BABYLON {
  150112. interface Scene {
  150113. /** @hidden (Backing field) */
  150114. _boundingBoxRenderer: BoundingBoxRenderer;
  150115. /** @hidden (Backing field) */
  150116. _forceShowBoundingBoxes: boolean;
  150117. /**
  150118. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  150119. */
  150120. forceShowBoundingBoxes: boolean;
  150121. /**
  150122. * Gets the bounding box renderer associated with the scene
  150123. * @returns a BoundingBoxRenderer
  150124. */
  150125. getBoundingBoxRenderer(): BoundingBoxRenderer;
  150126. }
  150127. interface AbstractMesh {
  150128. /** @hidden (Backing field) */
  150129. _showBoundingBox: boolean;
  150130. /**
  150131. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  150132. */
  150133. showBoundingBox: boolean;
  150134. }
  150135. /**
  150136. * Component responsible of rendering the bounding box of the meshes in a scene.
  150137. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  150138. */
  150139. export class BoundingBoxRenderer implements ISceneComponent {
  150140. /**
  150141. * The component name helpfull to identify the component in the list of scene components.
  150142. */
  150143. readonly name: string;
  150144. /**
  150145. * The scene the component belongs to.
  150146. */
  150147. scene: Scene;
  150148. /**
  150149. * Color of the bounding box lines placed in front of an object
  150150. */
  150151. frontColor: Color3;
  150152. /**
  150153. * Color of the bounding box lines placed behind an object
  150154. */
  150155. backColor: Color3;
  150156. /**
  150157. * Defines if the renderer should show the back lines or not
  150158. */
  150159. showBackLines: boolean;
  150160. /**
  150161. * Observable raised before rendering a bounding box
  150162. */
  150163. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  150164. /**
  150165. * Observable raised after rendering a bounding box
  150166. */
  150167. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  150168. /**
  150169. * @hidden
  150170. */
  150171. renderList: SmartArray<BoundingBox>;
  150172. private _colorShader;
  150173. private _vertexBuffers;
  150174. private _indexBuffer;
  150175. private _fillIndexBuffer;
  150176. private _fillIndexData;
  150177. /**
  150178. * Instantiates a new bounding box renderer in a scene.
  150179. * @param scene the scene the renderer renders in
  150180. */
  150181. constructor(scene: Scene);
  150182. /**
  150183. * Registers the component in a given scene
  150184. */
  150185. register(): void;
  150186. private _evaluateSubMesh;
  150187. private _activeMesh;
  150188. private _prepareRessources;
  150189. private _createIndexBuffer;
  150190. /**
  150191. * Rebuilds the elements related to this component in case of
  150192. * context lost for instance.
  150193. */
  150194. rebuild(): void;
  150195. /**
  150196. * @hidden
  150197. */
  150198. reset(): void;
  150199. /**
  150200. * Render the bounding boxes of a specific rendering group
  150201. * @param renderingGroupId defines the rendering group to render
  150202. */
  150203. render(renderingGroupId: number): void;
  150204. /**
  150205. * In case of occlusion queries, we can render the occlusion bounding box through this method
  150206. * @param mesh Define the mesh to render the occlusion bounding box for
  150207. */
  150208. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  150209. /**
  150210. * Dispose and release the resources attached to this renderer.
  150211. */
  150212. dispose(): void;
  150213. }
  150214. }
  150215. declare module BABYLON {
  150216. interface Scene {
  150217. /** @hidden (Backing field) */
  150218. _depthRenderer: {
  150219. [id: string]: DepthRenderer;
  150220. };
  150221. /**
  150222. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  150223. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  150224. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  150225. * @returns the created depth renderer
  150226. */
  150227. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  150228. /**
  150229. * Disables a depth renderer for a given camera
  150230. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  150231. */
  150232. disableDepthRenderer(camera?: Nullable<Camera>): void;
  150233. }
  150234. /**
  150235. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  150236. * in several rendering techniques.
  150237. */
  150238. export class DepthRendererSceneComponent implements ISceneComponent {
  150239. /**
  150240. * The component name helpfull to identify the component in the list of scene components.
  150241. */
  150242. readonly name: string;
  150243. /**
  150244. * The scene the component belongs to.
  150245. */
  150246. scene: Scene;
  150247. /**
  150248. * Creates a new instance of the component for the given scene
  150249. * @param scene Defines the scene to register the component in
  150250. */
  150251. constructor(scene: Scene);
  150252. /**
  150253. * Registers the component in a given scene
  150254. */
  150255. register(): void;
  150256. /**
  150257. * Rebuilds the elements related to this component in case of
  150258. * context lost for instance.
  150259. */
  150260. rebuild(): void;
  150261. /**
  150262. * Disposes the component and the associated ressources
  150263. */
  150264. dispose(): void;
  150265. private _gatherRenderTargets;
  150266. private _gatherActiveCameraRenderTargets;
  150267. }
  150268. }
  150269. declare module BABYLON {
  150270. interface AbstractScene {
  150271. /** @hidden (Backing field) */
  150272. _prePassRenderer: Nullable<PrePassRenderer>;
  150273. /**
  150274. * Gets or Sets the current prepass renderer associated to the scene.
  150275. */
  150276. prePassRenderer: Nullable<PrePassRenderer>;
  150277. /**
  150278. * Enables the prepass and associates it with the scene
  150279. * @returns the PrePassRenderer
  150280. */
  150281. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  150282. /**
  150283. * Disables the prepass associated with the scene
  150284. */
  150285. disablePrePassRenderer(): void;
  150286. }
  150287. /**
  150288. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150289. * in several rendering techniques.
  150290. */
  150291. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  150292. /**
  150293. * The component name helpful to identify the component in the list of scene components.
  150294. */
  150295. readonly name: string;
  150296. /**
  150297. * The scene the component belongs to.
  150298. */
  150299. scene: Scene;
  150300. /**
  150301. * Creates a new instance of the component for the given scene
  150302. * @param scene Defines the scene to register the component in
  150303. */
  150304. constructor(scene: Scene);
  150305. /**
  150306. * Registers the component in a given scene
  150307. */
  150308. register(): void;
  150309. private _beforeCameraDraw;
  150310. private _afterCameraDraw;
  150311. private _beforeClearStage;
  150312. /**
  150313. * Serializes the component data to the specified json object
  150314. * @param serializationObject The object to serialize to
  150315. */
  150316. serialize(serializationObject: any): void;
  150317. /**
  150318. * Adds all the elements from the container to the scene
  150319. * @param container the container holding the elements
  150320. */
  150321. addFromContainer(container: AbstractScene): void;
  150322. /**
  150323. * Removes all the elements in the container from the scene
  150324. * @param container contains the elements to remove
  150325. * @param dispose if the removed element should be disposed (default: false)
  150326. */
  150327. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  150328. /**
  150329. * Rebuilds the elements related to this component in case of
  150330. * context lost for instance.
  150331. */
  150332. rebuild(): void;
  150333. /**
  150334. * Disposes the component and the associated ressources
  150335. */
  150336. dispose(): void;
  150337. }
  150338. }
  150339. declare module BABYLON {
  150340. /** @hidden */
  150341. export var outlinePixelShader: {
  150342. name: string;
  150343. shader: string;
  150344. };
  150345. }
  150346. declare module BABYLON {
  150347. /** @hidden */
  150348. export var outlineVertexShader: {
  150349. name: string;
  150350. shader: string;
  150351. };
  150352. }
  150353. declare module BABYLON {
  150354. interface Scene {
  150355. /** @hidden */
  150356. _outlineRenderer: OutlineRenderer;
  150357. /**
  150358. * Gets the outline renderer associated with the scene
  150359. * @returns a OutlineRenderer
  150360. */
  150361. getOutlineRenderer(): OutlineRenderer;
  150362. }
  150363. interface AbstractMesh {
  150364. /** @hidden (Backing field) */
  150365. _renderOutline: boolean;
  150366. /**
  150367. * Gets or sets a boolean indicating if the outline must be rendered as well
  150368. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  150369. */
  150370. renderOutline: boolean;
  150371. /** @hidden (Backing field) */
  150372. _renderOverlay: boolean;
  150373. /**
  150374. * Gets or sets a boolean indicating if the overlay must be rendered as well
  150375. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  150376. */
  150377. renderOverlay: boolean;
  150378. }
  150379. /**
  150380. * This class is responsible to draw bothe outline/overlay of meshes.
  150381. * It should not be used directly but through the available method on mesh.
  150382. */
  150383. export class OutlineRenderer implements ISceneComponent {
  150384. /**
  150385. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  150386. */
  150387. private static _StencilReference;
  150388. /**
  150389. * The name of the component. Each component must have a unique name.
  150390. */
  150391. name: string;
  150392. /**
  150393. * The scene the component belongs to.
  150394. */
  150395. scene: Scene;
  150396. /**
  150397. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  150398. */
  150399. zOffset: number;
  150400. private _engine;
  150401. private _effect;
  150402. private _cachedDefines;
  150403. private _savedDepthWrite;
  150404. /**
  150405. * Instantiates a new outline renderer. (There could be only one per scene).
  150406. * @param scene Defines the scene it belongs to
  150407. */
  150408. constructor(scene: Scene);
  150409. /**
  150410. * Register the component to one instance of a scene.
  150411. */
  150412. register(): void;
  150413. /**
  150414. * Rebuilds the elements related to this component in case of
  150415. * context lost for instance.
  150416. */
  150417. rebuild(): void;
  150418. /**
  150419. * Disposes the component and the associated ressources.
  150420. */
  150421. dispose(): void;
  150422. /**
  150423. * Renders the outline in the canvas.
  150424. * @param subMesh Defines the sumesh to render
  150425. * @param batch Defines the batch of meshes in case of instances
  150426. * @param useOverlay Defines if the rendering is for the overlay or the outline
  150427. */
  150428. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  150429. /**
  150430. * Returns whether or not the outline renderer is ready for a given submesh.
  150431. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  150432. * @param subMesh Defines the submesh to check readyness for
  150433. * @param useInstances Defines wheter wee are trying to render instances or not
  150434. * @returns true if ready otherwise false
  150435. */
  150436. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150437. private _beforeRenderingMesh;
  150438. private _afterRenderingMesh;
  150439. }
  150440. }
  150441. declare module BABYLON {
  150442. /**
  150443. * Defines the basic options interface of a Sprite Frame Source Size.
  150444. */
  150445. export interface ISpriteJSONSpriteSourceSize {
  150446. /**
  150447. * number of the original width of the Frame
  150448. */
  150449. w: number;
  150450. /**
  150451. * number of the original height of the Frame
  150452. */
  150453. h: number;
  150454. }
  150455. /**
  150456. * Defines the basic options interface of a Sprite Frame Data.
  150457. */
  150458. export interface ISpriteJSONSpriteFrameData {
  150459. /**
  150460. * number of the x offset of the Frame
  150461. */
  150462. x: number;
  150463. /**
  150464. * number of the y offset of the Frame
  150465. */
  150466. y: number;
  150467. /**
  150468. * number of the width of the Frame
  150469. */
  150470. w: number;
  150471. /**
  150472. * number of the height of the Frame
  150473. */
  150474. h: number;
  150475. }
  150476. /**
  150477. * Defines the basic options interface of a JSON Sprite.
  150478. */
  150479. export interface ISpriteJSONSprite {
  150480. /**
  150481. * string name of the Frame
  150482. */
  150483. filename: string;
  150484. /**
  150485. * ISpriteJSONSpriteFrame basic object of the frame data
  150486. */
  150487. frame: ISpriteJSONSpriteFrameData;
  150488. /**
  150489. * boolean to flag is the frame was rotated.
  150490. */
  150491. rotated: boolean;
  150492. /**
  150493. * boolean to flag is the frame was trimmed.
  150494. */
  150495. trimmed: boolean;
  150496. /**
  150497. * ISpriteJSONSpriteFrame basic object of the source data
  150498. */
  150499. spriteSourceSize: ISpriteJSONSpriteFrameData;
  150500. /**
  150501. * ISpriteJSONSpriteFrame basic object of the source data
  150502. */
  150503. sourceSize: ISpriteJSONSpriteSourceSize;
  150504. }
  150505. /**
  150506. * Defines the basic options interface of a JSON atlas.
  150507. */
  150508. export interface ISpriteJSONAtlas {
  150509. /**
  150510. * Array of objects that contain the frame data.
  150511. */
  150512. frames: Array<ISpriteJSONSprite>;
  150513. /**
  150514. * object basic object containing the sprite meta data.
  150515. */
  150516. meta?: object;
  150517. }
  150518. }
  150519. declare module BABYLON {
  150520. /** @hidden */
  150521. export var spriteMapPixelShader: {
  150522. name: string;
  150523. shader: string;
  150524. };
  150525. }
  150526. declare module BABYLON {
  150527. /** @hidden */
  150528. export var spriteMapVertexShader: {
  150529. name: string;
  150530. shader: string;
  150531. };
  150532. }
  150533. declare module BABYLON {
  150534. /**
  150535. * Defines the basic options interface of a SpriteMap
  150536. */
  150537. export interface ISpriteMapOptions {
  150538. /**
  150539. * Vector2 of the number of cells in the grid.
  150540. */
  150541. stageSize?: Vector2;
  150542. /**
  150543. * Vector2 of the size of the output plane in World Units.
  150544. */
  150545. outputSize?: Vector2;
  150546. /**
  150547. * Vector3 of the position of the output plane in World Units.
  150548. */
  150549. outputPosition?: Vector3;
  150550. /**
  150551. * Vector3 of the rotation of the output plane.
  150552. */
  150553. outputRotation?: Vector3;
  150554. /**
  150555. * number of layers that the system will reserve in resources.
  150556. */
  150557. layerCount?: number;
  150558. /**
  150559. * number of max animation frames a single cell will reserve in resources.
  150560. */
  150561. maxAnimationFrames?: number;
  150562. /**
  150563. * number cell index of the base tile when the system compiles.
  150564. */
  150565. baseTile?: number;
  150566. /**
  150567. * boolean flip the sprite after its been repositioned by the framing data.
  150568. */
  150569. flipU?: boolean;
  150570. /**
  150571. * Vector3 scalar of the global RGB values of the SpriteMap.
  150572. */
  150573. colorMultiply?: Vector3;
  150574. }
  150575. /**
  150576. * Defines the IDisposable interface in order to be cleanable from resources.
  150577. */
  150578. export interface ISpriteMap extends IDisposable {
  150579. /**
  150580. * String name of the SpriteMap.
  150581. */
  150582. name: string;
  150583. /**
  150584. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  150585. */
  150586. atlasJSON: ISpriteJSONAtlas;
  150587. /**
  150588. * Texture of the SpriteMap.
  150589. */
  150590. spriteSheet: Texture;
  150591. /**
  150592. * The parameters to initialize the SpriteMap with.
  150593. */
  150594. options: ISpriteMapOptions;
  150595. }
  150596. /**
  150597. * Class used to manage a grid restricted sprite deployment on an Output plane.
  150598. */
  150599. export class SpriteMap implements ISpriteMap {
  150600. /** The Name of the spriteMap */
  150601. name: string;
  150602. /** The JSON file with the frame and meta data */
  150603. atlasJSON: ISpriteJSONAtlas;
  150604. /** The systems Sprite Sheet Texture */
  150605. spriteSheet: Texture;
  150606. /** Arguments passed with the Constructor */
  150607. options: ISpriteMapOptions;
  150608. /** Public Sprite Storage array, parsed from atlasJSON */
  150609. sprites: Array<ISpriteJSONSprite>;
  150610. /** Returns the Number of Sprites in the System */
  150611. get spriteCount(): number;
  150612. /** Returns the Position of Output Plane*/
  150613. get position(): Vector3;
  150614. /** Returns the Position of Output Plane*/
  150615. set position(v: Vector3);
  150616. /** Returns the Rotation of Output Plane*/
  150617. get rotation(): Vector3;
  150618. /** Returns the Rotation of Output Plane*/
  150619. set rotation(v: Vector3);
  150620. /** Sets the AnimationMap*/
  150621. get animationMap(): RawTexture;
  150622. /** Sets the AnimationMap*/
  150623. set animationMap(v: RawTexture);
  150624. /** Scene that the SpriteMap was created in */
  150625. private _scene;
  150626. /** Texture Buffer of Float32 that holds tile frame data*/
  150627. private _frameMap;
  150628. /** Texture Buffers of Float32 that holds tileMap data*/
  150629. private _tileMaps;
  150630. /** Texture Buffer of Float32 that holds Animation Data*/
  150631. private _animationMap;
  150632. /** Custom ShaderMaterial Central to the System*/
  150633. private _material;
  150634. /** Custom ShaderMaterial Central to the System*/
  150635. private _output;
  150636. /** Systems Time Ticker*/
  150637. private _time;
  150638. /**
  150639. * Creates a new SpriteMap
  150640. * @param name defines the SpriteMaps Name
  150641. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  150642. * @param spriteSheet is the Texture that the Sprites are on.
  150643. * @param options a basic deployment configuration
  150644. * @param scene The Scene that the map is deployed on
  150645. */
  150646. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  150647. /**
  150648. * Returns tileID location
  150649. * @returns Vector2 the cell position ID
  150650. */
  150651. getTileID(): Vector2;
  150652. /**
  150653. * Gets the UV location of the mouse over the SpriteMap.
  150654. * @returns Vector2 the UV position of the mouse interaction
  150655. */
  150656. getMousePosition(): Vector2;
  150657. /**
  150658. * Creates the "frame" texture Buffer
  150659. * -------------------------------------
  150660. * Structure of frames
  150661. * "filename": "Falling-Water-2.png",
  150662. * "frame": {"x":69,"y":103,"w":24,"h":32},
  150663. * "rotated": true,
  150664. * "trimmed": true,
  150665. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  150666. * "sourceSize": {"w":32,"h":32}
  150667. * @returns RawTexture of the frameMap
  150668. */
  150669. private _createFrameBuffer;
  150670. /**
  150671. * Creates the tileMap texture Buffer
  150672. * @param buffer normally and array of numbers, or a false to generate from scratch
  150673. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  150674. * @returns RawTexture of the tileMap
  150675. */
  150676. private _createTileBuffer;
  150677. /**
  150678. * Modifies the data of the tileMaps
  150679. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  150680. * @param pos is the iVector2 Coordinates of the Tile
  150681. * @param tile The SpriteIndex of the new Tile
  150682. */
  150683. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  150684. /**
  150685. * Creates the animationMap texture Buffer
  150686. * @param buffer normally and array of numbers, or a false to generate from scratch
  150687. * @returns RawTexture of the animationMap
  150688. */
  150689. private _createTileAnimationBuffer;
  150690. /**
  150691. * Modifies the data of the animationMap
  150692. * @param cellID is the Index of the Sprite
  150693. * @param _frame is the target Animation frame
  150694. * @param toCell is the Target Index of the next frame of the animation
  150695. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  150696. * @param speed is a global scalar of the time variable on the map.
  150697. */
  150698. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  150699. /**
  150700. * Exports the .tilemaps file
  150701. */
  150702. saveTileMaps(): void;
  150703. /**
  150704. * Imports the .tilemaps file
  150705. * @param url of the .tilemaps file
  150706. */
  150707. loadTileMaps(url: string): void;
  150708. /**
  150709. * Release associated resources
  150710. */
  150711. dispose(): void;
  150712. }
  150713. }
  150714. declare module BABYLON {
  150715. /**
  150716. * Class used to manage multiple sprites of different sizes on the same spritesheet
  150717. * @see https://doc.babylonjs.com/babylon101/sprites
  150718. */
  150719. export class SpritePackedManager extends SpriteManager {
  150720. /** defines the packed manager's name */
  150721. name: string;
  150722. /**
  150723. * Creates a new sprite manager from a packed sprite sheet
  150724. * @param name defines the manager's name
  150725. * @param imgUrl defines the sprite sheet url
  150726. * @param capacity defines the maximum allowed number of sprites
  150727. * @param scene defines the hosting scene
  150728. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  150729. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  150730. * @param samplingMode defines the smapling mode to use with spritesheet
  150731. * @param fromPacked set to true; do not alter
  150732. */
  150733. constructor(
  150734. /** defines the packed manager's name */
  150735. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  150736. }
  150737. }
  150738. declare module BABYLON {
  150739. /**
  150740. * Defines the list of states available for a task inside a AssetsManager
  150741. */
  150742. export enum AssetTaskState {
  150743. /**
  150744. * Initialization
  150745. */
  150746. INIT = 0,
  150747. /**
  150748. * Running
  150749. */
  150750. RUNNING = 1,
  150751. /**
  150752. * Done
  150753. */
  150754. DONE = 2,
  150755. /**
  150756. * Error
  150757. */
  150758. ERROR = 3
  150759. }
  150760. /**
  150761. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  150762. */
  150763. export abstract class AbstractAssetTask {
  150764. /**
  150765. * Task name
  150766. */ name: string;
  150767. /**
  150768. * Callback called when the task is successful
  150769. */
  150770. onSuccess: (task: any) => void;
  150771. /**
  150772. * Callback called when the task is not successful
  150773. */
  150774. onError: (task: any, message?: string, exception?: any) => void;
  150775. /**
  150776. * Creates a new AssetsManager
  150777. * @param name defines the name of the task
  150778. */
  150779. constructor(
  150780. /**
  150781. * Task name
  150782. */ name: string);
  150783. private _isCompleted;
  150784. private _taskState;
  150785. private _errorObject;
  150786. /**
  150787. * Get if the task is completed
  150788. */
  150789. get isCompleted(): boolean;
  150790. /**
  150791. * Gets the current state of the task
  150792. */
  150793. get taskState(): AssetTaskState;
  150794. /**
  150795. * Gets the current error object (if task is in error)
  150796. */
  150797. get errorObject(): {
  150798. message?: string;
  150799. exception?: any;
  150800. };
  150801. /**
  150802. * Internal only
  150803. * @hidden
  150804. */
  150805. _setErrorObject(message?: string, exception?: any): void;
  150806. /**
  150807. * Execute the current task
  150808. * @param scene defines the scene where you want your assets to be loaded
  150809. * @param onSuccess is a callback called when the task is successfully executed
  150810. * @param onError is a callback called if an error occurs
  150811. */
  150812. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150813. /**
  150814. * Execute the current task
  150815. * @param scene defines the scene where you want your assets to be loaded
  150816. * @param onSuccess is a callback called when the task is successfully executed
  150817. * @param onError is a callback called if an error occurs
  150818. */
  150819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150820. /**
  150821. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  150822. * This can be used with failed tasks that have the reason for failure fixed.
  150823. */
  150824. reset(): void;
  150825. private onErrorCallback;
  150826. private onDoneCallback;
  150827. }
  150828. /**
  150829. * Define the interface used by progress events raised during assets loading
  150830. */
  150831. export interface IAssetsProgressEvent {
  150832. /**
  150833. * Defines the number of remaining tasks to process
  150834. */
  150835. remainingCount: number;
  150836. /**
  150837. * Defines the total number of tasks
  150838. */
  150839. totalCount: number;
  150840. /**
  150841. * Defines the task that was just processed
  150842. */
  150843. task: AbstractAssetTask;
  150844. }
  150845. /**
  150846. * Class used to share progress information about assets loading
  150847. */
  150848. export class AssetsProgressEvent implements IAssetsProgressEvent {
  150849. /**
  150850. * Defines the number of remaining tasks to process
  150851. */
  150852. remainingCount: number;
  150853. /**
  150854. * Defines the total number of tasks
  150855. */
  150856. totalCount: number;
  150857. /**
  150858. * Defines the task that was just processed
  150859. */
  150860. task: AbstractAssetTask;
  150861. /**
  150862. * Creates a AssetsProgressEvent
  150863. * @param remainingCount defines the number of remaining tasks to process
  150864. * @param totalCount defines the total number of tasks
  150865. * @param task defines the task that was just processed
  150866. */
  150867. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  150868. }
  150869. /**
  150870. * Define a task used by AssetsManager to load assets into a container
  150871. */
  150872. export class ContainerAssetTask extends AbstractAssetTask {
  150873. /**
  150874. * Defines the name of the task
  150875. */
  150876. name: string;
  150877. /**
  150878. * Defines the list of mesh's names you want to load
  150879. */
  150880. meshesNames: any;
  150881. /**
  150882. * Defines the root url to use as a base to load your meshes and associated resources
  150883. */
  150884. rootUrl: string;
  150885. /**
  150886. * Defines the filename or File of the scene to load from
  150887. */
  150888. sceneFilename: string | File;
  150889. /**
  150890. * Get the loaded asset container
  150891. */
  150892. loadedContainer: AssetContainer;
  150893. /**
  150894. * Gets the list of loaded meshes
  150895. */
  150896. loadedMeshes: Array<AbstractMesh>;
  150897. /**
  150898. * Gets the list of loaded particle systems
  150899. */
  150900. loadedParticleSystems: Array<IParticleSystem>;
  150901. /**
  150902. * Gets the list of loaded skeletons
  150903. */
  150904. loadedSkeletons: Array<Skeleton>;
  150905. /**
  150906. * Gets the list of loaded animation groups
  150907. */
  150908. loadedAnimationGroups: Array<AnimationGroup>;
  150909. /**
  150910. * Callback called when the task is successful
  150911. */
  150912. onSuccess: (task: ContainerAssetTask) => void;
  150913. /**
  150914. * Callback called when the task is successful
  150915. */
  150916. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  150917. /**
  150918. * Creates a new ContainerAssetTask
  150919. * @param name defines the name of the task
  150920. * @param meshesNames defines the list of mesh's names you want to load
  150921. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150922. * @param sceneFilename defines the filename or File of the scene to load from
  150923. */
  150924. constructor(
  150925. /**
  150926. * Defines the name of the task
  150927. */
  150928. name: string,
  150929. /**
  150930. * Defines the list of mesh's names you want to load
  150931. */
  150932. meshesNames: any,
  150933. /**
  150934. * Defines the root url to use as a base to load your meshes and associated resources
  150935. */
  150936. rootUrl: string,
  150937. /**
  150938. * Defines the filename or File of the scene to load from
  150939. */
  150940. sceneFilename: string | File);
  150941. /**
  150942. * Execute the current task
  150943. * @param scene defines the scene where you want your assets to be loaded
  150944. * @param onSuccess is a callback called when the task is successfully executed
  150945. * @param onError is a callback called if an error occurs
  150946. */
  150947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150948. }
  150949. /**
  150950. * Define a task used by AssetsManager to load meshes
  150951. */
  150952. export class MeshAssetTask extends AbstractAssetTask {
  150953. /**
  150954. * Defines the name of the task
  150955. */
  150956. name: string;
  150957. /**
  150958. * Defines the list of mesh's names you want to load
  150959. */
  150960. meshesNames: any;
  150961. /**
  150962. * Defines the root url to use as a base to load your meshes and associated resources
  150963. */
  150964. rootUrl: string;
  150965. /**
  150966. * Defines the filename or File of the scene to load from
  150967. */
  150968. sceneFilename: string | File;
  150969. /**
  150970. * Gets the list of loaded meshes
  150971. */
  150972. loadedMeshes: Array<AbstractMesh>;
  150973. /**
  150974. * Gets the list of loaded particle systems
  150975. */
  150976. loadedParticleSystems: Array<IParticleSystem>;
  150977. /**
  150978. * Gets the list of loaded skeletons
  150979. */
  150980. loadedSkeletons: Array<Skeleton>;
  150981. /**
  150982. * Gets the list of loaded animation groups
  150983. */
  150984. loadedAnimationGroups: Array<AnimationGroup>;
  150985. /**
  150986. * Callback called when the task is successful
  150987. */
  150988. onSuccess: (task: MeshAssetTask) => void;
  150989. /**
  150990. * Callback called when the task is successful
  150991. */
  150992. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  150993. /**
  150994. * Creates a new MeshAssetTask
  150995. * @param name defines the name of the task
  150996. * @param meshesNames defines the list of mesh's names you want to load
  150997. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150998. * @param sceneFilename defines the filename or File of the scene to load from
  150999. */
  151000. constructor(
  151001. /**
  151002. * Defines the name of the task
  151003. */
  151004. name: string,
  151005. /**
  151006. * Defines the list of mesh's names you want to load
  151007. */
  151008. meshesNames: any,
  151009. /**
  151010. * Defines the root url to use as a base to load your meshes and associated resources
  151011. */
  151012. rootUrl: string,
  151013. /**
  151014. * Defines the filename or File of the scene to load from
  151015. */
  151016. sceneFilename: string | File);
  151017. /**
  151018. * Execute the current task
  151019. * @param scene defines the scene where you want your assets to be loaded
  151020. * @param onSuccess is a callback called when the task is successfully executed
  151021. * @param onError is a callback called if an error occurs
  151022. */
  151023. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151024. }
  151025. /**
  151026. * Define a task used by AssetsManager to load text content
  151027. */
  151028. export class TextFileAssetTask extends AbstractAssetTask {
  151029. /**
  151030. * Defines the name of the task
  151031. */
  151032. name: string;
  151033. /**
  151034. * Defines the location of the file to load
  151035. */
  151036. url: string;
  151037. /**
  151038. * Gets the loaded text string
  151039. */
  151040. text: string;
  151041. /**
  151042. * Callback called when the task is successful
  151043. */
  151044. onSuccess: (task: TextFileAssetTask) => void;
  151045. /**
  151046. * Callback called when the task is successful
  151047. */
  151048. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  151049. /**
  151050. * Creates a new TextFileAssetTask object
  151051. * @param name defines the name of the task
  151052. * @param url defines the location of the file to load
  151053. */
  151054. constructor(
  151055. /**
  151056. * Defines the name of the task
  151057. */
  151058. name: string,
  151059. /**
  151060. * Defines the location of the file to load
  151061. */
  151062. url: string);
  151063. /**
  151064. * Execute the current task
  151065. * @param scene defines the scene where you want your assets to be loaded
  151066. * @param onSuccess is a callback called when the task is successfully executed
  151067. * @param onError is a callback called if an error occurs
  151068. */
  151069. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151070. }
  151071. /**
  151072. * Define a task used by AssetsManager to load binary data
  151073. */
  151074. export class BinaryFileAssetTask extends AbstractAssetTask {
  151075. /**
  151076. * Defines the name of the task
  151077. */
  151078. name: string;
  151079. /**
  151080. * Defines the location of the file to load
  151081. */
  151082. url: string;
  151083. /**
  151084. * Gets the lodaded data (as an array buffer)
  151085. */
  151086. data: ArrayBuffer;
  151087. /**
  151088. * Callback called when the task is successful
  151089. */
  151090. onSuccess: (task: BinaryFileAssetTask) => void;
  151091. /**
  151092. * Callback called when the task is successful
  151093. */
  151094. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  151095. /**
  151096. * Creates a new BinaryFileAssetTask object
  151097. * @param name defines the name of the new task
  151098. * @param url defines the location of the file to load
  151099. */
  151100. constructor(
  151101. /**
  151102. * Defines the name of the task
  151103. */
  151104. name: string,
  151105. /**
  151106. * Defines the location of the file to load
  151107. */
  151108. url: string);
  151109. /**
  151110. * Execute the current task
  151111. * @param scene defines the scene where you want your assets to be loaded
  151112. * @param onSuccess is a callback called when the task is successfully executed
  151113. * @param onError is a callback called if an error occurs
  151114. */
  151115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151116. }
  151117. /**
  151118. * Define a task used by AssetsManager to load images
  151119. */
  151120. export class ImageAssetTask extends AbstractAssetTask {
  151121. /**
  151122. * Defines the name of the task
  151123. */
  151124. name: string;
  151125. /**
  151126. * Defines the location of the image to load
  151127. */
  151128. url: string;
  151129. /**
  151130. * Gets the loaded images
  151131. */
  151132. image: HTMLImageElement;
  151133. /**
  151134. * Callback called when the task is successful
  151135. */
  151136. onSuccess: (task: ImageAssetTask) => void;
  151137. /**
  151138. * Callback called when the task is successful
  151139. */
  151140. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  151141. /**
  151142. * Creates a new ImageAssetTask
  151143. * @param name defines the name of the task
  151144. * @param url defines the location of the image to load
  151145. */
  151146. constructor(
  151147. /**
  151148. * Defines the name of the task
  151149. */
  151150. name: string,
  151151. /**
  151152. * Defines the location of the image to load
  151153. */
  151154. url: string);
  151155. /**
  151156. * Execute the current task
  151157. * @param scene defines the scene where you want your assets to be loaded
  151158. * @param onSuccess is a callback called when the task is successfully executed
  151159. * @param onError is a callback called if an error occurs
  151160. */
  151161. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151162. }
  151163. /**
  151164. * Defines the interface used by texture loading tasks
  151165. */
  151166. export interface ITextureAssetTask<TEX extends BaseTexture> {
  151167. /**
  151168. * Gets the loaded texture
  151169. */
  151170. texture: TEX;
  151171. }
  151172. /**
  151173. * Define a task used by AssetsManager to load 2D textures
  151174. */
  151175. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  151176. /**
  151177. * Defines the name of the task
  151178. */
  151179. name: string;
  151180. /**
  151181. * Defines the location of the file to load
  151182. */
  151183. url: string;
  151184. /**
  151185. * Defines if mipmap should not be generated (default is false)
  151186. */
  151187. noMipmap?: boolean | undefined;
  151188. /**
  151189. * Defines if texture must be inverted on Y axis (default is true)
  151190. */
  151191. invertY: boolean;
  151192. /**
  151193. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151194. */
  151195. samplingMode: number;
  151196. /**
  151197. * Gets the loaded texture
  151198. */
  151199. texture: Texture;
  151200. /**
  151201. * Callback called when the task is successful
  151202. */
  151203. onSuccess: (task: TextureAssetTask) => void;
  151204. /**
  151205. * Callback called when the task is successful
  151206. */
  151207. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  151208. /**
  151209. * Creates a new TextureAssetTask object
  151210. * @param name defines the name of the task
  151211. * @param url defines the location of the file to load
  151212. * @param noMipmap defines if mipmap should not be generated (default is false)
  151213. * @param invertY defines if texture must be inverted on Y axis (default is true)
  151214. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151215. */
  151216. constructor(
  151217. /**
  151218. * Defines the name of the task
  151219. */
  151220. name: string,
  151221. /**
  151222. * Defines the location of the file to load
  151223. */
  151224. url: string,
  151225. /**
  151226. * Defines if mipmap should not be generated (default is false)
  151227. */
  151228. noMipmap?: boolean | undefined,
  151229. /**
  151230. * Defines if texture must be inverted on Y axis (default is true)
  151231. */
  151232. invertY?: boolean,
  151233. /**
  151234. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151235. */
  151236. samplingMode?: number);
  151237. /**
  151238. * Execute the current task
  151239. * @param scene defines the scene where you want your assets to be loaded
  151240. * @param onSuccess is a callback called when the task is successfully executed
  151241. * @param onError is a callback called if an error occurs
  151242. */
  151243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151244. }
  151245. /**
  151246. * Define a task used by AssetsManager to load cube textures
  151247. */
  151248. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  151249. /**
  151250. * Defines the name of the task
  151251. */
  151252. name: string;
  151253. /**
  151254. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151255. */
  151256. url: string;
  151257. /**
  151258. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151259. */
  151260. extensions?: string[] | undefined;
  151261. /**
  151262. * Defines if mipmaps should not be generated (default is false)
  151263. */
  151264. noMipmap?: boolean | undefined;
  151265. /**
  151266. * Defines the explicit list of files (undefined by default)
  151267. */
  151268. files?: string[] | undefined;
  151269. /**
  151270. * Gets the loaded texture
  151271. */
  151272. texture: CubeTexture;
  151273. /**
  151274. * Callback called when the task is successful
  151275. */
  151276. onSuccess: (task: CubeTextureAssetTask) => void;
  151277. /**
  151278. * Callback called when the task is successful
  151279. */
  151280. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  151281. /**
  151282. * Creates a new CubeTextureAssetTask
  151283. * @param name defines the name of the task
  151284. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151285. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151286. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151287. * @param files defines the explicit list of files (undefined by default)
  151288. */
  151289. constructor(
  151290. /**
  151291. * Defines the name of the task
  151292. */
  151293. name: string,
  151294. /**
  151295. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151296. */
  151297. url: string,
  151298. /**
  151299. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151300. */
  151301. extensions?: string[] | undefined,
  151302. /**
  151303. * Defines if mipmaps should not be generated (default is false)
  151304. */
  151305. noMipmap?: boolean | undefined,
  151306. /**
  151307. * Defines the explicit list of files (undefined by default)
  151308. */
  151309. files?: string[] | undefined);
  151310. /**
  151311. * Execute the current task
  151312. * @param scene defines the scene where you want your assets to be loaded
  151313. * @param onSuccess is a callback called when the task is successfully executed
  151314. * @param onError is a callback called if an error occurs
  151315. */
  151316. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151317. }
  151318. /**
  151319. * Define a task used by AssetsManager to load HDR cube textures
  151320. */
  151321. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  151322. /**
  151323. * Defines the name of the task
  151324. */
  151325. name: string;
  151326. /**
  151327. * Defines the location of the file to load
  151328. */
  151329. url: string;
  151330. /**
  151331. * Defines the desired size (the more it increases the longer the generation will be)
  151332. */
  151333. size: number;
  151334. /**
  151335. * Defines if mipmaps should not be generated (default is false)
  151336. */
  151337. noMipmap: boolean;
  151338. /**
  151339. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151340. */
  151341. generateHarmonics: boolean;
  151342. /**
  151343. * 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)
  151344. */
  151345. gammaSpace: boolean;
  151346. /**
  151347. * Internal Use Only
  151348. */
  151349. reserved: boolean;
  151350. /**
  151351. * Gets the loaded texture
  151352. */
  151353. texture: HDRCubeTexture;
  151354. /**
  151355. * Callback called when the task is successful
  151356. */
  151357. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  151358. /**
  151359. * Callback called when the task is successful
  151360. */
  151361. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  151362. /**
  151363. * Creates a new HDRCubeTextureAssetTask object
  151364. * @param name defines the name of the task
  151365. * @param url defines the location of the file to load
  151366. * @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.
  151367. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151368. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151369. * @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)
  151370. * @param reserved Internal use only
  151371. */
  151372. constructor(
  151373. /**
  151374. * Defines the name of the task
  151375. */
  151376. name: string,
  151377. /**
  151378. * Defines the location of the file to load
  151379. */
  151380. url: string,
  151381. /**
  151382. * Defines the desired size (the more it increases the longer the generation will be)
  151383. */
  151384. size: number,
  151385. /**
  151386. * Defines if mipmaps should not be generated (default is false)
  151387. */
  151388. noMipmap?: boolean,
  151389. /**
  151390. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151391. */
  151392. generateHarmonics?: boolean,
  151393. /**
  151394. * 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)
  151395. */
  151396. gammaSpace?: boolean,
  151397. /**
  151398. * Internal Use Only
  151399. */
  151400. reserved?: boolean);
  151401. /**
  151402. * Execute the current task
  151403. * @param scene defines the scene where you want your assets to be loaded
  151404. * @param onSuccess is a callback called when the task is successfully executed
  151405. * @param onError is a callback called if an error occurs
  151406. */
  151407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151408. }
  151409. /**
  151410. * Define a task used by AssetsManager to load Equirectangular cube textures
  151411. */
  151412. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  151413. /**
  151414. * Defines the name of the task
  151415. */
  151416. name: string;
  151417. /**
  151418. * Defines the location of the file to load
  151419. */
  151420. url: string;
  151421. /**
  151422. * Defines the desired size (the more it increases the longer the generation will be)
  151423. */
  151424. size: number;
  151425. /**
  151426. * Defines if mipmaps should not be generated (default is false)
  151427. */
  151428. noMipmap: boolean;
  151429. /**
  151430. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151431. * but the standard material would require them in Gamma space) (default is true)
  151432. */
  151433. gammaSpace: boolean;
  151434. /**
  151435. * Gets the loaded texture
  151436. */
  151437. texture: EquiRectangularCubeTexture;
  151438. /**
  151439. * Callback called when the task is successful
  151440. */
  151441. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  151442. /**
  151443. * Callback called when the task is successful
  151444. */
  151445. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  151446. /**
  151447. * Creates a new EquiRectangularCubeTextureAssetTask object
  151448. * @param name defines the name of the task
  151449. * @param url defines the location of the file to load
  151450. * @param size defines the desired size (the more it increases the longer the generation will be)
  151451. * If the size is omitted this implies you are using a preprocessed cubemap.
  151452. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151453. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  151454. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  151455. * (default is true)
  151456. */
  151457. constructor(
  151458. /**
  151459. * Defines the name of the task
  151460. */
  151461. name: string,
  151462. /**
  151463. * Defines the location of the file to load
  151464. */
  151465. url: string,
  151466. /**
  151467. * Defines the desired size (the more it increases the longer the generation will be)
  151468. */
  151469. size: number,
  151470. /**
  151471. * Defines if mipmaps should not be generated (default is false)
  151472. */
  151473. noMipmap?: boolean,
  151474. /**
  151475. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151476. * but the standard material would require them in Gamma space) (default is true)
  151477. */
  151478. gammaSpace?: boolean);
  151479. /**
  151480. * Execute the current task
  151481. * @param scene defines the scene where you want your assets to be loaded
  151482. * @param onSuccess is a callback called when the task is successfully executed
  151483. * @param onError is a callback called if an error occurs
  151484. */
  151485. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151486. }
  151487. /**
  151488. * This class can be used to easily import assets into a scene
  151489. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  151490. */
  151491. export class AssetsManager {
  151492. private _scene;
  151493. private _isLoading;
  151494. protected _tasks: AbstractAssetTask[];
  151495. protected _waitingTasksCount: number;
  151496. protected _totalTasksCount: number;
  151497. /**
  151498. * Callback called when all tasks are processed
  151499. */
  151500. onFinish: (tasks: AbstractAssetTask[]) => void;
  151501. /**
  151502. * Callback called when a task is successful
  151503. */
  151504. onTaskSuccess: (task: AbstractAssetTask) => void;
  151505. /**
  151506. * Callback called when a task had an error
  151507. */
  151508. onTaskError: (task: AbstractAssetTask) => void;
  151509. /**
  151510. * Callback called when a task is done (whatever the result is)
  151511. */
  151512. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  151513. /**
  151514. * Observable called when all tasks are processed
  151515. */
  151516. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  151517. /**
  151518. * Observable called when a task had an error
  151519. */
  151520. onTaskErrorObservable: Observable<AbstractAssetTask>;
  151521. /**
  151522. * Observable called when all tasks were executed
  151523. */
  151524. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  151525. /**
  151526. * Observable called when a task is done (whatever the result is)
  151527. */
  151528. onProgressObservable: Observable<IAssetsProgressEvent>;
  151529. /**
  151530. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  151531. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  151532. */
  151533. useDefaultLoadingScreen: boolean;
  151534. /**
  151535. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  151536. * when all assets have been downloaded.
  151537. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  151538. */
  151539. autoHideLoadingUI: boolean;
  151540. /**
  151541. * Creates a new AssetsManager
  151542. * @param scene defines the scene to work on
  151543. */
  151544. constructor(scene: Scene);
  151545. /**
  151546. * Add a ContainerAssetTask to the list of active tasks
  151547. * @param taskName defines the name of the new task
  151548. * @param meshesNames defines the name of meshes to load
  151549. * @param rootUrl defines the root url to use to locate files
  151550. * @param sceneFilename defines the filename of the scene file
  151551. * @returns a new ContainerAssetTask object
  151552. */
  151553. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  151554. /**
  151555. * Add a MeshAssetTask to the list of active tasks
  151556. * @param taskName defines the name of the new task
  151557. * @param meshesNames defines the name of meshes to load
  151558. * @param rootUrl defines the root url to use to locate files
  151559. * @param sceneFilename defines the filename of the scene file
  151560. * @returns a new MeshAssetTask object
  151561. */
  151562. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  151563. /**
  151564. * Add a TextFileAssetTask to the list of active tasks
  151565. * @param taskName defines the name of the new task
  151566. * @param url defines the url of the file to load
  151567. * @returns a new TextFileAssetTask object
  151568. */
  151569. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  151570. /**
  151571. * Add a BinaryFileAssetTask to the list of active tasks
  151572. * @param taskName defines the name of the new task
  151573. * @param url defines the url of the file to load
  151574. * @returns a new BinaryFileAssetTask object
  151575. */
  151576. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  151577. /**
  151578. * Add a ImageAssetTask to the list of active tasks
  151579. * @param taskName defines the name of the new task
  151580. * @param url defines the url of the file to load
  151581. * @returns a new ImageAssetTask object
  151582. */
  151583. addImageTask(taskName: string, url: string): ImageAssetTask;
  151584. /**
  151585. * Add a TextureAssetTask 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 noMipmap defines if the texture must not receive mipmaps (false by default)
  151589. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  151590. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151591. * @returns a new TextureAssetTask object
  151592. */
  151593. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  151594. /**
  151595. * Add a CubeTextureAssetTask to the list of active tasks
  151596. * @param taskName defines the name of the new task
  151597. * @param url defines the url of the file to load
  151598. * @param extensions defines the extension to use to load the cube map (can be null)
  151599. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151600. * @param files defines the list of files to load (can be null)
  151601. * @returns a new CubeTextureAssetTask object
  151602. */
  151603. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  151604. /**
  151605. *
  151606. * Add a HDRCubeTextureAssetTask to the list of active tasks
  151607. * @param taskName defines the name of the new task
  151608. * @param url defines the url of the file to load
  151609. * @param size defines the size you want for the cubemap (can be null)
  151610. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151611. * @param generateHarmonics defines if you want to automatically generate (true by default)
  151612. * @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)
  151613. * @param reserved Internal use only
  151614. * @returns a new HDRCubeTextureAssetTask object
  151615. */
  151616. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  151617. /**
  151618. *
  151619. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  151620. * @param taskName defines the name of the new task
  151621. * @param url defines the url of the file to load
  151622. * @param size defines the size you want for the cubemap (can be null)
  151623. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151624. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151625. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151626. * @returns a new EquiRectangularCubeTextureAssetTask object
  151627. */
  151628. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  151629. /**
  151630. * Remove a task from the assets manager.
  151631. * @param task the task to remove
  151632. */
  151633. removeTask(task: AbstractAssetTask): void;
  151634. private _decreaseWaitingTasksCount;
  151635. private _runTask;
  151636. /**
  151637. * Reset the AssetsManager and remove all tasks
  151638. * @return the current instance of the AssetsManager
  151639. */
  151640. reset(): AssetsManager;
  151641. /**
  151642. * Start the loading process
  151643. * @return the current instance of the AssetsManager
  151644. */
  151645. load(): AssetsManager;
  151646. /**
  151647. * Start the loading process as an async operation
  151648. * @return a promise returning the list of failed tasks
  151649. */
  151650. loadAsync(): Promise<void>;
  151651. }
  151652. }
  151653. declare module BABYLON {
  151654. /**
  151655. * Wrapper class for promise with external resolve and reject.
  151656. */
  151657. export class Deferred<T> {
  151658. /**
  151659. * The promise associated with this deferred object.
  151660. */
  151661. readonly promise: Promise<T>;
  151662. private _resolve;
  151663. private _reject;
  151664. /**
  151665. * The resolve method of the promise associated with this deferred object.
  151666. */
  151667. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  151668. /**
  151669. * The reject method of the promise associated with this deferred object.
  151670. */
  151671. get reject(): (reason?: any) => void;
  151672. /**
  151673. * Constructor for this deferred object.
  151674. */
  151675. constructor();
  151676. }
  151677. }
  151678. declare module BABYLON {
  151679. /**
  151680. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  151681. */
  151682. export class MeshExploder {
  151683. private _centerMesh;
  151684. private _meshes;
  151685. private _meshesOrigins;
  151686. private _toCenterVectors;
  151687. private _scaledDirection;
  151688. private _newPosition;
  151689. private _centerPosition;
  151690. /**
  151691. * Explodes meshes from a center mesh.
  151692. * @param meshes The meshes to explode.
  151693. * @param centerMesh The mesh to be center of explosion.
  151694. */
  151695. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  151696. private _setCenterMesh;
  151697. /**
  151698. * Get class name
  151699. * @returns "MeshExploder"
  151700. */
  151701. getClassName(): string;
  151702. /**
  151703. * "Exploded meshes"
  151704. * @returns Array of meshes with the centerMesh at index 0.
  151705. */
  151706. getMeshes(): Array<Mesh>;
  151707. /**
  151708. * Explodes meshes giving a specific direction
  151709. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  151710. */
  151711. explode(direction?: number): void;
  151712. }
  151713. }
  151714. declare module BABYLON {
  151715. /**
  151716. * Class used to help managing file picking and drag'n'drop
  151717. */
  151718. export class FilesInput {
  151719. /**
  151720. * List of files ready to be loaded
  151721. */
  151722. static get FilesToLoad(): {
  151723. [key: string]: File;
  151724. };
  151725. /**
  151726. * Callback called when a file is processed
  151727. */
  151728. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  151729. private _engine;
  151730. private _currentScene;
  151731. private _sceneLoadedCallback;
  151732. private _progressCallback;
  151733. private _additionalRenderLoopLogicCallback;
  151734. private _textureLoadingCallback;
  151735. private _startingProcessingFilesCallback;
  151736. private _onReloadCallback;
  151737. private _errorCallback;
  151738. private _elementToMonitor;
  151739. private _sceneFileToLoad;
  151740. private _filesToLoad;
  151741. /**
  151742. * Creates a new FilesInput
  151743. * @param engine defines the rendering engine
  151744. * @param scene defines the hosting scene
  151745. * @param sceneLoadedCallback callback called when scene is loaded
  151746. * @param progressCallback callback called to track progress
  151747. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  151748. * @param textureLoadingCallback callback called when a texture is loading
  151749. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  151750. * @param onReloadCallback callback called when a reload is requested
  151751. * @param errorCallback callback call if an error occurs
  151752. */
  151753. 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>);
  151754. private _dragEnterHandler;
  151755. private _dragOverHandler;
  151756. private _dropHandler;
  151757. /**
  151758. * Calls this function to listen to drag'n'drop events on a specific DOM element
  151759. * @param elementToMonitor defines the DOM element to track
  151760. */
  151761. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  151762. /** Gets the current list of files to load */
  151763. get filesToLoad(): File[];
  151764. /**
  151765. * Release all associated resources
  151766. */
  151767. dispose(): void;
  151768. private renderFunction;
  151769. private drag;
  151770. private drop;
  151771. private _traverseFolder;
  151772. private _processFiles;
  151773. /**
  151774. * Load files from a drop event
  151775. * @param event defines the drop event to use as source
  151776. */
  151777. loadFiles(event: any): void;
  151778. private _processReload;
  151779. /**
  151780. * Reload the current scene from the loaded files
  151781. */
  151782. reload(): void;
  151783. }
  151784. }
  151785. declare module BABYLON {
  151786. /**
  151787. * Defines the root class used to create scene optimization to use with SceneOptimizer
  151788. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151789. */
  151790. export class SceneOptimization {
  151791. /**
  151792. * Defines the priority of this optimization (0 by default which means first in the list)
  151793. */
  151794. priority: number;
  151795. /**
  151796. * Gets a string describing the action executed by the current optimization
  151797. * @returns description string
  151798. */
  151799. getDescription(): string;
  151800. /**
  151801. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151802. * @param scene defines the current scene where to apply this optimization
  151803. * @param optimizer defines the current optimizer
  151804. * @returns true if everything that can be done was applied
  151805. */
  151806. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151807. /**
  151808. * Creates the SceneOptimization object
  151809. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151810. * @param desc defines the description associated with the optimization
  151811. */
  151812. constructor(
  151813. /**
  151814. * Defines the priority of this optimization (0 by default which means first in the list)
  151815. */
  151816. priority?: number);
  151817. }
  151818. /**
  151819. * Defines an optimization used to reduce the size of render target textures
  151820. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151821. */
  151822. export class TextureOptimization extends SceneOptimization {
  151823. /**
  151824. * Defines the priority of this optimization (0 by default which means first in the list)
  151825. */
  151826. priority: number;
  151827. /**
  151828. * 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
  151829. */
  151830. maximumSize: number;
  151831. /**
  151832. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151833. */
  151834. step: number;
  151835. /**
  151836. * Gets a string describing the action executed by the current optimization
  151837. * @returns description string
  151838. */
  151839. getDescription(): string;
  151840. /**
  151841. * Creates the TextureOptimization object
  151842. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151843. * @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
  151844. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151845. */
  151846. constructor(
  151847. /**
  151848. * Defines the priority of this optimization (0 by default which means first in the list)
  151849. */
  151850. priority?: number,
  151851. /**
  151852. * 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
  151853. */
  151854. maximumSize?: number,
  151855. /**
  151856. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151857. */
  151858. step?: number);
  151859. /**
  151860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151861. * @param scene defines the current scene where to apply this optimization
  151862. * @param optimizer defines the current optimizer
  151863. * @returns true if everything that can be done was applied
  151864. */
  151865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151866. }
  151867. /**
  151868. * Defines an optimization used to increase or decrease the rendering resolution
  151869. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151870. */
  151871. export class HardwareScalingOptimization extends SceneOptimization {
  151872. /**
  151873. * Defines the priority of this optimization (0 by default which means first in the list)
  151874. */
  151875. priority: number;
  151876. /**
  151877. * Defines the maximum scale to use (2 by default)
  151878. */
  151879. maximumScale: number;
  151880. /**
  151881. * Defines the step to use between two passes (0.5 by default)
  151882. */
  151883. step: number;
  151884. private _currentScale;
  151885. private _directionOffset;
  151886. /**
  151887. * Gets a string describing the action executed by the current optimization
  151888. * @return description string
  151889. */
  151890. getDescription(): string;
  151891. /**
  151892. * Creates the HardwareScalingOptimization object
  151893. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151894. * @param maximumScale defines the maximum scale to use (2 by default)
  151895. * @param step defines the step to use between two passes (0.5 by default)
  151896. */
  151897. constructor(
  151898. /**
  151899. * Defines the priority of this optimization (0 by default which means first in the list)
  151900. */
  151901. priority?: number,
  151902. /**
  151903. * Defines the maximum scale to use (2 by default)
  151904. */
  151905. maximumScale?: number,
  151906. /**
  151907. * Defines the step to use between two passes (0.5 by default)
  151908. */
  151909. step?: number);
  151910. /**
  151911. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151912. * @param scene defines the current scene where to apply this optimization
  151913. * @param optimizer defines the current optimizer
  151914. * @returns true if everything that can be done was applied
  151915. */
  151916. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151917. }
  151918. /**
  151919. * Defines an optimization used to remove shadows
  151920. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151921. */
  151922. export class ShadowsOptimization extends SceneOptimization {
  151923. /**
  151924. * Gets a string describing the action executed by the current optimization
  151925. * @return description string
  151926. */
  151927. getDescription(): string;
  151928. /**
  151929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151930. * @param scene defines the current scene where to apply this optimization
  151931. * @param optimizer defines the current optimizer
  151932. * @returns true if everything that can be done was applied
  151933. */
  151934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151935. }
  151936. /**
  151937. * Defines an optimization used to turn post-processes off
  151938. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151939. */
  151940. export class PostProcessesOptimization extends SceneOptimization {
  151941. /**
  151942. * Gets a string describing the action executed by the current optimization
  151943. * @return description string
  151944. */
  151945. getDescription(): string;
  151946. /**
  151947. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151948. * @param scene defines the current scene where to apply this optimization
  151949. * @param optimizer defines the current optimizer
  151950. * @returns true if everything that can be done was applied
  151951. */
  151952. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151953. }
  151954. /**
  151955. * Defines an optimization used to turn lens flares off
  151956. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151957. */
  151958. export class LensFlaresOptimization extends SceneOptimization {
  151959. /**
  151960. * Gets a string describing the action executed by the current optimization
  151961. * @return description string
  151962. */
  151963. getDescription(): string;
  151964. /**
  151965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151966. * @param scene defines the current scene where to apply this optimization
  151967. * @param optimizer defines the current optimizer
  151968. * @returns true if everything that can be done was applied
  151969. */
  151970. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151971. }
  151972. /**
  151973. * Defines an optimization based on user defined callback.
  151974. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151975. */
  151976. export class CustomOptimization extends SceneOptimization {
  151977. /**
  151978. * Callback called to apply the custom optimization.
  151979. */
  151980. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  151981. /**
  151982. * Callback called to get custom description
  151983. */
  151984. onGetDescription: () => string;
  151985. /**
  151986. * Gets a string describing the action executed by the current optimization
  151987. * @returns description string
  151988. */
  151989. getDescription(): string;
  151990. /**
  151991. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151992. * @param scene defines the current scene where to apply this optimization
  151993. * @param optimizer defines the current optimizer
  151994. * @returns true if everything that can be done was applied
  151995. */
  151996. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151997. }
  151998. /**
  151999. * Defines an optimization used to turn particles off
  152000. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152001. */
  152002. export class ParticlesOptimization extends SceneOptimization {
  152003. /**
  152004. * Gets a string describing the action executed by the current optimization
  152005. * @return description string
  152006. */
  152007. getDescription(): string;
  152008. /**
  152009. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152010. * @param scene defines the current scene where to apply this optimization
  152011. * @param optimizer defines the current optimizer
  152012. * @returns true if everything that can be done was applied
  152013. */
  152014. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152015. }
  152016. /**
  152017. * Defines an optimization used to turn render targets off
  152018. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152019. */
  152020. export class RenderTargetsOptimization extends SceneOptimization {
  152021. /**
  152022. * Gets a string describing the action executed by the current optimization
  152023. * @return description string
  152024. */
  152025. getDescription(): string;
  152026. /**
  152027. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152028. * @param scene defines the current scene where to apply this optimization
  152029. * @param optimizer defines the current optimizer
  152030. * @returns true if everything that can be done was applied
  152031. */
  152032. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152033. }
  152034. /**
  152035. * Defines an optimization used to merge meshes with compatible materials
  152036. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152037. */
  152038. export class MergeMeshesOptimization extends SceneOptimization {
  152039. private static _UpdateSelectionTree;
  152040. /**
  152041. * Gets or sets a boolean which defines if optimization octree has to be updated
  152042. */
  152043. static get UpdateSelectionTree(): boolean;
  152044. /**
  152045. * Gets or sets a boolean which defines if optimization octree has to be updated
  152046. */
  152047. static set UpdateSelectionTree(value: boolean);
  152048. /**
  152049. * Gets a string describing the action executed by the current optimization
  152050. * @return description string
  152051. */
  152052. getDescription(): string;
  152053. private _canBeMerged;
  152054. /**
  152055. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152056. * @param scene defines the current scene where to apply this optimization
  152057. * @param optimizer defines the current optimizer
  152058. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  152059. * @returns true if everything that can be done was applied
  152060. */
  152061. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  152062. }
  152063. /**
  152064. * Defines a list of options used by SceneOptimizer
  152065. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152066. */
  152067. export class SceneOptimizerOptions {
  152068. /**
  152069. * Defines the target frame rate to reach (60 by default)
  152070. */
  152071. targetFrameRate: number;
  152072. /**
  152073. * Defines the interval between two checkes (2000ms by default)
  152074. */
  152075. trackerDuration: number;
  152076. /**
  152077. * Gets the list of optimizations to apply
  152078. */
  152079. optimizations: SceneOptimization[];
  152080. /**
  152081. * Creates a new list of options used by SceneOptimizer
  152082. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  152083. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  152084. */
  152085. constructor(
  152086. /**
  152087. * Defines the target frame rate to reach (60 by default)
  152088. */
  152089. targetFrameRate?: number,
  152090. /**
  152091. * Defines the interval between two checkes (2000ms by default)
  152092. */
  152093. trackerDuration?: number);
  152094. /**
  152095. * Add a new optimization
  152096. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  152097. * @returns the current SceneOptimizerOptions
  152098. */
  152099. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  152100. /**
  152101. * Add a new custom optimization
  152102. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  152103. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  152104. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152105. * @returns the current SceneOptimizerOptions
  152106. */
  152107. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  152108. /**
  152109. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  152110. * @param targetFrameRate defines the target frame rate (60 by default)
  152111. * @returns a SceneOptimizerOptions object
  152112. */
  152113. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152114. /**
  152115. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  152116. * @param targetFrameRate defines the target frame rate (60 by default)
  152117. * @returns a SceneOptimizerOptions object
  152118. */
  152119. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152120. /**
  152121. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  152122. * @param targetFrameRate defines the target frame rate (60 by default)
  152123. * @returns a SceneOptimizerOptions object
  152124. */
  152125. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152126. }
  152127. /**
  152128. * Class used to run optimizations in order to reach a target frame rate
  152129. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152130. */
  152131. export class SceneOptimizer implements IDisposable {
  152132. private _isRunning;
  152133. private _options;
  152134. private _scene;
  152135. private _currentPriorityLevel;
  152136. private _targetFrameRate;
  152137. private _trackerDuration;
  152138. private _currentFrameRate;
  152139. private _sceneDisposeObserver;
  152140. private _improvementMode;
  152141. /**
  152142. * Defines an observable called when the optimizer reaches the target frame rate
  152143. */
  152144. onSuccessObservable: Observable<SceneOptimizer>;
  152145. /**
  152146. * Defines an observable called when the optimizer enables an optimization
  152147. */
  152148. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  152149. /**
  152150. * Defines an observable called when the optimizer is not able to reach the target frame rate
  152151. */
  152152. onFailureObservable: Observable<SceneOptimizer>;
  152153. /**
  152154. * Gets a boolean indicating if the optimizer is in improvement mode
  152155. */
  152156. get isInImprovementMode(): boolean;
  152157. /**
  152158. * Gets the current priority level (0 at start)
  152159. */
  152160. get currentPriorityLevel(): number;
  152161. /**
  152162. * Gets the current frame rate checked by the SceneOptimizer
  152163. */
  152164. get currentFrameRate(): number;
  152165. /**
  152166. * Gets or sets the current target frame rate (60 by default)
  152167. */
  152168. get targetFrameRate(): number;
  152169. /**
  152170. * Gets or sets the current target frame rate (60 by default)
  152171. */
  152172. set targetFrameRate(value: number);
  152173. /**
  152174. * Gets or sets the current interval between two checks (every 2000ms by default)
  152175. */
  152176. get trackerDuration(): number;
  152177. /**
  152178. * Gets or sets the current interval between two checks (every 2000ms by default)
  152179. */
  152180. set trackerDuration(value: number);
  152181. /**
  152182. * Gets the list of active optimizations
  152183. */
  152184. get optimizations(): SceneOptimization[];
  152185. /**
  152186. * Creates a new SceneOptimizer
  152187. * @param scene defines the scene to work on
  152188. * @param options defines the options to use with the SceneOptimizer
  152189. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  152190. * @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)
  152191. */
  152192. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  152193. /**
  152194. * Stops the current optimizer
  152195. */
  152196. stop(): void;
  152197. /**
  152198. * Reset the optimizer to initial step (current priority level = 0)
  152199. */
  152200. reset(): void;
  152201. /**
  152202. * Start the optimizer. By default it will try to reach a specific framerate
  152203. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  152204. */
  152205. start(): void;
  152206. private _checkCurrentState;
  152207. /**
  152208. * Release all resources
  152209. */
  152210. dispose(): void;
  152211. /**
  152212. * Helper function to create a SceneOptimizer with one single line of code
  152213. * @param scene defines the scene to work on
  152214. * @param options defines the options to use with the SceneOptimizer
  152215. * @param onSuccess defines a callback to call on success
  152216. * @param onFailure defines a callback to call on failure
  152217. * @returns the new SceneOptimizer object
  152218. */
  152219. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  152220. }
  152221. }
  152222. declare module BABYLON {
  152223. /**
  152224. * Class used to serialize a scene into a string
  152225. */
  152226. export class SceneSerializer {
  152227. /**
  152228. * Clear cache used by a previous serialization
  152229. */
  152230. static ClearCache(): void;
  152231. /**
  152232. * Serialize a scene into a JSON compatible object
  152233. * @param scene defines the scene to serialize
  152234. * @returns a JSON compatible object
  152235. */
  152236. static Serialize(scene: Scene): any;
  152237. /**
  152238. * Serialize a mesh into a JSON compatible object
  152239. * @param toSerialize defines the mesh to serialize
  152240. * @param withParents defines if parents must be serialized as well
  152241. * @param withChildren defines if children must be serialized as well
  152242. * @returns a JSON compatible object
  152243. */
  152244. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  152245. }
  152246. }
  152247. declare module BABYLON {
  152248. /**
  152249. * Class used to host texture specific utilities
  152250. */
  152251. export class TextureTools {
  152252. /**
  152253. * Uses the GPU to create a copy texture rescaled at a given size
  152254. * @param texture Texture to copy from
  152255. * @param width defines the desired width
  152256. * @param height defines the desired height
  152257. * @param useBilinearMode defines if bilinear mode has to be used
  152258. * @return the generated texture
  152259. */
  152260. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  152261. }
  152262. }
  152263. declare module BABYLON {
  152264. /**
  152265. * This represents the different options available for the video capture.
  152266. */
  152267. export interface VideoRecorderOptions {
  152268. /** Defines the mime type of the video. */
  152269. mimeType: string;
  152270. /** Defines the FPS the video should be recorded at. */
  152271. fps: number;
  152272. /** Defines the chunk size for the recording data. */
  152273. recordChunckSize: number;
  152274. /** The audio tracks to attach to the recording. */
  152275. audioTracks?: MediaStreamTrack[];
  152276. }
  152277. /**
  152278. * This can help with recording videos from BabylonJS.
  152279. * This is based on the available WebRTC functionalities of the browser.
  152280. *
  152281. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  152282. */
  152283. export class VideoRecorder {
  152284. private static readonly _defaultOptions;
  152285. /**
  152286. * Returns whether or not the VideoRecorder is available in your browser.
  152287. * @param engine Defines the Babylon Engine.
  152288. * @returns true if supported otherwise false.
  152289. */
  152290. static IsSupported(engine: Engine): boolean;
  152291. private readonly _options;
  152292. private _canvas;
  152293. private _mediaRecorder;
  152294. private _recordedChunks;
  152295. private _fileName;
  152296. private _resolve;
  152297. private _reject;
  152298. /**
  152299. * True when a recording is already in progress.
  152300. */
  152301. get isRecording(): boolean;
  152302. /**
  152303. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  152304. * @param engine Defines the BabylonJS Engine you wish to record.
  152305. * @param options Defines options that can be used to customize the capture.
  152306. */
  152307. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  152308. /**
  152309. * Stops the current recording before the default capture timeout passed in the startRecording function.
  152310. */
  152311. stopRecording(): void;
  152312. /**
  152313. * Starts recording the canvas for a max duration specified in parameters.
  152314. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  152315. * If null no automatic download will start and you can rely on the promise to get the data back.
  152316. * @param maxDuration Defines the maximum recording time in seconds.
  152317. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  152318. * @return A promise callback at the end of the recording with the video data in Blob.
  152319. */
  152320. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  152321. /**
  152322. * Releases internal resources used during the recording.
  152323. */
  152324. dispose(): void;
  152325. private _handleDataAvailable;
  152326. private _handleError;
  152327. private _handleStop;
  152328. }
  152329. }
  152330. declare module BABYLON {
  152331. /**
  152332. * Class containing a set of static utilities functions for screenshots
  152333. */
  152334. export class ScreenshotTools {
  152335. /**
  152336. * Captures a screenshot of the current rendering
  152337. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152338. * @param engine defines the rendering engine
  152339. * @param camera defines the source camera
  152340. * @param size This parameter can be set to a single number or to an object with the
  152341. * following (optional) properties: precision, width, height. If a single number is passed,
  152342. * it will be used for both width and height. If an object is passed, the screenshot size
  152343. * will be derived from the parameters. The precision property is a multiplier allowing
  152344. * rendering at a higher or lower resolution
  152345. * @param successCallback defines the callback receives a single parameter which contains the
  152346. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152347. * src parameter of an <img> to display it
  152348. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152349. * Check your browser for supported MIME types
  152350. */
  152351. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  152352. /**
  152353. * Captures a screenshot of the current rendering
  152354. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152355. * @param engine defines the rendering engine
  152356. * @param camera defines the source camera
  152357. * @param size This parameter can be set to a single number or to an object with the
  152358. * following (optional) properties: precision, width, height. If a single number is passed,
  152359. * it will be used for both width and height. If an object is passed, the screenshot size
  152360. * will be derived from the parameters. The precision property is a multiplier allowing
  152361. * rendering at a higher or lower resolution
  152362. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152363. * Check your browser for supported MIME types
  152364. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152365. * to the src parameter of an <img> to display it
  152366. */
  152367. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  152368. /**
  152369. * Generates an image screenshot from the specified camera.
  152370. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152371. * @param engine The engine to use for rendering
  152372. * @param camera The camera to use for rendering
  152373. * @param size This parameter can be set to a single number or to an object with the
  152374. * following (optional) properties: precision, width, height. If a single number is passed,
  152375. * it will be used for both width and height. If an object is passed, the screenshot size
  152376. * will be derived from the parameters. The precision property is a multiplier allowing
  152377. * rendering at a higher or lower resolution
  152378. * @param successCallback The callback receives a single parameter which contains the
  152379. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152380. * src parameter of an <img> to display it
  152381. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152382. * Check your browser for supported MIME types
  152383. * @param samples Texture samples (default: 1)
  152384. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152385. * @param fileName A name for for the downloaded file.
  152386. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152387. */
  152388. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  152389. /**
  152390. * Generates an image screenshot from the specified camera.
  152391. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152392. * @param engine The engine to use for rendering
  152393. * @param camera The camera to use for rendering
  152394. * @param size This parameter can be set to a single number or to an object with the
  152395. * following (optional) properties: precision, width, height. If a single number is passed,
  152396. * it will be used for both width and height. If an object is passed, the screenshot size
  152397. * will be derived from the parameters. The precision property is a multiplier allowing
  152398. * rendering at a higher or lower resolution
  152399. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152400. * Check your browser for supported MIME types
  152401. * @param samples Texture samples (default: 1)
  152402. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152403. * @param fileName A name for for the downloaded file.
  152404. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152405. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152406. * to the src parameter of an <img> to display it
  152407. */
  152408. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  152409. /**
  152410. * Gets height and width for screenshot size
  152411. * @private
  152412. */
  152413. private static _getScreenshotSize;
  152414. }
  152415. }
  152416. declare module BABYLON {
  152417. /**
  152418. * Interface for a data buffer
  152419. */
  152420. export interface IDataBuffer {
  152421. /**
  152422. * Reads bytes from the data buffer.
  152423. * @param byteOffset The byte offset to read
  152424. * @param byteLength The byte length to read
  152425. * @returns A promise that resolves when the bytes are read
  152426. */
  152427. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  152428. /**
  152429. * The byte length of the buffer.
  152430. */
  152431. readonly byteLength: number;
  152432. }
  152433. /**
  152434. * Utility class for reading from a data buffer
  152435. */
  152436. export class DataReader {
  152437. /**
  152438. * The data buffer associated with this data reader.
  152439. */
  152440. readonly buffer: IDataBuffer;
  152441. /**
  152442. * The current byte offset from the beginning of the data buffer.
  152443. */
  152444. byteOffset: number;
  152445. private _dataView;
  152446. private _dataByteOffset;
  152447. /**
  152448. * Constructor
  152449. * @param buffer The buffer to read
  152450. */
  152451. constructor(buffer: IDataBuffer);
  152452. /**
  152453. * Loads the given byte length.
  152454. * @param byteLength The byte length to load
  152455. * @returns A promise that resolves when the load is complete
  152456. */
  152457. loadAsync(byteLength: number): Promise<void>;
  152458. /**
  152459. * Read a unsigned 32-bit integer from the currently loaded data range.
  152460. * @returns The 32-bit integer read
  152461. */
  152462. readUint32(): number;
  152463. /**
  152464. * Read a byte array from the currently loaded data range.
  152465. * @param byteLength The byte length to read
  152466. * @returns The byte array read
  152467. */
  152468. readUint8Array(byteLength: number): Uint8Array;
  152469. /**
  152470. * Read a string from the currently loaded data range.
  152471. * @param byteLength The byte length to read
  152472. * @returns The string read
  152473. */
  152474. readString(byteLength: number): string;
  152475. /**
  152476. * Skips the given byte length the currently loaded data range.
  152477. * @param byteLength The byte length to skip
  152478. */
  152479. skipBytes(byteLength: number): void;
  152480. }
  152481. }
  152482. declare module BABYLON {
  152483. /**
  152484. * Class for storing data to local storage if available or in-memory storage otherwise
  152485. */
  152486. export class DataStorage {
  152487. private static _Storage;
  152488. private static _GetStorage;
  152489. /**
  152490. * Reads a string from the data storage
  152491. * @param key The key to read
  152492. * @param defaultValue The value if the key doesn't exist
  152493. * @returns The string value
  152494. */
  152495. static ReadString(key: string, defaultValue: string): string;
  152496. /**
  152497. * Writes a string to the data storage
  152498. * @param key The key to write
  152499. * @param value The value to write
  152500. */
  152501. static WriteString(key: string, value: string): void;
  152502. /**
  152503. * Reads a boolean from the data storage
  152504. * @param key The key to read
  152505. * @param defaultValue The value if the key doesn't exist
  152506. * @returns The boolean value
  152507. */
  152508. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  152509. /**
  152510. * Writes a boolean to the data storage
  152511. * @param key The key to write
  152512. * @param value The value to write
  152513. */
  152514. static WriteBoolean(key: string, value: boolean): void;
  152515. /**
  152516. * Reads a number from the data storage
  152517. * @param key The key to read
  152518. * @param defaultValue The value if the key doesn't exist
  152519. * @returns The number value
  152520. */
  152521. static ReadNumber(key: string, defaultValue: number): number;
  152522. /**
  152523. * Writes a number to the data storage
  152524. * @param key The key to write
  152525. * @param value The value to write
  152526. */
  152527. static WriteNumber(key: string, value: number): void;
  152528. }
  152529. }
  152530. declare module BABYLON {
  152531. /**
  152532. * Class used to record delta files between 2 scene states
  152533. */
  152534. export class SceneRecorder {
  152535. private _trackedScene;
  152536. private _savedJSON;
  152537. /**
  152538. * Track a given scene. This means the current scene state will be considered the original state
  152539. * @param scene defines the scene to track
  152540. */
  152541. track(scene: Scene): void;
  152542. /**
  152543. * Get the delta between current state and original state
  152544. * @returns a string containing the delta
  152545. */
  152546. getDelta(): any;
  152547. private _compareArray;
  152548. private _compareObjects;
  152549. private _compareCollections;
  152550. private static GetShadowGeneratorById;
  152551. /**
  152552. * Apply a given delta to a given scene
  152553. * @param deltaJSON defines the JSON containing the delta
  152554. * @param scene defines the scene to apply the delta to
  152555. */
  152556. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  152557. private static _ApplyPropertiesToEntity;
  152558. private static _ApplyDeltaForEntity;
  152559. }
  152560. }
  152561. declare module BABYLON {
  152562. /**
  152563. * An interface for all Hit test features
  152564. */
  152565. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  152566. /**
  152567. * Triggered when new babylon (transformed) hit test results are available
  152568. */
  152569. onHitTestResultObservable: Observable<T[]>;
  152570. }
  152571. /**
  152572. * Options used for hit testing
  152573. */
  152574. export interface IWebXRLegacyHitTestOptions {
  152575. /**
  152576. * Only test when user interacted with the scene. Default - hit test every frame
  152577. */
  152578. testOnPointerDownOnly?: boolean;
  152579. /**
  152580. * The node to use to transform the local results to world coordinates
  152581. */
  152582. worldParentNode?: TransformNode;
  152583. }
  152584. /**
  152585. * Interface defining the babylon result of raycasting/hit-test
  152586. */
  152587. export interface IWebXRLegacyHitResult {
  152588. /**
  152589. * Transformation matrix that can be applied to a node that will put it in the hit point location
  152590. */
  152591. transformationMatrix: Matrix;
  152592. /**
  152593. * The native hit test result
  152594. */
  152595. xrHitResult: XRHitResult | XRHitTestResult;
  152596. }
  152597. /**
  152598. * The currently-working hit-test module.
  152599. * Hit test (or Ray-casting) is used to interact with the real world.
  152600. * For further information read here - https://github.com/immersive-web/hit-test
  152601. */
  152602. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  152603. /**
  152604. * options to use when constructing this feature
  152605. */
  152606. readonly options: IWebXRLegacyHitTestOptions;
  152607. private _direction;
  152608. private _mat;
  152609. private _onSelectEnabled;
  152610. private _origin;
  152611. /**
  152612. * The module's name
  152613. */
  152614. static readonly Name: string;
  152615. /**
  152616. * The (Babylon) version of this module.
  152617. * This is an integer representing the implementation version.
  152618. * This number does not correspond to the WebXR specs version
  152619. */
  152620. static readonly Version: number;
  152621. /**
  152622. * Populated with the last native XR Hit Results
  152623. */
  152624. lastNativeXRHitResults: XRHitResult[];
  152625. /**
  152626. * Triggered when new babylon (transformed) hit test results are available
  152627. */
  152628. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  152629. /**
  152630. * Creates a new instance of the (legacy version) hit test feature
  152631. * @param _xrSessionManager an instance of WebXRSessionManager
  152632. * @param options options to use when constructing this feature
  152633. */
  152634. constructor(_xrSessionManager: WebXRSessionManager,
  152635. /**
  152636. * options to use when constructing this feature
  152637. */
  152638. options?: IWebXRLegacyHitTestOptions);
  152639. /**
  152640. * execute a hit test with an XR Ray
  152641. *
  152642. * @param xrSession a native xrSession that will execute this hit test
  152643. * @param xrRay the ray (position and direction) to use for ray-casting
  152644. * @param referenceSpace native XR reference space to use for the hit-test
  152645. * @param filter filter function that will filter the results
  152646. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152647. */
  152648. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  152649. /**
  152650. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  152651. * @param event the (select) event to use to select with
  152652. * @param referenceSpace the reference space to use for this hit test
  152653. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152654. */
  152655. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152656. /**
  152657. * attach this feature
  152658. * Will usually be called by the features manager
  152659. *
  152660. * @returns true if successful.
  152661. */
  152662. attach(): boolean;
  152663. /**
  152664. * detach this feature.
  152665. * Will usually be called by the features manager
  152666. *
  152667. * @returns true if successful.
  152668. */
  152669. detach(): boolean;
  152670. /**
  152671. * Dispose this feature and all of the resources attached
  152672. */
  152673. dispose(): void;
  152674. protected _onXRFrame(frame: XRFrame): void;
  152675. private _onHitTestResults;
  152676. private _onSelect;
  152677. }
  152678. }
  152679. declare module BABYLON {
  152680. /**
  152681. * Options used for hit testing (version 2)
  152682. */
  152683. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  152684. /**
  152685. * Do not create a permanent hit test. Will usually be used when only
  152686. * transient inputs are needed.
  152687. */
  152688. disablePermanentHitTest?: boolean;
  152689. /**
  152690. * Enable transient (for example touch-based) hit test inspections
  152691. */
  152692. enableTransientHitTest?: boolean;
  152693. /**
  152694. * Offset ray for the permanent hit test
  152695. */
  152696. offsetRay?: Vector3;
  152697. /**
  152698. * Offset ray for the transient hit test
  152699. */
  152700. transientOffsetRay?: Vector3;
  152701. /**
  152702. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  152703. */
  152704. useReferenceSpace?: boolean;
  152705. }
  152706. /**
  152707. * Interface defining the babylon result of hit-test
  152708. */
  152709. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  152710. /**
  152711. * The input source that generated this hit test (if transient)
  152712. */
  152713. inputSource?: XRInputSource;
  152714. /**
  152715. * Is this a transient hit test
  152716. */
  152717. isTransient?: boolean;
  152718. /**
  152719. * Position of the hit test result
  152720. */
  152721. position: Vector3;
  152722. /**
  152723. * Rotation of the hit test result
  152724. */
  152725. rotationQuaternion: Quaternion;
  152726. /**
  152727. * The native hit test result
  152728. */
  152729. xrHitResult: XRHitTestResult;
  152730. }
  152731. /**
  152732. * The currently-working hit-test module.
  152733. * Hit test (or Ray-casting) is used to interact with the real world.
  152734. * For further information read here - https://github.com/immersive-web/hit-test
  152735. *
  152736. * Tested on chrome (mobile) 80.
  152737. */
  152738. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  152739. /**
  152740. * options to use when constructing this feature
  152741. */
  152742. readonly options: IWebXRHitTestOptions;
  152743. private _tmpMat;
  152744. private _tmpPos;
  152745. private _tmpQuat;
  152746. private _transientXrHitTestSource;
  152747. private _xrHitTestSource;
  152748. private initHitTestSource;
  152749. /**
  152750. * The module's name
  152751. */
  152752. static readonly Name: string;
  152753. /**
  152754. * The (Babylon) version of this module.
  152755. * This is an integer representing the implementation version.
  152756. * This number does not correspond to the WebXR specs version
  152757. */
  152758. static readonly Version: number;
  152759. /**
  152760. * When set to true, each hit test will have its own position/rotation objects
  152761. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  152762. * the developers will clone them or copy them as they see fit.
  152763. */
  152764. autoCloneTransformation: boolean;
  152765. /**
  152766. * Triggered when new babylon (transformed) hit test results are available
  152767. */
  152768. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  152769. /**
  152770. * Use this to temporarily pause hit test checks.
  152771. */
  152772. paused: boolean;
  152773. /**
  152774. * Creates a new instance of the hit test feature
  152775. * @param _xrSessionManager an instance of WebXRSessionManager
  152776. * @param options options to use when constructing this feature
  152777. */
  152778. constructor(_xrSessionManager: WebXRSessionManager,
  152779. /**
  152780. * options to use when constructing this feature
  152781. */
  152782. options?: IWebXRHitTestOptions);
  152783. /**
  152784. * attach this feature
  152785. * Will usually be called by the features manager
  152786. *
  152787. * @returns true if successful.
  152788. */
  152789. attach(): boolean;
  152790. /**
  152791. * detach this feature.
  152792. * Will usually be called by the features manager
  152793. *
  152794. * @returns true if successful.
  152795. */
  152796. detach(): boolean;
  152797. /**
  152798. * Dispose this feature and all of the resources attached
  152799. */
  152800. dispose(): void;
  152801. protected _onXRFrame(frame: XRFrame): void;
  152802. private _processWebXRHitTestResult;
  152803. }
  152804. }
  152805. declare module BABYLON {
  152806. /**
  152807. * Configuration options of the anchor system
  152808. */
  152809. export interface IWebXRAnchorSystemOptions {
  152810. /**
  152811. * a node that will be used to convert local to world coordinates
  152812. */
  152813. worldParentNode?: TransformNode;
  152814. /**
  152815. * If set to true a reference of the created anchors will be kept until the next session starts
  152816. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  152817. */
  152818. doNotRemoveAnchorsOnSessionEnded?: boolean;
  152819. }
  152820. /**
  152821. * A babylon container for an XR Anchor
  152822. */
  152823. export interface IWebXRAnchor {
  152824. /**
  152825. * A babylon-assigned ID for this anchor
  152826. */
  152827. id: number;
  152828. /**
  152829. * Transformation matrix to apply to an object attached to this anchor
  152830. */
  152831. transformationMatrix: Matrix;
  152832. /**
  152833. * The native anchor object
  152834. */
  152835. xrAnchor: XRAnchor;
  152836. /**
  152837. * if defined, this object will be constantly updated by the anchor's position and rotation
  152838. */
  152839. attachedNode?: TransformNode;
  152840. }
  152841. /**
  152842. * An implementation of the anchor system for WebXR.
  152843. * For further information see https://github.com/immersive-web/anchors/
  152844. */
  152845. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  152846. private _options;
  152847. private _lastFrameDetected;
  152848. private _trackedAnchors;
  152849. private _referenceSpaceForFrameAnchors;
  152850. private _futureAnchors;
  152851. /**
  152852. * The module's name
  152853. */
  152854. static readonly Name: string;
  152855. /**
  152856. * The (Babylon) version of this module.
  152857. * This is an integer representing the implementation version.
  152858. * This number does not correspond to the WebXR specs version
  152859. */
  152860. static readonly Version: number;
  152861. /**
  152862. * Observers registered here will be executed when a new anchor was added to the session
  152863. */
  152864. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  152865. /**
  152866. * Observers registered here will be executed when an anchor was removed from the session
  152867. */
  152868. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  152869. /**
  152870. * Observers registered here will be executed when an existing anchor updates
  152871. * This can execute N times every frame
  152872. */
  152873. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  152874. /**
  152875. * Set the reference space to use for anchor creation, when not using a hit test.
  152876. * Will default to the session's reference space if not defined
  152877. */
  152878. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  152879. /**
  152880. * constructs a new anchor system
  152881. * @param _xrSessionManager an instance of WebXRSessionManager
  152882. * @param _options configuration object for this feature
  152883. */
  152884. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  152885. private _tmpVector;
  152886. private _tmpQuaternion;
  152887. private _populateTmpTransformation;
  152888. /**
  152889. * Create a new anchor point using a hit test result at a specific point in the scene
  152890. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152891. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152892. *
  152893. * @param hitTestResult The hit test result to use for this anchor creation
  152894. * @param position an optional position offset for this anchor
  152895. * @param rotationQuaternion an optional rotation offset for this anchor
  152896. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152897. */
  152898. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  152899. /**
  152900. * Add a new anchor at a specific position and rotation
  152901. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  152902. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  152903. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152904. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152905. *
  152906. * @param position the position in which to add an anchor
  152907. * @param rotationQuaternion an optional rotation for the anchor transformation
  152908. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  152909. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152910. */
  152911. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  152912. /**
  152913. * detach this feature.
  152914. * Will usually be called by the features manager
  152915. *
  152916. * @returns true if successful.
  152917. */
  152918. detach(): boolean;
  152919. /**
  152920. * Dispose this feature and all of the resources attached
  152921. */
  152922. dispose(): void;
  152923. protected _onXRFrame(frame: XRFrame): void;
  152924. /**
  152925. * avoiding using Array.find for global support.
  152926. * @param xrAnchor the plane to find in the array
  152927. */
  152928. private _findIndexInAnchorArray;
  152929. private _updateAnchorWithXRFrame;
  152930. private _createAnchorAtTransformation;
  152931. }
  152932. }
  152933. declare module BABYLON {
  152934. /**
  152935. * Options used in the plane detector module
  152936. */
  152937. export interface IWebXRPlaneDetectorOptions {
  152938. /**
  152939. * The node to use to transform the local results to world coordinates
  152940. */
  152941. worldParentNode?: TransformNode;
  152942. /**
  152943. * If set to true a reference of the created planes will be kept until the next session starts
  152944. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  152945. */
  152946. doNotRemovePlanesOnSessionEnded?: boolean;
  152947. }
  152948. /**
  152949. * A babylon interface for a WebXR plane.
  152950. * A Plane is actually a polygon, built from N points in space
  152951. *
  152952. * Supported in chrome 79, not supported in canary 81 ATM
  152953. */
  152954. export interface IWebXRPlane {
  152955. /**
  152956. * a babylon-assigned ID for this polygon
  152957. */
  152958. id: number;
  152959. /**
  152960. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  152961. */
  152962. polygonDefinition: Array<Vector3>;
  152963. /**
  152964. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  152965. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  152966. */
  152967. transformationMatrix: Matrix;
  152968. /**
  152969. * the native xr-plane object
  152970. */
  152971. xrPlane: XRPlane;
  152972. }
  152973. /**
  152974. * The plane detector is used to detect planes in the real world when in AR
  152975. * For more information see https://github.com/immersive-web/real-world-geometry/
  152976. */
  152977. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  152978. private _options;
  152979. private _detectedPlanes;
  152980. private _enabled;
  152981. private _lastFrameDetected;
  152982. /**
  152983. * The module's name
  152984. */
  152985. static readonly Name: string;
  152986. /**
  152987. * The (Babylon) version of this module.
  152988. * This is an integer representing the implementation version.
  152989. * This number does not correspond to the WebXR specs version
  152990. */
  152991. static readonly Version: number;
  152992. /**
  152993. * Observers registered here will be executed when a new plane was added to the session
  152994. */
  152995. onPlaneAddedObservable: Observable<IWebXRPlane>;
  152996. /**
  152997. * Observers registered here will be executed when a plane is no longer detected in the session
  152998. */
  152999. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  153000. /**
  153001. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  153002. * This can execute N times every frame
  153003. */
  153004. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  153005. /**
  153006. * construct a new Plane Detector
  153007. * @param _xrSessionManager an instance of xr Session manager
  153008. * @param _options configuration to use when constructing this feature
  153009. */
  153010. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  153011. /**
  153012. * detach this feature.
  153013. * Will usually be called by the features manager
  153014. *
  153015. * @returns true if successful.
  153016. */
  153017. detach(): boolean;
  153018. /**
  153019. * Dispose this feature and all of the resources attached
  153020. */
  153021. dispose(): void;
  153022. protected _onXRFrame(frame: XRFrame): void;
  153023. private _init;
  153024. private _updatePlaneWithXRPlane;
  153025. /**
  153026. * avoiding using Array.find for global support.
  153027. * @param xrPlane the plane to find in the array
  153028. */
  153029. private findIndexInPlaneArray;
  153030. }
  153031. }
  153032. declare module BABYLON {
  153033. /**
  153034. * Options interface for the background remover plugin
  153035. */
  153036. export interface IWebXRBackgroundRemoverOptions {
  153037. /**
  153038. * Further background meshes to disable when entering AR
  153039. */
  153040. backgroundMeshes?: AbstractMesh[];
  153041. /**
  153042. * flags to configure the removal of the environment helper.
  153043. * If not set, the entire background will be removed. If set, flags should be set as well.
  153044. */
  153045. environmentHelperRemovalFlags?: {
  153046. /**
  153047. * Should the skybox be removed (default false)
  153048. */
  153049. skyBox?: boolean;
  153050. /**
  153051. * Should the ground be removed (default false)
  153052. */
  153053. ground?: boolean;
  153054. };
  153055. /**
  153056. * don't disable the environment helper
  153057. */
  153058. ignoreEnvironmentHelper?: boolean;
  153059. }
  153060. /**
  153061. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  153062. */
  153063. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  153064. /**
  153065. * read-only options to be used in this module
  153066. */
  153067. readonly options: IWebXRBackgroundRemoverOptions;
  153068. /**
  153069. * The module's name
  153070. */
  153071. static readonly Name: string;
  153072. /**
  153073. * The (Babylon) version of this module.
  153074. * This is an integer representing the implementation version.
  153075. * This number does not correspond to the WebXR specs version
  153076. */
  153077. static readonly Version: number;
  153078. /**
  153079. * registered observers will be triggered when the background state changes
  153080. */
  153081. onBackgroundStateChangedObservable: Observable<boolean>;
  153082. /**
  153083. * constructs a new background remover module
  153084. * @param _xrSessionManager the session manager for this module
  153085. * @param options read-only options to be used in this module
  153086. */
  153087. constructor(_xrSessionManager: WebXRSessionManager,
  153088. /**
  153089. * read-only options to be used in this module
  153090. */
  153091. options?: IWebXRBackgroundRemoverOptions);
  153092. /**
  153093. * attach this feature
  153094. * Will usually be called by the features manager
  153095. *
  153096. * @returns true if successful.
  153097. */
  153098. attach(): boolean;
  153099. /**
  153100. * detach this feature.
  153101. * Will usually be called by the features manager
  153102. *
  153103. * @returns true if successful.
  153104. */
  153105. detach(): boolean;
  153106. /**
  153107. * Dispose this feature and all of the resources attached
  153108. */
  153109. dispose(): void;
  153110. protected _onXRFrame(_xrFrame: XRFrame): void;
  153111. private _setBackgroundState;
  153112. }
  153113. }
  153114. declare module BABYLON {
  153115. /**
  153116. * Options for the controller physics feature
  153117. */
  153118. export class IWebXRControllerPhysicsOptions {
  153119. /**
  153120. * Should the headset get its own impostor
  153121. */
  153122. enableHeadsetImpostor?: boolean;
  153123. /**
  153124. * Optional parameters for the headset impostor
  153125. */
  153126. headsetImpostorParams?: {
  153127. /**
  153128. * The type of impostor to create. Default is sphere
  153129. */
  153130. impostorType: number;
  153131. /**
  153132. * the size of the impostor. Defaults to 10cm
  153133. */
  153134. impostorSize?: number | {
  153135. width: number;
  153136. height: number;
  153137. depth: number;
  153138. };
  153139. /**
  153140. * Friction definitions
  153141. */
  153142. friction?: number;
  153143. /**
  153144. * Restitution
  153145. */
  153146. restitution?: number;
  153147. };
  153148. /**
  153149. * The physics properties of the future impostors
  153150. */
  153151. physicsProperties?: {
  153152. /**
  153153. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  153154. * Note that this requires a physics engine that supports mesh impostors!
  153155. */
  153156. useControllerMesh?: boolean;
  153157. /**
  153158. * The type of impostor to create. Default is sphere
  153159. */
  153160. impostorType?: number;
  153161. /**
  153162. * the size of the impostor. Defaults to 10cm
  153163. */
  153164. impostorSize?: number | {
  153165. width: number;
  153166. height: number;
  153167. depth: number;
  153168. };
  153169. /**
  153170. * Friction definitions
  153171. */
  153172. friction?: number;
  153173. /**
  153174. * Restitution
  153175. */
  153176. restitution?: number;
  153177. };
  153178. /**
  153179. * the xr input to use with this pointer selection
  153180. */
  153181. xrInput: WebXRInput;
  153182. }
  153183. /**
  153184. * Add physics impostor to your webxr controllers,
  153185. * including naive calculation of their linear and angular velocity
  153186. */
  153187. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  153188. private readonly _options;
  153189. private _attachController;
  153190. private _controllers;
  153191. private _debugMode;
  153192. private _delta;
  153193. private _headsetImpostor?;
  153194. private _headsetMesh?;
  153195. private _lastTimestamp;
  153196. private _tmpQuaternion;
  153197. private _tmpVector;
  153198. /**
  153199. * The module's name
  153200. */
  153201. static readonly Name: string;
  153202. /**
  153203. * The (Babylon) version of this module.
  153204. * This is an integer representing the implementation version.
  153205. * This number does not correspond to the webxr specs version
  153206. */
  153207. static readonly Version: number;
  153208. /**
  153209. * Construct a new Controller Physics Feature
  153210. * @param _xrSessionManager the corresponding xr session manager
  153211. * @param _options options to create this feature with
  153212. */
  153213. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  153214. /**
  153215. * @hidden
  153216. * enable debugging - will show console outputs and the impostor mesh
  153217. */
  153218. _enablePhysicsDebug(): void;
  153219. /**
  153220. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  153221. * @param xrController the controller to add
  153222. */
  153223. addController(xrController: WebXRInputSource): void;
  153224. /**
  153225. * attach this feature
  153226. * Will usually be called by the features manager
  153227. *
  153228. * @returns true if successful.
  153229. */
  153230. attach(): boolean;
  153231. /**
  153232. * detach this feature.
  153233. * Will usually be called by the features manager
  153234. *
  153235. * @returns true if successful.
  153236. */
  153237. detach(): boolean;
  153238. /**
  153239. * Get the headset impostor, if enabled
  153240. * @returns the impostor
  153241. */
  153242. getHeadsetImpostor(): PhysicsImpostor | undefined;
  153243. /**
  153244. * Get the physics impostor of a specific controller.
  153245. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  153246. * @param controller the controller or the controller id of which to get the impostor
  153247. * @returns the impostor or null
  153248. */
  153249. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  153250. /**
  153251. * Update the physics properties provided in the constructor
  153252. * @param newProperties the new properties object
  153253. */
  153254. setPhysicsProperties(newProperties: {
  153255. impostorType?: number;
  153256. impostorSize?: number | {
  153257. width: number;
  153258. height: number;
  153259. depth: number;
  153260. };
  153261. friction?: number;
  153262. restitution?: number;
  153263. }): void;
  153264. protected _onXRFrame(_xrFrame: any): void;
  153265. private _detachController;
  153266. }
  153267. }
  153268. declare module BABYLON {
  153269. /**
  153270. * The motion controller class for all microsoft mixed reality controllers
  153271. */
  153272. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  153273. protected readonly _mapping: {
  153274. defaultButton: {
  153275. valueNodeName: string;
  153276. unpressedNodeName: string;
  153277. pressedNodeName: string;
  153278. };
  153279. defaultAxis: {
  153280. valueNodeName: string;
  153281. minNodeName: string;
  153282. maxNodeName: string;
  153283. };
  153284. buttons: {
  153285. "xr-standard-trigger": {
  153286. rootNodeName: string;
  153287. componentProperty: string;
  153288. states: string[];
  153289. };
  153290. "xr-standard-squeeze": {
  153291. rootNodeName: string;
  153292. componentProperty: string;
  153293. states: string[];
  153294. };
  153295. "xr-standard-touchpad": {
  153296. rootNodeName: string;
  153297. labelAnchorNodeName: string;
  153298. touchPointNodeName: string;
  153299. };
  153300. "xr-standard-thumbstick": {
  153301. rootNodeName: string;
  153302. componentProperty: string;
  153303. states: string[];
  153304. };
  153305. };
  153306. axes: {
  153307. "xr-standard-touchpad": {
  153308. "x-axis": {
  153309. rootNodeName: string;
  153310. };
  153311. "y-axis": {
  153312. rootNodeName: string;
  153313. };
  153314. };
  153315. "xr-standard-thumbstick": {
  153316. "x-axis": {
  153317. rootNodeName: string;
  153318. };
  153319. "y-axis": {
  153320. rootNodeName: string;
  153321. };
  153322. };
  153323. };
  153324. };
  153325. /**
  153326. * The base url used to load the left and right controller models
  153327. */
  153328. static MODEL_BASE_URL: string;
  153329. /**
  153330. * The name of the left controller model file
  153331. */
  153332. static MODEL_LEFT_FILENAME: string;
  153333. /**
  153334. * The name of the right controller model file
  153335. */
  153336. static MODEL_RIGHT_FILENAME: string;
  153337. profileId: string;
  153338. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153339. protected _getFilenameAndPath(): {
  153340. filename: string;
  153341. path: string;
  153342. };
  153343. protected _getModelLoadingConstraints(): boolean;
  153344. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153345. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153346. protected _updateModel(): void;
  153347. }
  153348. }
  153349. declare module BABYLON {
  153350. /**
  153351. * The motion controller class for oculus touch (quest, rift).
  153352. * This class supports legacy mapping as well the standard xr mapping
  153353. */
  153354. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  153355. private _forceLegacyControllers;
  153356. private _modelRootNode;
  153357. /**
  153358. * The base url used to load the left and right controller models
  153359. */
  153360. static MODEL_BASE_URL: string;
  153361. /**
  153362. * The name of the left controller model file
  153363. */
  153364. static MODEL_LEFT_FILENAME: string;
  153365. /**
  153366. * The name of the right controller model file
  153367. */
  153368. static MODEL_RIGHT_FILENAME: string;
  153369. /**
  153370. * Base Url for the Quest controller model.
  153371. */
  153372. static QUEST_MODEL_BASE_URL: string;
  153373. profileId: string;
  153374. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  153375. protected _getFilenameAndPath(): {
  153376. filename: string;
  153377. path: string;
  153378. };
  153379. protected _getModelLoadingConstraints(): boolean;
  153380. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153381. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153382. protected _updateModel(): void;
  153383. /**
  153384. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  153385. * between the touch and touch 2.
  153386. */
  153387. private _isQuest;
  153388. }
  153389. }
  153390. declare module BABYLON {
  153391. /**
  153392. * The motion controller class for the standard HTC-Vive controllers
  153393. */
  153394. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  153395. private _modelRootNode;
  153396. /**
  153397. * The base url used to load the left and right controller models
  153398. */
  153399. static MODEL_BASE_URL: string;
  153400. /**
  153401. * File name for the controller model.
  153402. */
  153403. static MODEL_FILENAME: string;
  153404. profileId: string;
  153405. /**
  153406. * Create a new Vive motion controller object
  153407. * @param scene the scene to use to create this controller
  153408. * @param gamepadObject the corresponding gamepad object
  153409. * @param handedness the handedness of the controller
  153410. */
  153411. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153412. protected _getFilenameAndPath(): {
  153413. filename: string;
  153414. path: string;
  153415. };
  153416. protected _getModelLoadingConstraints(): boolean;
  153417. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153418. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153419. protected _updateModel(): void;
  153420. }
  153421. }
  153422. declare module BABYLON {
  153423. /**
  153424. * A cursor which tracks a point on a path
  153425. */
  153426. export class PathCursor {
  153427. private path;
  153428. /**
  153429. * Stores path cursor callbacks for when an onchange event is triggered
  153430. */
  153431. private _onchange;
  153432. /**
  153433. * The value of the path cursor
  153434. */
  153435. value: number;
  153436. /**
  153437. * The animation array of the path cursor
  153438. */
  153439. animations: Animation[];
  153440. /**
  153441. * Initializes the path cursor
  153442. * @param path The path to track
  153443. */
  153444. constructor(path: Path2);
  153445. /**
  153446. * Gets the cursor point on the path
  153447. * @returns A point on the path cursor at the cursor location
  153448. */
  153449. getPoint(): Vector3;
  153450. /**
  153451. * Moves the cursor ahead by the step amount
  153452. * @param step The amount to move the cursor forward
  153453. * @returns This path cursor
  153454. */
  153455. moveAhead(step?: number): PathCursor;
  153456. /**
  153457. * Moves the cursor behind by the step amount
  153458. * @param step The amount to move the cursor back
  153459. * @returns This path cursor
  153460. */
  153461. moveBack(step?: number): PathCursor;
  153462. /**
  153463. * Moves the cursor by the step amount
  153464. * If the step amount is greater than one, an exception is thrown
  153465. * @param step The amount to move the cursor
  153466. * @returns This path cursor
  153467. */
  153468. move(step: number): PathCursor;
  153469. /**
  153470. * Ensures that the value is limited between zero and one
  153471. * @returns This path cursor
  153472. */
  153473. private ensureLimits;
  153474. /**
  153475. * Runs onchange callbacks on change (used by the animation engine)
  153476. * @returns This path cursor
  153477. */
  153478. private raiseOnChange;
  153479. /**
  153480. * Executes a function on change
  153481. * @param f A path cursor onchange callback
  153482. * @returns This path cursor
  153483. */
  153484. onchange(f: (cursor: PathCursor) => void): PathCursor;
  153485. }
  153486. }
  153487. declare module BABYLON {
  153488. /** @hidden */
  153489. export var blurPixelShader: {
  153490. name: string;
  153491. shader: string;
  153492. };
  153493. }
  153494. declare module BABYLON {
  153495. /** @hidden */
  153496. export var pointCloudVertexDeclaration: {
  153497. name: string;
  153498. shader: string;
  153499. };
  153500. }
  153501. // Mixins
  153502. interface Window {
  153503. mozIndexedDB: IDBFactory;
  153504. webkitIndexedDB: IDBFactory;
  153505. msIndexedDB: IDBFactory;
  153506. webkitURL: typeof URL;
  153507. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  153508. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  153509. WebGLRenderingContext: WebGLRenderingContext;
  153510. MSGesture: MSGesture;
  153511. CANNON: any;
  153512. AudioContext: AudioContext;
  153513. webkitAudioContext: AudioContext;
  153514. PointerEvent: any;
  153515. Math: Math;
  153516. Uint8Array: Uint8ArrayConstructor;
  153517. Float32Array: Float32ArrayConstructor;
  153518. mozURL: typeof URL;
  153519. msURL: typeof URL;
  153520. VRFrameData: any; // WebVR, from specs 1.1
  153521. DracoDecoderModule: any;
  153522. setImmediate(handler: (...args: any[]) => void): number;
  153523. }
  153524. interface HTMLCanvasElement {
  153525. requestPointerLock(): void;
  153526. msRequestPointerLock?(): void;
  153527. mozRequestPointerLock?(): void;
  153528. webkitRequestPointerLock?(): void;
  153529. /** Track wether a record is in progress */
  153530. isRecording: boolean;
  153531. /** Capture Stream method defined by some browsers */
  153532. captureStream(fps?: number): MediaStream;
  153533. }
  153534. interface CanvasRenderingContext2D {
  153535. msImageSmoothingEnabled: boolean;
  153536. }
  153537. interface MouseEvent {
  153538. mozMovementX: number;
  153539. mozMovementY: number;
  153540. webkitMovementX: number;
  153541. webkitMovementY: number;
  153542. msMovementX: number;
  153543. msMovementY: number;
  153544. }
  153545. interface Navigator {
  153546. mozGetVRDevices: (any: any) => any;
  153547. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153548. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153549. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153550. webkitGetGamepads(): Gamepad[];
  153551. msGetGamepads(): Gamepad[];
  153552. webkitGamepads(): Gamepad[];
  153553. }
  153554. interface HTMLVideoElement {
  153555. mozSrcObject: any;
  153556. }
  153557. interface Math {
  153558. fround(x: number): number;
  153559. imul(a: number, b: number): number;
  153560. }
  153561. interface WebGLRenderingContext {
  153562. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  153563. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  153564. vertexAttribDivisor(index: number, divisor: number): void;
  153565. createVertexArray(): any;
  153566. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  153567. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  153568. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  153569. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  153570. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  153571. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  153572. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  153573. // Queries
  153574. createQuery(): WebGLQuery;
  153575. deleteQuery(query: WebGLQuery): void;
  153576. beginQuery(target: number, query: WebGLQuery): void;
  153577. endQuery(target: number): void;
  153578. getQueryParameter(query: WebGLQuery, pname: number): any;
  153579. getQuery(target: number, pname: number): any;
  153580. MAX_SAMPLES: number;
  153581. RGBA8: number;
  153582. READ_FRAMEBUFFER: number;
  153583. DRAW_FRAMEBUFFER: number;
  153584. UNIFORM_BUFFER: number;
  153585. HALF_FLOAT_OES: number;
  153586. RGBA16F: number;
  153587. RGBA32F: number;
  153588. R32F: number;
  153589. RG32F: number;
  153590. RGB32F: number;
  153591. R16F: number;
  153592. RG16F: number;
  153593. RGB16F: number;
  153594. RED: number;
  153595. RG: number;
  153596. R8: number;
  153597. RG8: number;
  153598. UNSIGNED_INT_24_8: number;
  153599. DEPTH24_STENCIL8: number;
  153600. MIN: number;
  153601. MAX: number;
  153602. /* Multiple Render Targets */
  153603. drawBuffers(buffers: number[]): void;
  153604. readBuffer(src: number): void;
  153605. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  153606. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  153607. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  153608. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  153609. // Occlusion Query
  153610. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  153611. ANY_SAMPLES_PASSED: number;
  153612. QUERY_RESULT_AVAILABLE: number;
  153613. QUERY_RESULT: number;
  153614. }
  153615. interface WebGLProgram {
  153616. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  153617. }
  153618. interface EXT_disjoint_timer_query {
  153619. QUERY_COUNTER_BITS_EXT: number;
  153620. TIME_ELAPSED_EXT: number;
  153621. TIMESTAMP_EXT: number;
  153622. GPU_DISJOINT_EXT: number;
  153623. QUERY_RESULT_EXT: number;
  153624. QUERY_RESULT_AVAILABLE_EXT: number;
  153625. queryCounterEXT(query: WebGLQuery, target: number): void;
  153626. createQueryEXT(): WebGLQuery;
  153627. beginQueryEXT(target: number, query: WebGLQuery): void;
  153628. endQueryEXT(target: number): void;
  153629. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  153630. deleteQueryEXT(query: WebGLQuery): void;
  153631. }
  153632. interface WebGLUniformLocation {
  153633. _currentState: any;
  153634. }
  153635. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  153636. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  153637. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  153638. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153639. interface WebGLRenderingContext {
  153640. readonly RASTERIZER_DISCARD: number;
  153641. readonly DEPTH_COMPONENT24: number;
  153642. readonly TEXTURE_3D: number;
  153643. readonly TEXTURE_2D_ARRAY: number;
  153644. readonly TEXTURE_COMPARE_FUNC: number;
  153645. readonly TEXTURE_COMPARE_MODE: number;
  153646. readonly COMPARE_REF_TO_TEXTURE: number;
  153647. readonly TEXTURE_WRAP_R: number;
  153648. readonly HALF_FLOAT: number;
  153649. readonly RGB8: number;
  153650. readonly RED_INTEGER: number;
  153651. readonly RG_INTEGER: number;
  153652. readonly RGB_INTEGER: number;
  153653. readonly RGBA_INTEGER: number;
  153654. readonly R8_SNORM: number;
  153655. readonly RG8_SNORM: number;
  153656. readonly RGB8_SNORM: number;
  153657. readonly RGBA8_SNORM: number;
  153658. readonly R8I: number;
  153659. readonly RG8I: number;
  153660. readonly RGB8I: number;
  153661. readonly RGBA8I: number;
  153662. readonly R8UI: number;
  153663. readonly RG8UI: number;
  153664. readonly RGB8UI: number;
  153665. readonly RGBA8UI: number;
  153666. readonly R16I: number;
  153667. readonly RG16I: number;
  153668. readonly RGB16I: number;
  153669. readonly RGBA16I: number;
  153670. readonly R16UI: number;
  153671. readonly RG16UI: number;
  153672. readonly RGB16UI: number;
  153673. readonly RGBA16UI: number;
  153674. readonly R32I: number;
  153675. readonly RG32I: number;
  153676. readonly RGB32I: number;
  153677. readonly RGBA32I: number;
  153678. readonly R32UI: number;
  153679. readonly RG32UI: number;
  153680. readonly RGB32UI: number;
  153681. readonly RGBA32UI: number;
  153682. readonly RGB10_A2UI: number;
  153683. readonly R11F_G11F_B10F: number;
  153684. readonly RGB9_E5: number;
  153685. readonly RGB10_A2: number;
  153686. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  153687. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  153688. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  153689. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  153690. readonly DEPTH_COMPONENT32F: number;
  153691. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  153692. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  153693. 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;
  153694. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  153695. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  153696. readonly TRANSFORM_FEEDBACK: number;
  153697. readonly INTERLEAVED_ATTRIBS: number;
  153698. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  153699. createTransformFeedback(): WebGLTransformFeedback;
  153700. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  153701. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  153702. beginTransformFeedback(primitiveMode: number): void;
  153703. endTransformFeedback(): void;
  153704. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  153705. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153706. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153707. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153708. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  153709. }
  153710. interface ImageBitmap {
  153711. readonly width: number;
  153712. readonly height: number;
  153713. close(): void;
  153714. }
  153715. interface WebGLQuery extends WebGLObject {
  153716. }
  153717. declare var WebGLQuery: {
  153718. prototype: WebGLQuery;
  153719. new(): WebGLQuery;
  153720. };
  153721. interface WebGLSampler extends WebGLObject {
  153722. }
  153723. declare var WebGLSampler: {
  153724. prototype: WebGLSampler;
  153725. new(): WebGLSampler;
  153726. };
  153727. interface WebGLSync extends WebGLObject {
  153728. }
  153729. declare var WebGLSync: {
  153730. prototype: WebGLSync;
  153731. new(): WebGLSync;
  153732. };
  153733. interface WebGLTransformFeedback extends WebGLObject {
  153734. }
  153735. declare var WebGLTransformFeedback: {
  153736. prototype: WebGLTransformFeedback;
  153737. new(): WebGLTransformFeedback;
  153738. };
  153739. interface WebGLVertexArrayObject extends WebGLObject {
  153740. }
  153741. declare var WebGLVertexArrayObject: {
  153742. prototype: WebGLVertexArrayObject;
  153743. new(): WebGLVertexArrayObject;
  153744. };
  153745. // Type definitions for WebVR API
  153746. // Project: https://w3c.github.io/webvr/
  153747. // Definitions by: six a <https://github.com/lostfictions>
  153748. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153749. interface VRDisplay extends EventTarget {
  153750. /**
  153751. * Dictionary of capabilities describing the VRDisplay.
  153752. */
  153753. readonly capabilities: VRDisplayCapabilities;
  153754. /**
  153755. * z-depth defining the far plane of the eye view frustum
  153756. * enables mapping of values in the render target depth
  153757. * attachment to scene coordinates. Initially set to 10000.0.
  153758. */
  153759. depthFar: number;
  153760. /**
  153761. * z-depth defining the near plane of the eye view frustum
  153762. * enables mapping of values in the render target depth
  153763. * attachment to scene coordinates. Initially set to 0.01.
  153764. */
  153765. depthNear: number;
  153766. /**
  153767. * An identifier for this distinct VRDisplay. Used as an
  153768. * association point in the Gamepad API.
  153769. */
  153770. readonly displayId: number;
  153771. /**
  153772. * A display name, a user-readable name identifying it.
  153773. */
  153774. readonly displayName: string;
  153775. readonly isConnected: boolean;
  153776. readonly isPresenting: boolean;
  153777. /**
  153778. * If this VRDisplay supports room-scale experiences, the optional
  153779. * stage attribute contains details on the room-scale parameters.
  153780. */
  153781. readonly stageParameters: VRStageParameters | null;
  153782. /**
  153783. * Passing the value returned by `requestAnimationFrame` to
  153784. * `cancelAnimationFrame` will unregister the callback.
  153785. * @param handle Define the hanle of the request to cancel
  153786. */
  153787. cancelAnimationFrame(handle: number): void;
  153788. /**
  153789. * Stops presenting to the VRDisplay.
  153790. * @returns a promise to know when it stopped
  153791. */
  153792. exitPresent(): Promise<void>;
  153793. /**
  153794. * Return the current VREyeParameters for the given eye.
  153795. * @param whichEye Define the eye we want the parameter for
  153796. * @returns the eye parameters
  153797. */
  153798. getEyeParameters(whichEye: string): VREyeParameters;
  153799. /**
  153800. * Populates the passed VRFrameData with the information required to render
  153801. * the current frame.
  153802. * @param frameData Define the data structure to populate
  153803. * @returns true if ok otherwise false
  153804. */
  153805. getFrameData(frameData: VRFrameData): boolean;
  153806. /**
  153807. * Get the layers currently being presented.
  153808. * @returns the list of VR layers
  153809. */
  153810. getLayers(): VRLayer[];
  153811. /**
  153812. * Return a VRPose containing the future predicted pose of the VRDisplay
  153813. * when the current frame will be presented. The value returned will not
  153814. * change until JavaScript has returned control to the browser.
  153815. *
  153816. * The VRPose will contain the position, orientation, velocity,
  153817. * and acceleration of each of these properties.
  153818. * @returns the pose object
  153819. */
  153820. getPose(): VRPose;
  153821. /**
  153822. * Return the current instantaneous pose of the VRDisplay, with no
  153823. * prediction applied.
  153824. * @returns the current instantaneous pose
  153825. */
  153826. getImmediatePose(): VRPose;
  153827. /**
  153828. * The callback passed to `requestAnimationFrame` will be called
  153829. * any time a new frame should be rendered. When the VRDisplay is
  153830. * presenting the callback will be called at the native refresh
  153831. * rate of the HMD. When not presenting this function acts
  153832. * identically to how window.requestAnimationFrame acts. Content should
  153833. * make no assumptions of frame rate or vsync behavior as the HMD runs
  153834. * asynchronously from other displays and at differing refresh rates.
  153835. * @param callback Define the eaction to run next frame
  153836. * @returns the request handle it
  153837. */
  153838. requestAnimationFrame(callback: FrameRequestCallback): number;
  153839. /**
  153840. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  153841. * Repeat calls while already presenting will update the VRLayers being displayed.
  153842. * @param layers Define the list of layer to present
  153843. * @returns a promise to know when the request has been fulfilled
  153844. */
  153845. requestPresent(layers: VRLayer[]): Promise<void>;
  153846. /**
  153847. * Reset the pose for this display, treating its current position and
  153848. * orientation as the "origin/zero" values. VRPose.position,
  153849. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  153850. * updated when calling resetPose(). This should be called in only
  153851. * sitting-space experiences.
  153852. */
  153853. resetPose(): void;
  153854. /**
  153855. * The VRLayer provided to the VRDisplay will be captured and presented
  153856. * in the HMD. Calling this function has the same effect on the source
  153857. * canvas as any other operation that uses its source image, and canvases
  153858. * created without preserveDrawingBuffer set to true will be cleared.
  153859. * @param pose Define the pose to submit
  153860. */
  153861. submitFrame(pose?: VRPose): void;
  153862. }
  153863. declare var VRDisplay: {
  153864. prototype: VRDisplay;
  153865. new(): VRDisplay;
  153866. };
  153867. interface VRLayer {
  153868. leftBounds?: number[] | Float32Array | null;
  153869. rightBounds?: number[] | Float32Array | null;
  153870. source?: HTMLCanvasElement | null;
  153871. }
  153872. interface VRDisplayCapabilities {
  153873. readonly canPresent: boolean;
  153874. readonly hasExternalDisplay: boolean;
  153875. readonly hasOrientation: boolean;
  153876. readonly hasPosition: boolean;
  153877. readonly maxLayers: number;
  153878. }
  153879. interface VREyeParameters {
  153880. /** @deprecated */
  153881. readonly fieldOfView: VRFieldOfView;
  153882. readonly offset: Float32Array;
  153883. readonly renderHeight: number;
  153884. readonly renderWidth: number;
  153885. }
  153886. interface VRFieldOfView {
  153887. readonly downDegrees: number;
  153888. readonly leftDegrees: number;
  153889. readonly rightDegrees: number;
  153890. readonly upDegrees: number;
  153891. }
  153892. interface VRFrameData {
  153893. readonly leftProjectionMatrix: Float32Array;
  153894. readonly leftViewMatrix: Float32Array;
  153895. readonly pose: VRPose;
  153896. readonly rightProjectionMatrix: Float32Array;
  153897. readonly rightViewMatrix: Float32Array;
  153898. readonly timestamp: number;
  153899. }
  153900. interface VRPose {
  153901. readonly angularAcceleration: Float32Array | null;
  153902. readonly angularVelocity: Float32Array | null;
  153903. readonly linearAcceleration: Float32Array | null;
  153904. readonly linearVelocity: Float32Array | null;
  153905. readonly orientation: Float32Array | null;
  153906. readonly position: Float32Array | null;
  153907. readonly timestamp: number;
  153908. }
  153909. interface VRStageParameters {
  153910. sittingToStandingTransform?: Float32Array;
  153911. sizeX?: number;
  153912. sizeY?: number;
  153913. }
  153914. interface Navigator {
  153915. getVRDisplays(): Promise<VRDisplay[]>;
  153916. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  153917. }
  153918. interface Window {
  153919. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  153920. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  153921. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  153922. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153923. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153924. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  153925. }
  153926. interface Gamepad {
  153927. readonly displayId: number;
  153928. }
  153929. type XRSessionMode =
  153930. | "inline"
  153931. | "immersive-vr"
  153932. | "immersive-ar";
  153933. type XRReferenceSpaceType =
  153934. | "viewer"
  153935. | "local"
  153936. | "local-floor"
  153937. | "bounded-floor"
  153938. | "unbounded";
  153939. type XREnvironmentBlendMode =
  153940. | "opaque"
  153941. | "additive"
  153942. | "alpha-blend";
  153943. type XRVisibilityState =
  153944. | "visible"
  153945. | "visible-blurred"
  153946. | "hidden";
  153947. type XRHandedness =
  153948. | "none"
  153949. | "left"
  153950. | "right";
  153951. type XRTargetRayMode =
  153952. | "gaze"
  153953. | "tracked-pointer"
  153954. | "screen";
  153955. type XREye =
  153956. | "none"
  153957. | "left"
  153958. | "right";
  153959. type XREventType =
  153960. | "devicechange"
  153961. | "visibilitychange"
  153962. | "end"
  153963. | "inputsourceschange"
  153964. | "select"
  153965. | "selectstart"
  153966. | "selectend"
  153967. | "squeeze"
  153968. | "squeezestart"
  153969. | "squeezeend"
  153970. | "reset";
  153971. interface XRSpace extends EventTarget {
  153972. }
  153973. interface XRRenderState {
  153974. depthNear?: number;
  153975. depthFar?: number;
  153976. inlineVerticalFieldOfView?: number;
  153977. baseLayer?: XRWebGLLayer;
  153978. }
  153979. interface XRInputSource {
  153980. handedness: XRHandedness;
  153981. targetRayMode: XRTargetRayMode;
  153982. targetRaySpace: XRSpace;
  153983. gripSpace: XRSpace | undefined;
  153984. gamepad: Gamepad | undefined;
  153985. profiles: Array<string>;
  153986. }
  153987. interface XRSessionInit {
  153988. optionalFeatures?: string[];
  153989. requiredFeatures?: string[];
  153990. }
  153991. interface XRSession {
  153992. addEventListener: Function;
  153993. removeEventListener: Function;
  153994. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  153995. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  153996. requestAnimationFrame: Function;
  153997. end(): Promise<void>;
  153998. renderState: XRRenderState;
  153999. inputSources: Array<XRInputSource>;
  154000. // hit test
  154001. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  154002. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  154003. // legacy AR hit test
  154004. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154005. // legacy plane detection
  154006. updateWorldTrackingState(options: {
  154007. planeDetectionState?: { enabled: boolean; }
  154008. }): void;
  154009. }
  154010. interface XRReferenceSpace extends XRSpace {
  154011. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  154012. onreset: any;
  154013. }
  154014. type XRPlaneSet = Set<XRPlane>;
  154015. type XRAnchorSet = Set<XRAnchor>;
  154016. interface XRFrame {
  154017. session: XRSession;
  154018. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  154019. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  154020. // AR
  154021. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  154022. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  154023. // Anchors
  154024. trackedAnchors?: XRAnchorSet;
  154025. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  154026. // Planes
  154027. worldInformation: {
  154028. detectedPlanes?: XRPlaneSet;
  154029. };
  154030. }
  154031. interface XRViewerPose extends XRPose {
  154032. views: Array<XRView>;
  154033. }
  154034. interface XRPose {
  154035. transform: XRRigidTransform;
  154036. emulatedPosition: boolean;
  154037. }
  154038. interface XRWebGLLayerOptions {
  154039. antialias?: boolean;
  154040. depth?: boolean;
  154041. stencil?: boolean;
  154042. alpha?: boolean;
  154043. multiview?: boolean;
  154044. framebufferScaleFactor?: number;
  154045. }
  154046. declare var XRWebGLLayer: {
  154047. prototype: XRWebGLLayer;
  154048. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  154049. };
  154050. interface XRWebGLLayer {
  154051. framebuffer: WebGLFramebuffer;
  154052. framebufferWidth: number;
  154053. framebufferHeight: number;
  154054. getViewport: Function;
  154055. }
  154056. declare class XRRigidTransform {
  154057. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  154058. position: DOMPointReadOnly;
  154059. orientation: DOMPointReadOnly;
  154060. matrix: Float32Array;
  154061. inverse: XRRigidTransform;
  154062. }
  154063. interface XRView {
  154064. eye: XREye;
  154065. projectionMatrix: Float32Array;
  154066. transform: XRRigidTransform;
  154067. }
  154068. interface XRInputSourceChangeEvent {
  154069. session: XRSession;
  154070. removed: Array<XRInputSource>;
  154071. added: Array<XRInputSource>;
  154072. }
  154073. interface XRInputSourceEvent extends Event {
  154074. readonly frame: XRFrame;
  154075. readonly inputSource: XRInputSource;
  154076. }
  154077. // Experimental(er) features
  154078. declare class XRRay {
  154079. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  154080. origin: DOMPointReadOnly;
  154081. direction: DOMPointReadOnly;
  154082. matrix: Float32Array;
  154083. }
  154084. declare enum XRHitTestTrackableType {
  154085. "point",
  154086. "plane"
  154087. }
  154088. interface XRHitResult {
  154089. hitMatrix: Float32Array;
  154090. }
  154091. interface XRTransientInputHitTestResult {
  154092. readonly inputSource: XRInputSource;
  154093. readonly results: Array<XRHitTestResult>;
  154094. }
  154095. interface XRHitTestResult {
  154096. getPose(baseSpace: XRSpace): XRPose | undefined;
  154097. // When anchor system is enabled
  154098. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  154099. }
  154100. interface XRHitTestSource {
  154101. cancel(): void;
  154102. }
  154103. interface XRTransientInputHitTestSource {
  154104. cancel(): void;
  154105. }
  154106. interface XRHitTestOptionsInit {
  154107. space: XRSpace;
  154108. entityTypes?: Array<XRHitTestTrackableType>;
  154109. offsetRay?: XRRay;
  154110. }
  154111. interface XRTransientInputHitTestOptionsInit {
  154112. profile: string;
  154113. entityTypes?: Array<XRHitTestTrackableType>;
  154114. offsetRay?: XRRay;
  154115. }
  154116. interface XRAnchor {
  154117. anchorSpace: XRSpace;
  154118. delete(): void;
  154119. }
  154120. interface XRPlane {
  154121. orientation: "Horizontal" | "Vertical";
  154122. planeSpace: XRSpace;
  154123. polygon: Array<DOMPointReadOnly>;
  154124. lastChangedTime: number;
  154125. }